mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Strip seemingly unecessary tests, as UTF-8 decoder can not return null since 9cca1b2e9
This commit is contained in:
parent
55b8ce9b23
commit
ccf94e2e6e
@ -1288,8 +1288,7 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||
{
|
||||
unsigned int c = 0;
|
||||
utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL);
|
||||
if (c != 0)
|
||||
AddInputCharacter(c);
|
||||
AddInputCharacter(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2032,8 +2031,6 @@ int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const cha
|
||||
{
|
||||
unsigned int c;
|
||||
in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
|
||||
if (c == 0)
|
||||
break;
|
||||
*buf_out++ = (ImWchar)c;
|
||||
}
|
||||
*buf_out = 0;
|
||||
@ -2049,8 +2046,6 @@ int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end)
|
||||
{
|
||||
unsigned int c;
|
||||
in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
|
||||
if (c == 0)
|
||||
break;
|
||||
char_count++;
|
||||
}
|
||||
return char_count;
|
||||
|
@ -3382,6 +3382,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
bool inside_word = true;
|
||||
|
||||
const char* s = text;
|
||||
IM_ASSERT(text_end != NULL);
|
||||
while (s < text_end)
|
||||
{
|
||||
unsigned int c = (unsigned int)*s;
|
||||
@ -3390,8 +3391,6 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
next_s = s + 1;
|
||||
else
|
||||
next_s = s + ImTextCharFromUtf8(&c, s, text_end);
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
@ -3497,15 +3496,9 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||
const char* prev_s = s;
|
||||
unsigned int c = (unsigned int)*s;
|
||||
if (c < 0x80)
|
||||
{
|
||||
s += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
s += ImTextCharFromUtf8(&c, s, text_end);
|
||||
if (c == 0) // Malformed UTF-8?
|
||||
break;
|
||||
}
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
@ -3647,15 +3640,9 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
||||
// Decode and advance source
|
||||
unsigned int c = (unsigned int)*s;
|
||||
if (c < 0x80)
|
||||
{
|
||||
s += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
s += ImTextCharFromUtf8(&c, s, text_end);
|
||||
if (c == 0) // Malformed UTF-8?
|
||||
break;
|
||||
}
|
||||
|
||||
if (c < 32)
|
||||
{
|
||||
|
@ -4407,12 +4407,10 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
const int clipboard_len = (int)strlen(clipboard);
|
||||
ImWchar* clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len + 1) * sizeof(ImWchar));
|
||||
int clipboard_filtered_len = 0;
|
||||
for (const char* s = clipboard; *s; )
|
||||
for (const char* s = clipboard; *s != 0; )
|
||||
{
|
||||
unsigned int c;
|
||||
s += ImTextCharFromUtf8(&c, s, NULL);
|
||||
if (c == 0)
|
||||
break;
|
||||
if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Clipboard))
|
||||
continue;
|
||||
clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c;
|
||||
|
Loading…
Reference in New Issue
Block a user