From 109558d74d116900f3528862d062deefa3cb14d8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Nov 2016 13:12:55 +0100 Subject: [PATCH] - added unsigned char casts to all isspace calls in zstring.cpp isspace takes a signed integer as parameter which triggers an assert on any non-ASCII character taken from a signed char array. --- src/zstring.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/zstring.cpp b/src/zstring.cpp index b6e5b4b8d..e8e867323 100644 --- a/src/zstring.cpp +++ b/src/zstring.cpp @@ -632,7 +632,7 @@ void FString::StripLeft () if (max == 0) return; for (i = 0; i < max; ++i) { - if (!isspace(Chars[i])) + if (!isspace((unsigned char)Chars[i])) break; } if (i == 0) @@ -697,7 +697,7 @@ void FString::StripRight () if (max == 0) return; for (i = --max; i-- > 0; ) { - if (!isspace(Chars[i])) + if (!isspace((unsigned char)Chars[i])) break; } if (i == max) @@ -756,12 +756,12 @@ void FString::StripLeftRight () if (max == 0) return; for (i = 0; i < max; ++i) { - if (!isspace(Chars[i])) + if (!isspace((unsigned char)Chars[i])) break; } for (j = max - 1; j >= i; --j) { - if (!isspace(Chars[j])) + if (!isspace((unsigned char)Chars[j])) break; } if (i == 0 && j == max - 1) @@ -1040,7 +1040,7 @@ octdigits = [0-7]; yych = *YYCURSOR; // Skip preceding whitespace - while (yych != '\0' && isspace(yych)) { yych = *++YYCURSOR; } + while (yych != '\0' && isspace((unsigned char)yych)) { yych = *++YYCURSOR; } // Check for sign if (yych == '+' || yych == '-') { yych = *++YYCURSOR; } @@ -1078,7 +1078,7 @@ octdigits = [0-7]; } // The rest should all be whitespace - while (yych != '\0' && isspace(yych)) { yych = *++YYCURSOR; } + while (yych != '\0' && isspace((unsigned char)yych)) { yych = *++YYCURSOR; } return yych == '\0'; } @@ -1098,7 +1098,7 @@ digits = [0-9]; yych = *YYCURSOR; // Skip preceding whitespace - while (yych != '\0' && isspace(yych)) { yych = *++YYCURSOR; } + while (yych != '\0' && isspace((unsigned char)yych)) { yych = *++YYCURSOR; } // Check for sign if (yych == '+' || yych == '-') { yych = *++YYCURSOR; } @@ -1129,7 +1129,7 @@ digits = [0-9]; } // The rest should all be whitespace - while (yych != '\0' && isspace(yych)) { yych = *++YYCURSOR; } + while (yych != '\0' && isspace((unsigned char)yych)) { yych = *++YYCURSOR; } return yych == '\0'; }