src/stdlib/SDL_string.c
branchSDL-1.3
changeset 1659 14717b52abc0
parent 1512 845b1619c8f6
child 1662 782fd950bd46
child 1867 887c3600826b
     1.1 --- a/src/stdlib/SDL_string.c	Mon May 01 06:58:33 2006 +0000
     1.2 +++ b/src/stdlib/SDL_string.c	Wed May 17 08:18:28 2006 +0000
     1.3 @@ -985,10 +985,10 @@
     1.4  
     1.5      SDL_ltoa(value, num, radix);
     1.6      size = SDL_strlen(num);
     1.7 -    if ( size > maxlen ) {
     1.8 -        size = maxlen;
     1.9 +    if ( size >= maxlen ) {
    1.10 +        size = maxlen-1;
    1.11      }
    1.12 -    SDL_strlcpy(text, num, size);
    1.13 +    SDL_strlcpy(text, num, size+1);
    1.14  
    1.15      return size;
    1.16  }
    1.17 @@ -999,10 +999,10 @@
    1.18  
    1.19      SDL_ultoa(value, num, radix);
    1.20      size = SDL_strlen(num);
    1.21 -    if ( size > maxlen ) {
    1.22 -        size = maxlen;
    1.23 +    if ( size >= maxlen ) {
    1.24 +        size = maxlen-1;
    1.25      }
    1.26 -    SDL_strlcpy(text, num, size);
    1.27 +    SDL_strlcpy(text, num, size+1);
    1.28  
    1.29      return size;
    1.30  }
    1.31 @@ -1014,10 +1014,10 @@
    1.32  
    1.33      SDL_lltoa(value, num, radix);
    1.34      size = SDL_strlen(num);
    1.35 -    if ( size > maxlen ) {
    1.36 -        size = maxlen;
    1.37 +    if ( size >= maxlen ) {
    1.38 +        size = maxlen-1;
    1.39      }
    1.40 -    SDL_strlcpy(text, num, size);
    1.41 +    SDL_strlcpy(text, num, size+1);
    1.42  
    1.43      return size;
    1.44  }
    1.45 @@ -1028,10 +1028,10 @@
    1.46  
    1.47      SDL_ulltoa(value, num, radix);
    1.48      size = SDL_strlen(num);
    1.49 -    if ( size > maxlen ) {
    1.50 -        size = maxlen;
    1.51 +    if ( size >= maxlen ) {
    1.52 +        size = maxlen-1;
    1.53      }
    1.54 -    SDL_strlcpy(text, num, size);
    1.55 +    SDL_strlcpy(text, num, size+1);
    1.56  
    1.57      return size;
    1.58  }
    1.59 @@ -1101,6 +1101,9 @@
    1.60  
    1.61              ++fmt;
    1.62              /* FIXME: implement more of the format specifiers */
    1.63 +            while ( *fmt == '.' || (*fmt >= '0' && *fmt <= '9') ) {
    1.64 +                ++fmt;
    1.65 +            }
    1.66              while (!done) {
    1.67                  switch(*fmt) {
    1.68                      case '%':