Do not pass negative values to isspace()

MSVCRT debug versions assert that.
This commit is contained in:
kichikuou
2024-08-15 16:50:52 +09:00
parent c1273bd3e3
commit f700a717d7
+3 -3
View File
@@ -38,7 +38,7 @@ std::string normalize_path(std::string s)
bool is_empty_line(const char *s)
{
for (; *s; s++) {
if (!isspace(*s))
if (!isspace((unsigned char)*s))
return false;
}
return true;
@@ -46,10 +46,10 @@ bool is_empty_line(const char *s)
char *trim(char *s)
{
while (isspace(*s))
while (isspace((unsigned char)*s))
s++;
char *p = s + strlen(s) - 1;
while (p > s && isspace(*p))
while (p > s && isspace((unsigned char)*p))
*p-- = '\0';
return s;
}