@@ -2054,11 +2054,11 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
20542054
20552055int ImStrcmp(ImStrv str1, ImStrv str2)
20562056{
2057- size_t str1_len = str1.length();
2058- size_t str2_len = str2.length();
2057+ int str1_len = str1.length();
2058+ int str2_len = str2.length();
20592059 if (str1_len != str2_len)
2060- return (int) str1_len - (int) str2_len;
2061- return memcmp(str1.Begin, str2.Begin, str1_len);
2060+ return str1_len - str2_len;
2061+ return memcmp(str1.Begin, str2.Begin, (size_t) str1_len);
20622062}
20632063
20642064// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more.
@@ -2089,7 +2089,7 @@ void ImStrncpy(char* dst, ImStrv src, size_t count)
20892089{
20902090 // Even though src does not necessarily include \0 terminator it is ok to include it. ImStrncpy above does not
20912091 // actually include that in a copy operation and inserts zero terminator manually.
2092- ImStrncpy(dst, src.Begin, ImMin(count, src.length() + 1));
2092+ ImStrncpy(dst, src.Begin, ImMin(count, (size_t) src.length() + 1));
20932093}
20942094
20952095char* ImStrdup(const char* str)
@@ -2101,7 +2101,7 @@ char* ImStrdup(const char* str)
21012101
21022102char* ImStrdup(ImStrv str)
21032103{
2104- size_t len = str.length();
2104+ size_t len = (size_t) str.length();
21052105 void* buf = IM_ALLOC(len + 1);
21062106 *((char*)buf + len) = 0; // str may not contain \0, it must be inserted manually.
21072107 if (len > 0)
@@ -2112,7 +2112,7 @@ char* ImStrdup(ImStrv str)
21122112char* ImStrdupcpy(char* dst, size_t* p_dst_size, ImStrv src)
21132113{
21142114 size_t dst_buf_size = p_dst_size ? *p_dst_size : ImStrlen(dst) + 1;
2115- size_t src_size = src.length() + 1;
2115+ size_t src_size = (size_t) src.length() + 1;
21162116 if (dst_buf_size < src_size)
21172117 {
21182118 IM_FREE(dst);
@@ -2192,7 +2192,7 @@ const char* ImStrstr(ImStrv haystack, ImStrv needle)
21922192{
21932193 const char un0 = (char)*needle.Begin;
21942194 const char* p = haystack.Begin;
2195- const size_t needle_len_m1 = needle.length() - 1;
2195+ const size_t needle_len_m1 = (size_t) needle.length() - 1;
21962196 while (true)
21972197 {
21982198 p = (const char*)memchr(p, un0, haystack.End - p);
@@ -2416,7 +2416,7 @@ ImGuiID ImHashStr(ImStrv str, ImGuiID seed)
24162416#endif
24172417 if (str.End != NULL)
24182418 {
2419- size_t data_size = str.length();
2419+ size_t data_size = (size_t) str.length();
24202420 while (data_size-- != 0)
24212421 {
24222422 unsigned char c = *data++;
@@ -2468,8 +2468,8 @@ ImFileHandle ImFileOpen(ImStrv filename, ImStrv mode)
24682468#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (defined(__MINGW32__) || (!defined(__CYGWIN__) && !defined(__GNUC__)))
24692469 // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames.
24702470 // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32!
2471- const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, (int) filename.length() + 1, NULL, 0);
2472- const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, (int) mode.length() + 1, NULL, 0);
2471+ const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, filename.length() + 1, NULL, 0);
2472+ const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, mode.length() + 1, NULL, 0);
24732473
24742474 // Use stack buffer if possible, otherwise heap buffer. Sizes include zero terminator.
24752475 // We don't rely on current ImGuiContext as this is implied to be a helper function which doesn't depend on it (see #7314).
@@ -2479,8 +2479,8 @@ ImFileHandle ImFileOpen(ImStrv filename, ImStrv mode)
24792479 local_temp_heap.resize(filename_wsize + mode_wsize);
24802480 wchar_t* filename_wbuf = local_temp_heap.Data ? local_temp_heap.Data : local_temp_stack;
24812481 wchar_t* mode_wbuf = filename_wbuf + filename_wsize;
2482- ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, (int) filename.length(), filename_wbuf, filename_wsize);
2483- ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, (int) mode.length(), mode_wbuf, mode_wsize);
2482+ ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, filename.length(), filename_wbuf, filename_wsize);
2483+ ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, mode.length(), mode_wbuf, mode_wsize);
24842484 filename_wbuf[filename_wsize - 1] = mode_wbuf[mode_wsize - 1] = 0;
24852485 return ::_wfopen(filename_wbuf, mode_wbuf);
24862486#else
@@ -3097,7 +3097,7 @@ char ImGuiTextBuffer::EmptyString[1] = { 0 };
30973097
30983098void ImGuiTextBuffer::append(ImStrv str)
30993099{
3100- int len = (int) str.length();
3100+ const int len = str.length();
31013101 if (len == 0)
31023102 return;
31033103
@@ -4511,7 +4511,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* ctx, ImStrv name) : DrawListInst(NULL)
45114511 memset(this, 0, sizeof(*this));
45124512 Ctx = ctx;
45134513 Name = ImStrdup(name);
4514- NameBufLen = (int) name.length() + 1;
4514+ NameBufLen = name.length() + 1;
45154515 ID = ImHashStr(name);
45164516 IDStack.push_back(ID);
45174517 MoveId = GetID("#MOVE");
@@ -5069,7 +5069,7 @@ void ImGui::SetClipboardText(ImStrv text)
50695069 ImGuiContext& g = *GImGui;
50705070 if (g.PlatformIO.Platform_SetClipboardTextFn != NULL)
50715071 {
5072- int len = (int) text.length();
5072+ int len = text.length();
50735073 char* text_p = (char*)IM_ALLOC(len + 1);
50745074 if (len > 0)
50755075 memcpy(text_p, text.Begin, len);
@@ -6407,10 +6407,10 @@ bool ImGui::BeginChildEx(ImStrv name, ImGuiID id, const ImVec2& size_arg, ImGuiC
64076407 // e.g. "ParentName###ParentIdentifier/ChildName###ChildIdentifier" would get hashed incorrectly by ImHashStr(), trailing _%08X somehow fixes it.
64086408 ImStrv temp_window_name;
64096409 /*if (name && parent_window->IDStack.back() == parent_window->ID)
6410- ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s", parent_window->Name, (int) name.length(), name.Begin); // May omit ID if in root of ID stack
6410+ ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s", parent_window->Name, name.length(), name.Begin); // May omit ID if in root of ID stack
64116411 else*/
64126412 if (name)
6413- ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s_%08X", parent_window->Name, (int) name.length(), name.Begin, id);
6413+ ImFormatStringToTempBuffer(&temp_window_name, "%s/%.*s_%08X", parent_window->Name, name.length(), name.Begin, id);
64146414 else
64156415 ImFormatStringToTempBuffer(&temp_window_name, "%s/%08X", parent_window->Name, id);
64166416
@@ -12321,7 +12321,7 @@ bool ImGui::BeginPopupMenuEx(ImGuiID id, ImStrv label, ImGuiWindowFlags extra_wi
1232112321
1232212322 char name[128];
1232312323 IM_ASSERT(extra_window_flags & ImGuiWindowFlags_ChildMenu);
12324- ImFormatString(name, IM_ARRAYSIZE(name), "%.*s###Menu_%02d", (int) label.length(), label.Begin, g.BeginMenuDepth); // Recycle windows based on depth
12324+ ImFormatString(name, IM_ARRAYSIZE(name), "%.*s###Menu_%02d", label.length(), label.Begin, g.BeginMenuDepth); // Recycle windows based on depth
1232512325 bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup);
1232612326 if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
1232712327 EndPopup();
@@ -15320,7 +15320,7 @@ void ImGui::LoadIniSettingsFromMemory(ImStrv ini_data)
1532015320
1532115321 // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
1532215322 // 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..
15323- const int ini_size = (int) ini_data.length();
15323+ const int ini_size = ini_data.length();
1532415324 g.SettingsIniData.Buf.resize((int)ini_size + 1);
1532515325 char* const buf = g.SettingsIniData.Buf.Data;
1532615326 char* const buf_end = buf + ini_size;
@@ -15417,7 +15417,7 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(ImStrv name)
1541715417 // Preserve the full string when ConfigDebugVerboseIniSettings is set to make .ini inspection easier.
1541815418 if (g.IO.ConfigDebugIniSettings == false)
1541915419 name.Begin = ImHashSkipUncontributingPrefix(name);
15420- const size_t name_len = name.length();
15420+ const size_t name_len = (size_t) name.length();
1542115421 if (name_len == 0)
1542215422 {
1542315423 IM_ASSERT(false && "Name must not be empty.");
@@ -16044,7 +16044,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
1604416044// Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct.
1604516045void ImGui::DebugTextEncoding(ImStrv str)
1604616046{
16047- Text("Text: \"%.*s\"", (int) str.length(), str.Begin);
16047+ Text("Text: \"%.*s\"", str.length(), str.Begin);
1604816048 if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
1604916049 return;
1605016050 TableSetupColumn("Offset");
0 commit comments