mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	Internals: String functions uses size_t in their signature
This commit is contained in:
		
							
								
								
									
										18
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -911,17 +911,17 @@ int ImStricmp(const char* str1, const char* str2) | |||||||
|     return d; |     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; |     int d = 0; | ||||||
|     while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } |     while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } | ||||||
|     return d; |     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; |     if (count < 1) return; | ||||||
|     strncpy(dst, src, (size_t)count); |     strncpy(dst, src, count); | ||||||
|     dst[count-1] = 0; |     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. | // 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. | // B) When buf==NULL vsnprintf() will return the output size. | ||||||
| #ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS | #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_list args; | ||||||
|     va_start(args, fmt); |     va_start(args, fmt); | ||||||
| @@ -1000,19 +1000,19 @@ int ImFormatString(char* buf, int buf_size, const char* fmt, ...) | |||||||
|     va_end(args); |     va_end(args); | ||||||
|     if (buf == NULL) |     if (buf == NULL) | ||||||
|         return w; |         return w; | ||||||
|     if (w == -1 || w >= buf_size) |     if (w == -1 || w >= (int)buf_size) | ||||||
|         w = buf_size - 1; |         w = (int)buf_size - 1; | ||||||
|     buf[w] = 0; |     buf[w] = 0; | ||||||
|     return w; |     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); |     int w = vsnprintf(buf, buf_size, fmt, args); | ||||||
|     if (buf == NULL) |     if (buf == NULL) | ||||||
|         return w; |         return w; | ||||||
|     if (w == -1 || w >= buf_size) |     if (w == -1 || w >= (int)buf_size) | ||||||
|         w = buf_size - 1; |         w = (int)buf_size - 1; | ||||||
|     buf[w] = 0; |     buf[w] = 0; | ||||||
|     return w; |     return w; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -103,15 +103,15 @@ IMGUI_API void          ImTriangleBarycentricCoords(const ImVec2& a, const ImVec | |||||||
|  |  | ||||||
| // Helpers: String | // Helpers: String | ||||||
| IMGUI_API int           ImStricmp(const char* str1, const char* str2); | IMGUI_API int           ImStricmp(const char* str1, const char* str2); | ||||||
| IMGUI_API int           ImStrnicmp(const char* str1, const char* str2, int count); | IMGUI_API int           ImStrnicmp(const char* str1, const char* str2, size_t count); | ||||||
| IMGUI_API void          ImStrncpy(char* dst, const char* src, int count); | IMGUI_API void          ImStrncpy(char* dst, const char* src, size_t count); | ||||||
| IMGUI_API char*         ImStrdup(const char* str); | IMGUI_API char*         ImStrdup(const char* str); | ||||||
| IMGUI_API char*         ImStrchrRange(const char* str_begin, const char* str_end, char c); | IMGUI_API char*         ImStrchrRange(const char* str_begin, const char* str_end, char c); | ||||||
| IMGUI_API int           ImStrlenW(const ImWchar* str); | IMGUI_API int           ImStrlenW(const ImWchar* str); | ||||||
| IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line | IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line | ||||||
| IMGUI_API const char*   ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); | IMGUI_API const char*   ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); | ||||||
| IMGUI_API int           ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_FMTARGS(3); | IMGUI_API int           ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3); | ||||||
| IMGUI_API int           ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args) IM_FMTLIST(3); | IMGUI_API int           ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3); | ||||||
|  |  | ||||||
| // Helpers: Math | // Helpers: Math | ||||||
| // We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined) | // We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user