[Commits] SDL: More fixes for the SDL_scanf code

libsdl.org revision control commits-owner at libsdl.org
Sat Aug 12 00:01:27 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/6c3895d3599f
changeset: 11235:6c3895d3599f
user:      Sam Lantinga <slouken at libsdl.org>
date:      Sat Aug 12 00:01:24 2017 -0700
description:
More fixes for the SDL_scanf code

diffstat:

 src/stdlib/SDL_string.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (60 lines):

diff -r b5cf1e85ffd5 -r 6c3895d3599f src/stdlib/SDL_string.c
--- a/src/stdlib/SDL_string.c	Fri Aug 11 23:54:06 2017 -0700
+++ b/src/stdlib/SDL_string.c	Sat Aug 12 00:01:24 2017 -0700
@@ -803,7 +803,7 @@
     return strtol(string, endp, base);
 #else
     size_t len;
-    long value;
+    long value = 0;
 
     if (!base) {
         if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
@@ -828,7 +828,7 @@
     return strtoul(string, endp, base);
 #else
     size_t len;
-    unsigned long value;
+    unsigned long value = 0;
 
     if (!base) {
         if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
@@ -853,7 +853,7 @@
     return strtoll(string, endp, base);
 #else
     size_t len;
-    Sint64 value;
+    Sint64 value = 0;
 
     if (!base) {
         if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
@@ -878,7 +878,7 @@
     return strtoull(string, endp, base);
 #else
     size_t len;
-    Uint64 value;
+    Uint64 value = 0;
 
     if (!base) {
         if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
@@ -903,7 +903,7 @@
     return strtod(string, endp);
 #else
     size_t len;
-    double value;
+    double value = 0.0;
 
     len = SDL_ScanFloat(string, &value);
     if (endp) {
@@ -1128,8 +1128,9 @@
                 case 'd':
                     if (inttype == DO_LONGLONG) {
                         Sint64 value;
-                        text += SDL_ScanLongLong(text, radix, &value);
-                        if (!suppress) {
+                        advance = SDL_ScanLongLong(text, radix, &value);
+                        text += advance;
+                        if (advance && !suppress) {
                             Sint64 *valuep = va_arg(ap, Sint64 *);
                             *valuep = value;
                             ++retval;


More information about the commits mailing list