Bug 273467 - -"-0x1" results in 1 instead of NaN. r=brendan.
authorSaint Wesonga <wesongathedeveloper@yahoo.com>
Fri, 14 Aug 2009 15:03:10 -0500
changeset 31827 a2ab5097c5e504ad4cebf2f0826d0d925adcabdb
parent 31826 ae4a9225ddcf6bc3a94519751f19982f7592c99d
child 31828 c3648b2ea86cac3ddb898aecf4f85da4849580f7
push id8746
push userrsayre@mozilla.com
push dateTue, 25 Aug 2009 16:53:43 +0000
treeherdermozilla-central@189759c41621 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrendan
bugs273467
milestone1.9.2a2pre
Bug 273467 - -"-0x1" results in 1 instead of NaN. r=brendan.
js/src/jsnum.cpp
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -922,16 +922,24 @@ js_ValueToNumber(JSContext *cx, jsval *v
             /*
              * Note that ECMA doesn't treat a string beginning with a '0' as
              * an octal number here. This works because all such numbers will
              * be interpreted as decimal by js_strtod and will never get
              * passed to js_strtointeger (which would interpret them as
              * octal).
              */
             str->getCharsAndEnd(bp, end);
+
+            /* ECMA doesn't allow signed hex numbers (bug 273467). */
+            bp = js_SkipWhiteSpace(bp, end);
+            if (bp + 2 < end && (*bp == '-' || *bp == '+') &&
+                bp[1] == '0' && (bp[2] == 'X' || bp[2] == 'x')) {
+                break;
+            }
+
             if ((!js_strtod(cx, bp, end, &ep, &d) ||
                  js_SkipWhiteSpace(ep, end) != end) &&
                 (!js_strtointeger(cx, bp, end, &ep, 0, &d) ||
                  js_SkipWhiteSpace(ep, end) != end)) {
                 break;
             }
 
             /*