diff --git a/ccutil/unicharset.cpp b/ccutil/unicharset.cpp index 43adc4367..0cc192b95 100644 --- a/ccutil/unicharset.cpp +++ b/ccutil/unicharset.cpp @@ -1115,11 +1115,11 @@ int UNICHARSET::get_script_id_from_name(const char* script_name) const { // Removes/replaces content that belongs in rendered text, but not in the // unicharset. /* static */ -std::string UNICHARSET::CleanupString(const char* utf8_str, int length) { +std::string UNICHARSET::CleanupString(const char* utf8_str, size_t length) { std::string result; result.reserve(length); char ch; - while ((ch = *utf8_str) != '\0' && --length >= 0) { + while ((ch = *utf8_str) != '\0' && length-- > 0) { int key_index = 0; const char* key; while ((key = kCleanupMaps[key_index][0]) != nullptr) { diff --git a/ccutil/unicharset.h b/ccutil/unicharset.h index 44696cb1a..eb48c25bd 100644 --- a/ccutil/unicharset.h +++ b/ccutil/unicharset.h @@ -241,7 +241,7 @@ class UNICHARSET { static std::string CleanupString(const char* utf8_str) { return CleanupString(utf8_str, strlen(utf8_str)); } - static std::string CleanupString(const char* utf8_str, int length); + static std::string CleanupString(const char* utf8_str, size_t length); // Return a STRING containing debug information on the unichar, including // the id_to_unichar, its hex unicodes and the properties.