From 496e7515a9419652b8a012c8aed665f4ee1d5c36 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Thu, 22 Jul 2010 22:28:33 -0500 Subject: [PATCH] Bug 581067 - U+FEFF should be a WhiteSpace character (change in ES5 from ES3). r=cdleary --HG-- extra : rebase_source : 38947caa8d4f21d0867137d0933495061a88d052 --- js/src/jsstr.h | 7 +++++-- js/src/tests/ecma/GlobalObject/15.1.2.2-1.js | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/js/src/jsstr.h b/js/src/jsstr.h index 254b98dda92..8981341cd95 100644 --- a/js/src/jsstr.h +++ b/js/src/jsstr.h @@ -752,15 +752,18 @@ extern const bool js_alnum[]; #define JS_ISDIGIT(c) (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER) +const jschar BYTE_ORDER_MARK = 0xFEFF; +const jschar NO_BREAK_SPACE = 0x00A0; + static inline bool JS_ISSPACE(jschar c) { unsigned w = c; if (w < 256) - return (w <= ' ' && (w == ' ' || (9 <= w && w <= 0xD))) || w == 0xA0; + return (w <= ' ' && (w == ' ' || (9 <= w && w <= 0xD))) || w == NO_BREAK_SPACE; - return (JS_CCODE(w) & 0x00070000) == 0x00040000; + return w == BYTE_ORDER_MARK || (JS_CCODE(w) & 0x00070000) == 0x00040000; } #define JS_ISPRINT(c) ((c) < 128 && isprint(c)) diff --git a/js/src/tests/ecma/GlobalObject/15.1.2.2-1.js b/js/src/tests/ecma/GlobalObject/15.1.2.2-1.js index e7cfdf14a7c..daf013ca251 100644 --- a/js/src/tests/ecma/GlobalObject/15.1.2.2-1.js +++ b/js/src/tests/ecma/GlobalObject/15.1.2.2-1.js @@ -218,6 +218,8 @@ for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; HEX_VALUE += Math.pow(16,POWER)*15; } +new TestCase(SECTION, "parseInt(BOM + '123', 10)", 123, parseInt("\uFEFF" + "123", 10)); + // a few tests with negative numbers for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) );