ecere/com/instance: Fixed _strto(u)i64() - *endPtr wasn't always set
authorJerome St-Louis <jerome@ecere.com>
Sun, 24 Apr 2016 02:51:06 +0000 (22:51 -0400)
committerJerome St-Louis <jerome@ecere.com>
Fri, 29 Apr 2016 16:27:17 +0000 (12:27 -0400)
- This was causing issues parsing TextAlignment enumeration types from JSON

ecere/src/com/instance.ec

index 3e38499..6e9ad66 100644 (file)
@@ -3289,25 +3289,20 @@ public int64 _strtoi64(const char * string, const char ** endString, int base)
       else if(ch >= 'A' && ch <= 'Z')
          ch -= ('A'- 10);
       else
-      {
-         if(endString)
-            *endString = string + c;
          // Invalid character
          break;
-      }
       if(ch < base)
       {
          value *= base;
          value += ch;
       }
       else
-      {
-         if(endString)
-            *endString = string + c;
          // Invalid character
          break;
-      }
    }
+   if(endString)
+      *endString = string + c;
+
    return sign*value;
 }
 
@@ -3344,25 +3339,19 @@ public uint64 _strtoui64(const char * string, const char ** endString, int base)
       else if(ch >= 'A' && ch <= 'Z')
          ch -= ('A' - 10);
       else
-      {
-         if(endString)
-            *endString = string + c;
          // Invalid character
          break;
-      }
       if(ch < base)
       {
          value *= base;
          value += ch;
       }
       else
-      {
-         if(endString)
-            *endString = string + c;
          // Invalid character
          break;
-      }
    }
+   if(endString)
+      *endString = string + c;
    return sign*value;
 }