Commit cb20c837 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Force chars to unsigned chars in SDL_string.c, so platforms that expect

 these to not be negative, when not EOF, work.

   Fixes Bugzilla #338.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402271
parent 0855a63e
...@@ -45,7 +45,7 @@ static size_t SDL_ScanLong(const char *text, int radix, long *valuep) ...@@ -45,7 +45,7 @@ static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
} }
for ( ; ; ) { for ( ; ; ) {
int v; int v;
if ( SDL_isdigit(*text) ) { if ( SDL_isdigit((unsigned char) *text) ) {
v = *text - '0'; v = *text - '0';
} else if ( radix == 16 && SDL_isupperhex(*text) ) { } else if ( radix == 16 && SDL_isupperhex(*text) ) {
v = 10 + (*text - 'A'); v = 10 + (*text - 'A');
...@@ -80,7 +80,7 @@ static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *v ...@@ -80,7 +80,7 @@ static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *v
} }
for ( ; ; ) { for ( ; ; ) {
int v; int v;
if ( SDL_isdigit(*text) ) { if ( SDL_isdigit((unsigned char) *text) ) {
v = *text - '0'; v = *text - '0';
} else if ( radix == 16 && SDL_isupperhex(*text) ) { } else if ( radix == 16 && SDL_isupperhex(*text) ) {
v = 10 + (*text - 'A'); v = 10 + (*text - 'A');
...@@ -111,7 +111,7 @@ static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep) ...@@ -111,7 +111,7 @@ static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
} }
for ( ; ; ) { for ( ; ; ) {
int v; int v;
if ( SDL_isdigit(*text) ) { if ( SDL_isdigit((unsigned char) *text) ) {
v = *text - '0'; v = *text - '0';
} else if ( radix == 16 && SDL_isupperhex(*text) ) { } else if ( radix == 16 && SDL_isupperhex(*text) ) {
v = 10 + (*text - 'A'); v = 10 + (*text - 'A');
...@@ -148,7 +148,7 @@ static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep) ...@@ -148,7 +148,7 @@ static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
} }
for ( ; ; ) { for ( ; ; ) {
int v; int v;
if ( SDL_isdigit(*text) ) { if ( SDL_isdigit((unsigned char) *text) ) {
v = *text - '0'; v = *text - '0';
} else if ( radix == 16 && SDL_isupperhex(*text) ) { } else if ( radix == 16 && SDL_isupperhex(*text) ) {
v = 10 + (*text - 'A'); v = 10 + (*text - 'A');
...@@ -183,7 +183,7 @@ static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valu ...@@ -183,7 +183,7 @@ static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valu
} }
for ( ; ; ) { for ( ; ; ) {
int v; int v;
if ( SDL_isdigit(*text) ) { if ( SDL_isdigit((unsigned char) *text) ) {
v = *text - '0'; v = *text - '0';
} else if ( radix == 16 && SDL_isupperhex(*text) ) { } else if ( radix == 16 && SDL_isupperhex(*text) ) {
v = 10 + (*text - 'A'); v = 10 + (*text - 'A');
...@@ -221,7 +221,7 @@ static size_t SDL_ScanFloat(const char *text, double *valuep) ...@@ -221,7 +221,7 @@ static size_t SDL_ScanFloat(const char *text, double *valuep)
if ( *text == '.' ) { if ( *text == '.' ) {
int mult = 10; int mult = 10;
++text; ++text;
while ( SDL_isdigit(*text) ) { while ( SDL_isdigit((unsigned char) *text) ) {
lvalue = *text - '0'; lvalue = *text - '0';
value += (double)lvalue / mult; value += (double)lvalue / mult;
mult *= 10; mult *= 10;
...@@ -383,7 +383,7 @@ char *SDL_strupr(char *string) ...@@ -383,7 +383,7 @@ char *SDL_strupr(char *string)
{ {
char *bufp = string; char *bufp = string;
while ( *bufp ) { while ( *bufp ) {
*bufp = SDL_toupper(*bufp); *bufp = SDL_toupper((unsigned char) *bufp);
++bufp; ++bufp;
} }
return string; return string;
...@@ -395,7 +395,7 @@ char *SDL_strlwr(char *string) ...@@ -395,7 +395,7 @@ char *SDL_strlwr(char *string)
{ {
char *bufp = string; char *bufp = string;
while ( *bufp ) { while ( *bufp ) {
*bufp = SDL_tolower(*bufp); *bufp = SDL_tolower((unsigned char) *bufp);
++bufp; ++bufp;
} }
return string; return string;
...@@ -699,8 +699,8 @@ int SDL_strcasecmp(const char *str1, const char *str2) ...@@ -699,8 +699,8 @@ int SDL_strcasecmp(const char *str1, const char *str2)
char a = 0; char a = 0;
char b = 0; char b = 0;
while ( *str1 && *str2 ) { while ( *str1 && *str2 ) {
a = SDL_tolower(*str1); a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower(*str2); b = SDL_tolower((unsigned char) *str2);
if ( a != b ) if ( a != b )
break; break;
++str1; ++str1;
...@@ -716,8 +716,8 @@ int SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) ...@@ -716,8 +716,8 @@ int SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
char a = 0; char a = 0;
char b = 0; char b = 0;
while ( *str1 && *str2 && maxlen ) { while ( *str1 && *str2 && maxlen ) {
a = SDL_tolower(*str1); a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower(*str2); b = SDL_tolower((unsigned char) *str2);
if ( a != b ) if ( a != b )
break; break;
++str1; ++str1;
...@@ -737,7 +737,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) ...@@ -737,7 +737,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
while ( *fmt ) { while ( *fmt ) {
if ( *fmt == ' ' ) { if ( *fmt == ' ' ) {
while ( SDL_isspace(*text) ) { while ( SDL_isspace((unsigned char) *text) ) {
++text; ++text;
} }
++fmt; ++fmt;
...@@ -788,7 +788,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) ...@@ -788,7 +788,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...)
continue; continue;
} }
while ( SDL_isspace(*text) ) { while ( SDL_isspace((unsigned char) *text) ) {
++text; ++text;
} }
...@@ -821,7 +821,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) ...@@ -821,7 +821,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...)
++index; ++index;
} }
if ( text[index] == '0' ) { if ( text[index] == '0' ) {
if ( SDL_tolower(text[index+1]) == 'x' ) { if ( SDL_tolower((unsigned char) text[index+1]) == 'x' ) {
radix = 16; radix = 16;
} else { } else {
radix = 8; radix = 8;
...@@ -950,7 +950,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) ...@@ -950,7 +950,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...)
break; break;
case 's': case 's':
if ( suppress ) { if ( suppress ) {
while ( !SDL_isspace(*text) ) { while ( !SDL_isspace((unsigned char) *text) ) {
++text; ++text;
if ( count ) { if ( count ) {
if ( --count == 0 ) { if ( --count == 0 ) {
...@@ -960,7 +960,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...) ...@@ -960,7 +960,7 @@ int SDL_sscanf(const char *text, const char *fmt, ...)
} }
} else { } else {
char *valuep = va_arg(ap, char*); char *valuep = va_arg(ap, char*);
while ( !SDL_isspace(*text) ) { while ( !SDL_isspace((unsigned char) *text) ) {
*valuep++ = *text++; *valuep++ = *text++;
if ( count ) { if ( count ) {
if ( --count == 0 ) { if ( --count == 0 ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment