mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-29 03:00:05 +00:00
Internals: String functions uses size_t in their signature
This commit is contained in:
parent
996dfb21cf
commit
c8c872c753
2 changed files with 13 additions and 13 deletions
18
imgui.cpp
18
imgui.cpp
|
|
@ -911,17 +911,17 @@ int ImStricmp(const char* str1, const char* str2)
|
|||
return d;
|
||||
}
|
||||
|
||||
int ImStrnicmp(const char* str1, const char* str2, int count)
|
||||
int ImStrnicmp(const char* str1, const char* str2, size_t count)
|
||||
{
|
||||
int d = 0;
|
||||
while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; }
|
||||
return d;
|
||||
}
|
||||
|
||||
void ImStrncpy(char* dst, const char* src, int count)
|
||||
void ImStrncpy(char* dst, const char* src, size_t count)
|
||||
{
|
||||
if (count < 1) return;
|
||||
strncpy(dst, src, (size_t)count);
|
||||
strncpy(dst, src, count);
|
||||
dst[count-1] = 0;
|
||||
}
|
||||
|
||||
|
|
@ -992,7 +992,7 @@ static const char* ImAtoi(const char* src, int* output)
|
|||
// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm.
|
||||
// B) When buf==NULL vsnprintf() will return the output size.
|
||||
#ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
|
||||
int ImFormatString(char* buf, int buf_size, const char* fmt, ...)
|
||||
int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
|
@ -1000,19 +1000,19 @@ int ImFormatString(char* buf, int buf_size, const char* fmt, ...)
|
|||
va_end(args);
|
||||
if (buf == NULL)
|
||||
return w;
|
||||
if (w == -1 || w >= buf_size)
|
||||
w = buf_size - 1;
|
||||
if (w == -1 || w >= (int)buf_size)
|
||||
w = (int)buf_size - 1;
|
||||
buf[w] = 0;
|
||||
return w;
|
||||
}
|
||||
|
||||
int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args)
|
||||
int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
|
||||
{
|
||||
int w = vsnprintf(buf, buf_size, fmt, args);
|
||||
if (buf == NULL)
|
||||
return w;
|
||||
if (w == -1 || w >= buf_size)
|
||||
w = buf_size - 1;
|
||||
if (w == -1 || w >= (int)buf_size)
|
||||
w = (int)buf_size - 1;
|
||||
buf[w] = 0;
|
||||
return w;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue