@@ -1965,11 +1965,11 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
1965
1965
1966
1966
int ImStrcmp(ImStrv str1, ImStrv str2)
1967
1967
{
1968
- size_t str1_len = str1.length();
1969
- size_t str2_len = str2.length();
1968
+ int str1_len = str1.length();
1969
+ int str2_len = str2.length();
1970
1970
if (str1_len != str2_len)
1971
- return (int) str1_len - (int) str2_len;
1972
- return memcmp(str1.Begin, str2.Begin, str1_len);
1971
+ return str1_len - str2_len;
1972
+ return memcmp(str1.Begin, str2.Begin, (size_t) str1_len);
1973
1973
}
1974
1974
1975
1975
// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more.
@@ -2000,7 +2000,7 @@ void ImStrncpy(char* dst, ImStrv src, size_t count)
2000
2000
{
2001
2001
// Even though src does not necessarily include \0 terminator it is ok to include it. ImStrncpy above does not
2002
2002
// actually include that in a copy operation and inserts zero terminator manually.
2003
- ImStrncpy(dst, src.Begin, ImMin(count, src.length() + 1));
2003
+ ImStrncpy(dst, src.Begin, ImMin(count, (size_t) src.length() + 1));
2004
2004
}
2005
2005
2006
2006
char* ImStrdup(const char* str)
@@ -2012,7 +2012,7 @@ char* ImStrdup(const char* str)
2012
2012
2013
2013
char* ImStrdup(ImStrv str)
2014
2014
{
2015
- size_t len = str.length();
2015
+ size_t len = (size_t) str.length();
2016
2016
void* buf = IM_ALLOC(len + 1);
2017
2017
*((char*)buf + len) = 0; // str may not contain \0, it must be inserted manually.
2018
2018
if (len > 0)
@@ -2023,7 +2023,7 @@ char* ImStrdup(ImStrv str)
2023
2023
char* ImStrdupcpy(char* dst, size_t* p_dst_size, ImStrv src)
2024
2024
{
2025
2025
size_t dst_buf_size = p_dst_size ? *p_dst_size : ImStrlen(dst) + 1;
2026
- size_t src_size = src.length() + 1;
2026
+ size_t src_size = (size_t) src.length() + 1;
2027
2027
if (dst_buf_size < src_size)
2028
2028
{
2029
2029
IM_FREE(dst);
@@ -2097,7 +2097,7 @@ const char* ImStrstr(ImStrv haystack, ImStrv needle)
2097
2097
{
2098
2098
const char un0 = (char)*needle.Begin;
2099
2099
const char* p = haystack.Begin;
2100
- const size_t needle_len_m1 = needle.length() - 1;
2100
+ const size_t needle_len_m1 = (size_t) needle.length() - 1;
2101
2101
while (true)
2102
2102
{
2103
2103
p = (const char*)memchr(p, un0, haystack.End - p);
@@ -2321,7 +2321,7 @@ ImGuiID ImHashStr(ImStrv str, ImGuiID seed)
2321
2321
#endif
2322
2322
if (str.End != NULL)
2323
2323
{
2324
- size_t data_size = str.length();
2324
+ size_t data_size = (size_t) str.length();
2325
2325
while (data_size-- != 0)
2326
2326
{
2327
2327
unsigned char c = *data++;
@@ -2362,8 +2362,8 @@ ImFileHandle ImFileOpen(ImStrv filename, ImStrv mode)
2362
2362
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (defined(__MINGW32__) || (!defined(__CYGWIN__) && !defined(__GNUC__)))
2363
2363
// We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames.
2364
2364
// Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32!
2365
- const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, (int) filename.length() + 1, NULL, 0);
2366
- const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, (int) mode.length() + 1, NULL, 0);
2365
+ const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, filename.length() + 1, NULL, 0);
2366
+ const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, mode.length() + 1, NULL, 0);
2367
2367
2368
2368
// Use stack buffer if possible, otherwise heap buffer. Sizes include zero terminator.
2369
2369
// We don't rely on current ImGuiContext as this is implied to be a helper function which doesn't depend on it (see #7314).
@@ -2373,8 +2373,8 @@ ImFileHandle ImFileOpen(ImStrv filename, ImStrv mode)
2373
2373
local_temp_heap.resize(filename_wsize + mode_wsize);
2374
2374
wchar_t* filename_wbuf = local_temp_heap.Data ? local_temp_heap.Data : local_temp_stack;
2375
2375
wchar_t* mode_wbuf = filename_wbuf + filename_wsize;
2376
- ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, (int) filename.length(), filename_wbuf, filename_wsize);
2377
- ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, (int) mode.length(), mode_wbuf, mode_wsize);
2376
+ ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, filename.length(), filename_wbuf, filename_wsize);
2377
+ ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, mode.length(), mode_wbuf, mode_wsize);
2378
2378
filename_wbuf[filename_wsize - 1] = mode_wbuf[mode_wsize - 1] = 0;
2379
2379
return ::_wfopen(filename_wbuf, mode_wbuf);
2380
2380
#else
@@ -2978,7 +2978,7 @@ char ImGuiTextBuffer::EmptyString[1] = { 0 };
2978
2978
2979
2979
void ImGuiTextBuffer::append(ImStrv str)
2980
2980
{
2981
- int len = (int) str.length();
2981
+ const int len = str.length();
2982
2982
if (len == 0)
2983
2983
return;
2984
2984
@@ -4340,7 +4340,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* ctx, ImStrv name) : DrawListInst(NULL)
4340
4340
memset(this, 0, sizeof(*this));
4341
4341
Ctx = ctx;
4342
4342
Name = ImStrdup(name);
4343
- NameBufLen = (int) name.length() + 1;
4343
+ NameBufLen = name.length() + 1;
4344
4344
ID = ImHashStr(name);
4345
4345
IDStack.push_back(ID);
4346
4346
MoveId = GetID("#MOVE");
@@ -4875,7 +4875,7 @@ void ImGui::SetClipboardText(ImStrv text)
4875
4875
ImGuiContext& g = *GImGui;
4876
4876
if (g.PlatformIO.Platform_SetClipboardTextFn != NULL)
4877
4877
{
4878
- int len = (int) text.length();
4878
+ int len = text.length();
4879
4879
char* text_p = (char*)IM_ALLOC(len + 1);
4880
4880
if (len > 0)
4881
4881
memcpy(text_p, text.Begin, len);
@@ -6173,10 +6173,10 @@ bool ImGui::BeginChildEx(ImStrv name, ImGuiID id, const ImVec2& size_arg, ImGuiC
6173
6173
// e.g. "ParentName###ParentIdentifier/ChildName###ChildIdentifier" would get hashed incorrectly by ImHashStr(), trailing _%08X somehow fixes it.
6174
6174
ImStrv temp_window_name;
6175
6175
/*if (name && parent_window->IDStack.back() == parent_window->ID)
6176
- ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s", parent_window->Name, (int) name.length(), name.Begin); // May omit ID if in root of ID stack
6176
+ ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s", parent_window->Name, name.length(), name.Begin); // May omit ID if in root of ID stack
6177
6177
else*/
6178
6178
if (name)
6179
- ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s_%08X", parent_window->Name, (int) name.length(), name.Begin, id);
6179
+ ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s_%08X", parent_window->Name, name.length(), name.Begin, id);
6180
6180
else
6181
6181
ImFormatStringToTempBuffer(&temp_window_name, "%s/%08X", parent_window->Name, id);
6182
6182
@@ -11794,7 +11794,7 @@ bool ImGui::BeginPopupMenuEx(ImGuiID id, ImStrv label, ImGuiWindowFlags extra_wi
11794
11794
11795
11795
char name[128];
11796
11796
IM_ASSERT(extra_window_flags & ImGuiWindowFlags_ChildMenu);
11797
- ImFormatString(name, IM_ARRAYSIZE(name), "%.*s###Menu_%02d", (int) label.length(), label.Begin, g.BeginMenuDepth); // Recycle windows based on depth
11797
+ ImFormatString(name, IM_ARRAYSIZE(name), "%.*s###Menu_%02d", label.length(), label.Begin, g.BeginMenuDepth); // Recycle windows based on depth
11798
11798
bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup);
11799
11799
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
11800
11800
EndPopup();
@@ -14741,7 +14741,7 @@ void ImGui::LoadIniSettingsFromMemory(ImStrv ini_data)
14741
14741
14742
14742
// For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
14743
14743
// For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
14744
- const int ini_size = (int) ini_data.length();
14744
+ const int ini_size = ini_data.length();
14745
14745
g.SettingsIniData.Buf.resize((int)ini_size + 1);
14746
14746
char* const buf = g.SettingsIniData.Buf.Data;
14747
14747
char* const buf_end = buf + ini_size;
@@ -14843,7 +14843,7 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(ImStrv name)
14843
14843
name.Begin = p;
14844
14844
}
14845
14845
14846
- const size_t name_len = name.length();
14846
+ const size_t name_len = (size_t) name.length();
14847
14847
if (!name_len)
14848
14848
{
14849
14849
IM_ASSERT(false && "Name must not be empty.");
@@ -15430,7 +15430,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
15430
15430
// Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct.
15431
15431
void ImGui::DebugTextEncoding(ImStrv str)
15432
15432
{
15433
- Text("Text: \"%.*s\"", (int) str.length(), str.Begin);
15433
+ Text("Text: \"%.*s\"", str.length(), str.Begin);
15434
15434
if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
15435
15435
return;
15436
15436
TableSetupColumn("Offset");
0 commit comments