Skip to content

Commit

Permalink
antoi: accept numbers starting with "+"
Browse files Browse the repository at this point in the history
  • Loading branch information
wsourdeau committed Oct 2, 2014
1 parent bdbeffb commit 9175d4d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils/string_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,13 @@ antoi(const char * start, const char * end, int base)
else {
throw ML::Exception("Cannot negate non base 10");
}
start++;
}
else if (*start == '+') {
start++;
}

for (const char * ptr = start + neg; ptr < end; ptr++) {
for (const char * ptr = start; ptr < end; ptr++) {
int digit;
if (*ptr >= '0' and *ptr <= '9') {
digit = *ptr - '0';
Expand All @@ -195,7 +199,8 @@ antoi(const char * start, const char * end, int base)

if (neg) {
return result * -1;
}
}

return result;
}

Expand Down

0 comments on commit 9175d4d

Please sign in to comment.