Commit 84bf9436 authored by lrn@chromium.org's avatar lrn@chromium.org

Fix number parsing to not allow space between sign and digits.

Affects both parseFloat and ToNumber conversion.

Fix issue 946.

Review URL: http://codereview.chromium.org/5338005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5894 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7be18f70
......@@ -448,12 +448,12 @@ static double InternalStringToDouble(Iterator current,
bool sign = false;
if (*current == '+') {
// Ignore leading sign; skip following spaces.
// Ignore leading sign.
++current;
if (!AdvanceToNonspace(&current, end)) return JUNK_STRING_VALUE;
if (current == end) return JUNK_STRING_VALUE;
} else if (*current == '-') {
++current;
if (!AdvanceToNonspace(&current, end)) return JUNK_STRING_VALUE;
if (current == end) return JUNK_STRING_VALUE;
sign = true;
}
......
......@@ -104,8 +104,10 @@ TEST(IntegerStrLiteral) {
CHECK_EQ(0.0, StringToDouble("000", NO_FLAGS));
CHECK_EQ(1.0, StringToDouble("1", NO_FLAGS));
CHECK_EQ(-1.0, StringToDouble("-1", NO_FLAGS));
CHECK_EQ(-1.0, StringToDouble(" - 1 ", NO_FLAGS));
CHECK_EQ(1.0, StringToDouble(" + 1 ", NO_FLAGS));
CHECK_EQ(-1.0, StringToDouble(" -1 ", NO_FLAGS));
CHECK_EQ(1.0, StringToDouble(" +1 ", NO_FLAGS));
CHECK(isnan(StringToDouble(" - 1 ", NO_FLAGS)));
CHECK(isnan(StringToDouble(" + 1 ", NO_FLAGS)));
CHECK_EQ(0.0, StringToDouble("0e0", ALLOW_HEX | ALLOW_OCTALS));
CHECK_EQ(0.0, StringToDouble("0e1", ALLOW_HEX | ALLOW_OCTALS));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment