Force chars to unsigned chars in SDL_string.c, so platforms that expect SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Thu, 15 Feb 2007 11:06:22 +0000
branchSDL-1.2
changeset 391616f7767f9580
parent 3915 89b0f3d12fe2
child 3917 8a3a0f1179f3
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.
src/stdlib/SDL_string.c
     1.1 --- a/src/stdlib/SDL_string.c	Wed Feb 14 10:40:24 2007 +0000
     1.2 +++ b/src/stdlib/SDL_string.c	Thu Feb 15 11:06:22 2007 +0000
     1.3 @@ -45,7 +45,7 @@
     1.4      }
     1.5      for ( ; ; ) {
     1.6          int v;
     1.7 -        if ( SDL_isdigit(*text) ) {
     1.8 +        if ( SDL_isdigit((unsigned char) *text) ) {
     1.9              v = *text - '0';
    1.10          } else if ( radix == 16 && SDL_isupperhex(*text) ) {
    1.11              v = 10 + (*text - 'A');
    1.12 @@ -80,7 +80,7 @@
    1.13      }
    1.14      for ( ; ; ) {
    1.15          int v;
    1.16 -        if ( SDL_isdigit(*text) ) {
    1.17 +        if ( SDL_isdigit((unsigned char) *text) ) {
    1.18              v = *text - '0';
    1.19          } else if ( radix == 16 && SDL_isupperhex(*text) ) {
    1.20              v = 10 + (*text - 'A');
    1.21 @@ -111,7 +111,7 @@
    1.22      }
    1.23      for ( ; ; ) {
    1.24          int v;
    1.25 -        if ( SDL_isdigit(*text) ) {
    1.26 +        if ( SDL_isdigit((unsigned char) *text) ) {
    1.27              v = *text - '0';
    1.28          } else if ( radix == 16 && SDL_isupperhex(*text) ) {
    1.29              v = 10 + (*text - 'A');
    1.30 @@ -148,7 +148,7 @@
    1.31      }
    1.32      for ( ; ; ) {
    1.33          int v;
    1.34 -        if ( SDL_isdigit(*text) ) {
    1.35 +        if ( SDL_isdigit((unsigned char) *text) ) {
    1.36              v = *text - '0';
    1.37          } else if ( radix == 16 && SDL_isupperhex(*text) ) {
    1.38              v = 10 + (*text - 'A');
    1.39 @@ -183,7 +183,7 @@
    1.40      }
    1.41      for ( ; ; ) {
    1.42          int v;
    1.43 -        if ( SDL_isdigit(*text) ) {
    1.44 +        if ( SDL_isdigit((unsigned char) *text) ) {
    1.45              v = *text - '0';
    1.46          } else if ( radix == 16 && SDL_isupperhex(*text) ) {
    1.47              v = 10 + (*text - 'A');
    1.48 @@ -221,7 +221,7 @@
    1.49      if ( *text == '.' ) {
    1.50          int mult = 10;
    1.51          ++text;
    1.52 -        while ( SDL_isdigit(*text) ) {
    1.53 +        while ( SDL_isdigit((unsigned char) *text) ) {
    1.54              lvalue = *text - '0';
    1.55              value += (double)lvalue / mult;
    1.56              mult *= 10;
    1.57 @@ -383,7 +383,7 @@
    1.58  {
    1.59      char *bufp = string;
    1.60      while ( *bufp ) {
    1.61 -        *bufp = SDL_toupper(*bufp);
    1.62 +        *bufp = SDL_toupper((unsigned char) *bufp);
    1.63  	++bufp;
    1.64      }
    1.65      return string;
    1.66 @@ -395,7 +395,7 @@
    1.67  {
    1.68      char *bufp = string;
    1.69      while ( *bufp ) {
    1.70 -        *bufp = SDL_tolower(*bufp);
    1.71 +        *bufp = SDL_tolower((unsigned char) *bufp);
    1.72  	++bufp;
    1.73      }
    1.74      return string;
    1.75 @@ -699,8 +699,8 @@
    1.76      char a = 0;
    1.77      char b = 0;
    1.78      while ( *str1 && *str2 ) {
    1.79 -        a = SDL_tolower(*str1);
    1.80 -        b = SDL_tolower(*str2);
    1.81 +        a = SDL_tolower((unsigned char) *str1);
    1.82 +        b = SDL_tolower((unsigned char) *str2);
    1.83          if ( a != b )
    1.84              break;
    1.85          ++str1;
    1.86 @@ -716,8 +716,8 @@
    1.87      char a = 0;
    1.88      char b = 0;
    1.89      while ( *str1 && *str2 && maxlen ) {
    1.90 -        a = SDL_tolower(*str1);
    1.91 -        b = SDL_tolower(*str2);
    1.92 +        a = SDL_tolower((unsigned char) *str1);
    1.93 +        b = SDL_tolower((unsigned char) *str2);
    1.94          if ( a != b )
    1.95              break;
    1.96          ++str1;
    1.97 @@ -737,7 +737,7 @@
    1.98      va_start(ap, fmt);
    1.99      while ( *fmt ) {
   1.100          if ( *fmt == ' ' ) {
   1.101 -            while ( SDL_isspace(*text) ) {
   1.102 +            while ( SDL_isspace((unsigned char) *text) ) {
   1.103                  ++text;
   1.104              }
   1.105              ++fmt;
   1.106 @@ -788,7 +788,7 @@
   1.107                  continue;
   1.108              }
   1.109  
   1.110 -            while ( SDL_isspace(*text) ) {
   1.111 +            while ( SDL_isspace((unsigned char) *text) ) {
   1.112                  ++text;
   1.113              }
   1.114  
   1.115 @@ -821,7 +821,7 @@
   1.116                                  ++index;
   1.117                              }
   1.118                              if ( text[index] == '0' ) {
   1.119 -                                if ( SDL_tolower(text[index+1]) == 'x' ) {
   1.120 +                                if ( SDL_tolower((unsigned char) text[index+1]) == 'x' ) {
   1.121                                      radix = 16;
   1.122                                  } else {
   1.123                                      radix = 8;
   1.124 @@ -950,7 +950,7 @@
   1.125                          break;
   1.126                      case 's':
   1.127                          if ( suppress ) {
   1.128 -                            while ( !SDL_isspace(*text) ) {
   1.129 +                            while ( !SDL_isspace((unsigned char) *text) ) {
   1.130                                  ++text;
   1.131                                  if ( count ) {
   1.132                                      if ( --count == 0 ) {
   1.133 @@ -960,7 +960,7 @@
   1.134                              }
   1.135                          } else {
   1.136                              char *valuep = va_arg(ap, char*);
   1.137 -                            while ( !SDL_isspace(*text) ) {
   1.138 +                            while ( !SDL_isspace((unsigned char) *text) ) {
   1.139                                  *valuep++ = *text++;
   1.140                                  if ( count ) {
   1.141                                      if ( --count == 0 ) {