More fixes for the SDL_scanf code
authorSam Lantinga
Sat, 12 Aug 2017 00:01:24 -0700
changeset 112356c3895d3599f
parent 11234 b5cf1e85ffd5
child 11236 8c3cba28b1fd
More fixes for the SDL_scanf code
src/stdlib/SDL_string.c
     1.1 --- a/src/stdlib/SDL_string.c	Fri Aug 11 23:54:06 2017 -0700
     1.2 +++ b/src/stdlib/SDL_string.c	Sat Aug 12 00:01:24 2017 -0700
     1.3 @@ -803,7 +803,7 @@
     1.4      return strtol(string, endp, base);
     1.5  #else
     1.6      size_t len;
     1.7 -    long value;
     1.8 +    long value = 0;
     1.9  
    1.10      if (!base) {
    1.11          if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
    1.12 @@ -828,7 +828,7 @@
    1.13      return strtoul(string, endp, base);
    1.14  #else
    1.15      size_t len;
    1.16 -    unsigned long value;
    1.17 +    unsigned long value = 0;
    1.18  
    1.19      if (!base) {
    1.20          if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
    1.21 @@ -853,7 +853,7 @@
    1.22      return strtoll(string, endp, base);
    1.23  #else
    1.24      size_t len;
    1.25 -    Sint64 value;
    1.26 +    Sint64 value = 0;
    1.27  
    1.28      if (!base) {
    1.29          if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
    1.30 @@ -878,7 +878,7 @@
    1.31      return strtoull(string, endp, base);
    1.32  #else
    1.33      size_t len;
    1.34 -    Uint64 value;
    1.35 +    Uint64 value = 0;
    1.36  
    1.37      if (!base) {
    1.38          if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
    1.39 @@ -903,7 +903,7 @@
    1.40      return strtod(string, endp);
    1.41  #else
    1.42      size_t len;
    1.43 -    double value;
    1.44 +    double value = 0.0;
    1.45  
    1.46      len = SDL_ScanFloat(string, &value);
    1.47      if (endp) {
    1.48 @@ -1128,8 +1128,9 @@
    1.49                  case 'd':
    1.50                      if (inttype == DO_LONGLONG) {
    1.51                          Sint64 value;
    1.52 -                        text += SDL_ScanLongLong(text, radix, &value);
    1.53 -                        if (!suppress) {
    1.54 +                        advance = SDL_ScanLongLong(text, radix, &value);
    1.55 +                        text += advance;
    1.56 +                        if (advance && !suppress) {
    1.57                              Sint64 *valuep = va_arg(ap, Sint64 *);
    1.58                              *valuep = value;
    1.59                              ++retval;