]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
fixed unmber parsing
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 9 May 2014 01:57:31 +0000 (21:57 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 9 May 2014 01:57:31 +0000 (21:57 -0400)
source/slvm/kernel/parser.c

index b69c70774973033f47847baeb750bfa87193deda..a9143672b299462d592a3c49e4111ca58137e61b 100644 (file)
@@ -249,24 +249,20 @@ long strtol(char* p_str, char** p_p_end)
     int sign = 1;
     int base = 10;
     long value = 0;
+    bool consumed = false;
 
     /* Skip any leading whitespace */
-    do {
-        ch = *(p_str);
-        p_str++;
-    } while (is_ws(ch));
+    do { ch = *p_str++; } while (is_ws(ch));
 
     /* Detect leading sign */
     if (ch == '-')
     {
         sign = -1;
-        ch = *p_str;
-        p_str++;
+        ch = *p_str++;
     }
     else if (ch == '+')
     {
-        ch = *p_str;
-        p_str++;
+        ch = *p_str++;
     }
 
     /* Detect the base of the number being parsed */
@@ -300,8 +296,9 @@ long strtol(char* p_str, char** p_p_end)
         /* Shift the value be the base and add in the digit */
         value *= base;
         value += ch;
+        consumed = true;
     }
 
-    *p_p_end = p_str-1;
+    *p_p_end = (consumed) ? p_str-1 : p_str;
     return sign * value;
 }