Mon, 16 Jul 2012 04:26:27 +0300
Negative numbers are now considered numbers too...
scriptreader.cxx | file | annotate | diff | comparison | revisions | |
str.cxx | file | annotate | diff | comparison | revisions |
--- a/scriptreader.cxx Mon Jul 16 04:15:49 2012 +0300 +++ b/scriptreader.cxx Mon Jul 16 04:26:27 2012 +0300 @@ -273,9 +273,19 @@ } void ScriptReader::MustNumber () { + str num; MustNext (); - if (!token.isnumber()) - ParserError ("expected a number, got `%s`", token.chars()); + num += token; + + // Cater for a possible minus sign, since it + // breaks the token, read a new one with the number. + if (!token.compare ("-")) { + MustNext (); + num += token; + } + + if (!num.isnumber()) + ParserError ("expected a number, got `%s`", num.chars()); } void ScriptReader::MustBool () {
--- a/str.cxx Mon Jul 16 04:15:49 2012 +0300 +++ b/str.cxx Mon Jul 16 04:26:27 2012 +0300 @@ -309,9 +309,16 @@ // ============================================================================ bool str::isnumber () { - ITERATE_STRING (u) + ITERATE_STRING (u) { + // Minus sign as the first character is allowed for negatives + if (!u && text[u] == '-') { + printf ("%u was minus sign\n", u); + continue; + } + if (text[u] < '0' || text[u] > '9') return false; + } return true; }