Skip to content

Commit

Permalink
Fixes Issue 11222 - isNumeric should return false on -/+ as a single …
Browse files Browse the repository at this point in the history
…character.
  • Loading branch information
AndrejMitrovic committed Oct 11, 2013
1 parent d744bec commit ac04f8b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -3167,7 +3167,12 @@ bool isNumeric(const(char)[] s, in bool bAllowSep = false) @safe pure

// A sign is allowed only in the 1st character
if (sx[0] == '-' || sx[0] == '+')
{
if (iLen == 1) // but must be followed by other characters
return false;

j++;
}

for (int i = j; i < iLen; i++)
{
Expand Down Expand Up @@ -3331,6 +3336,9 @@ unittest
assert(isNumeric(s) == false);
assert(isNumeric(s[0..s.length - 1]) == false);
});

assert(!isNumeric("-"));
assert(!isNumeric("+"));
}


Expand Down

0 comments on commit ac04f8b

Please sign in to comment.