Changeset 199523 in webkit
- Timestamp:
- Apr 13, 2016 5:47:40 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199521 r199523 1 2016-04-13 Michael Saboff <msaboff@apple.com> 2 3 Some tests fail with ES6 `u` (Unicode) flag for regular expressions 4 https://bugs.webkit.org/show_bug.cgi?id=151597 5 6 Reviewed by Geoffrey Garen. 7 8 Updated tests. 9 10 * js/regexp-unicode-expected.txt: 11 * js/script-tests/regexp-unicode.js: 12 1 13 2016-04-13 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/js/regexp-unicode-expected.txt
r198866 r199523 40 40 PASS "a𐄣X".match(/a𐄣b|a𐄣x/iu)[0].length is 4 41 41 PASS "Ťx".match(/ťx/iu)[0].length is 2 42 PASS /\w/iu.test("ſ") is true 43 PASS /\w/iu.test("K") is true 44 PASS /!\w/iu.test("ſ") is false 45 PASS /!\w/iu.test("K") is false 46 PASS /\W/iu.test("ſ") is true 47 PASS /\W/iu.test("K") is true 48 PASS /!\W/iu.test("ſ") is false 49 PASS /!\W/iu.test("K") is false 50 PASS /[\w\d]/iu.test("ſ") is true 51 PASS /[\w\d]/iu.test("K") is true 52 PASS /[^\w\d]/iu.test("ſ") is false 53 PASS /[^\w\d]/iu.test("K") is false 54 PASS /[\W\d]/iu.test("ſ") is true 55 PASS /[\W\d]/iu.test("K") is true 56 PASS /[^\W\d]/iu.test("ſ") is false 57 PASS /[^\W\d]/iu.test("K") is false 58 PASS /\w/iu.test("S") is true 59 PASS /\w/iu.test("K") is true 60 PASS /!\w/iu.test("S") is false 61 PASS /!\w/iu.test("K") is false 62 PASS /\W/iu.test("S") is true 63 PASS /\W/iu.test("K") is true 64 PASS /!\W/iu.test("S") is false 65 PASS /!\W/iu.test("K") is false 66 PASS /[\w\d]/iu.test("S") is true 67 PASS /[\w\d]/iu.test("K") is true 68 PASS /[^\w\d]/iu.test("S") is false 69 PASS /[^\w\d]/iu.test("K") is false 70 PASS /[\W\d]/iu.test("S") is true 71 PASS /[\W\d]/iu.test("K") is true 72 PASS /[^\W\d]/iu.test("S") is false 73 PASS /[^\W\d]/iu.test("K") is false 42 74 PASS "𝌆".match(/^.$/u)[0].length is 2 43 75 PASS "It is 78°".match(/.*/u)[0].length is 9 -
trunk/LayoutTests/js/script-tests/regexp-unicode.js
r198866 r199523 44 44 shouldBe('"a\u{10123}X".match(/a\u{10123}b|a\u{10123}x/iu)[0].length', '4'); 45 45 shouldBe('"\u0164x".match(/\u0165x/iu)[0].length', '2'); 46 shouldBeTrue('/\\w/iu.test("\u017f")'); 47 shouldBeTrue('/\\w/iu.test("\u212a")'); 48 shouldBeFalse('/!\\w/iu.test("\u017f")'); 49 shouldBeFalse('/!\\w/iu.test("\u212a")'); 50 shouldBeTrue('/\\W/iu.test("\u017f")'); 51 shouldBeTrue('/\\W/iu.test("\u212a")'); 52 shouldBeFalse('/!\\W/iu.test("\u017f")'); 53 shouldBeFalse('/!\\W/iu.test("\u212a")'); 54 shouldBeTrue('/[\\w\\d]/iu.test("\u017f")'); 55 shouldBeTrue('/[\\w\\d]/iu.test("\u212a")'); 56 shouldBeFalse('/[^\\w\\d]/iu.test("\u017f")'); 57 shouldBeFalse('/[^\\w\\d]/iu.test("\u212a")'); 58 shouldBeTrue('/[\\W\\d]/iu.test("\u017f")'); 59 shouldBeTrue('/[\\W\\d]/iu.test("\u212a")'); 60 shouldBeFalse('/[^\\W\\d]/iu.test("\u017f")'); 61 shouldBeFalse('/[^\\W\\d]/iu.test("\u212a")'); 62 shouldBeTrue('/\\w/iu.test("S")'); 63 shouldBeTrue('/\\w/iu.test("K")'); 64 shouldBeFalse('/!\\w/iu.test("S")'); 65 shouldBeFalse('/!\\w/iu.test("K")'); 66 shouldBeTrue('/\\W/iu.test("S")'); 67 shouldBeTrue('/\\W/iu.test("K")'); 68 shouldBeFalse('/!\\W/iu.test("S")'); 69 shouldBeFalse('/!\\W/iu.test("K")'); 70 shouldBeTrue('/[\\w\\d]/iu.test("S")'); 71 shouldBeTrue('/[\\w\\d]/iu.test("K")'); 72 shouldBeFalse('/[^\\w\\d]/iu.test("S")'); 73 shouldBeFalse('/[^\\w\\d]/iu.test("K")'); 74 shouldBeTrue('/[\\W\\d]/iu.test("S")'); 75 shouldBeTrue('/[\\W\\d]/iu.test("K")'); 76 shouldBeFalse('/[^\\W\\d]/iu.test("S")'); 77 shouldBeFalse('/[^\\W\\d]/iu.test("K")'); 78 46 79 47 80 // Test . matches with Unicode flag -
trunk/Source/JavaScriptCore/ChangeLog
r199514 r199523 1 2016-04-13 Michael Saboff <msaboff@apple.com> 2 3 Some tests fail with ES6 `u` (Unicode) flag for regular expressions 4 https://bugs.webkit.org/show_bug.cgi?id=151597 5 6 Reviewed by Geoffrey Garen. 7 8 Added two new tables to handle the anomolies of \w and \W CharacterClassEscapes 9 when specified in RegExp's with both the unicode and ignoreCase flags. Given the 10 case folding rules described in the standard vie the meta function Canonicalize(), 11 which allow cross ASCII case folding when unicode is specified, the unicode characters 12 \u017f (small sharp s) and \u212a (kelvin symbol) are part of the \w (word) characterClassEscape. 13 This is true because they case fold to 's' and 'k' respectively. Because they case fold 14 to lower case letters, the corresponding letters, 'k', 'K', 's' and 'S', are also matched with 15 \W with the unicode and ignoreCase flags. 16 17 * create_regex_tables: 18 * yarr/YarrPattern.cpp: 19 (JSC::Yarr::YarrPatternConstructor::atomBuiltInCharacterClass): 20 (JSC::Yarr::YarrPatternConstructor::atomCharacterClassBuiltIn): 21 (JSC::Yarr::YarrPattern::YarrPattern): 22 * yarr/YarrPattern.h: 23 (JSC::Yarr::YarrPattern::wordcharCharacterClass): 24 (JSC::Yarr::YarrPattern::wordUnicodeIgnoreCaseCharCharacterClass): 25 (JSC::Yarr::YarrPattern::nonwordcharCharacterClass): 26 (JSC::Yarr::YarrPattern::nonwordUnicodeIgnoreCaseCharCharacterClass): 27 1 28 2016-04-13 Commit Queue <commit-queue@webkit.org> 2 29 -
trunk/Source/JavaScriptCore/create_regex_tables
r194470 r199523 26 26 types = { 27 27 "wordchar": { "UseTable" : True, "data": ['_', ('0','9'), ('A', 'Z'), ('a','z')]}, 28 "nonwordchar": { "UseTable" : True, "Inverse": "wordchar", "data": ['`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0xffff)]}, 28 "wordUnicodeIgnoreCaseChar": { "UseTable" : False, "data": ['_', ('0', '9'), ('A', 'Z'), ('a', 'z'), 0x017f, 0x212a]}, 29 "nonwordchar": { "UseTable" : True, "Inverse": "wordchar", "data": ['`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0x10ffff)]}, 30 "nonwordUnicodeIgnoreCaseChar": { "UseTable" : False, "Inverse": "wordchar", "data": ['k', 'K', 's', 'S', '`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0x10ffff)]}, 29 31 "newline": { "UseTable" : False, "data": ['\n', '\r', 0x2028, 0x2029]}, 30 32 "spaces": { "UseTable" : True, "data": [' ', ('\t', '\r'), 0xa0, 0x1680, 0x180e, 0x2028, 0x2029, 0x202f, 0x205f, 0x3000, (0x2000, 0x200a), 0xfeff]}, 31 "nonspaces": { "UseTable" : True, "Inverse": "spaces", "data": [(0, ord('\t') - 1), (ord('\r') + 1, ord(' ') - 1), (ord(' ') + 1, 0x009f), (0x00a1, 0x167f), (0x1681, 0x180d), (0x180f, 0x1fff), (0x200b, 0x2027), (0x202a, 0x202e), (0x2030, 0x205e), (0x2060, 0x2fff), (0x3001, 0xfefe), (0xff00, 0x ffff)]},33 "nonspaces": { "UseTable" : True, "Inverse": "spaces", "data": [(0, ord('\t') - 1), (ord('\r') + 1, ord(' ') - 1), (ord(' ') + 1, 0x009f), (0x00a1, 0x167f), (0x1681, 0x180d), (0x180f, 0x1fff), (0x200b, 0x2027), (0x202a, 0x202e), (0x2030, 0x205e), (0x2060, 0x2fff), (0x3001, 0xfefe), (0xff00, 0x10ffff)]}, 32 34 "digits": { "UseTable" : False, "data": [('0', '9')]}, 33 "nondigits": { "UseTable" : False, "Inverse": "digits", "data": [(0, ord('0') - 1), (ord('9') + 1, 0x ffff)] }35 "nondigits": { "UseTable" : False, "Inverse": "digits", "data": [(0, ord('0') - 1), (ord('9') + 1, 0x10ffff)] } 34 36 } 35 37 entriesPerLine = 50 -
trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp
r197869 r199523 350 350 break; 351 351 case WordClassID: 352 m_alternative->m_terms.append(PatternTerm(m_pattern.wordcharCharacterClass(), invert)); 352 if (m_pattern.unicode() && m_pattern.ignoreCase()) { 353 if (invert) 354 m_alternative->m_terms.append(PatternTerm(m_pattern.nonwordUnicodeIgnoreCaseCharCharacterClass(), false)); 355 else 356 m_alternative->m_terms.append(PatternTerm(m_pattern.wordUnicodeIgnoreCaseCharCharacterClass(), false)); 357 } else 358 m_alternative->m_terms.append(PatternTerm(m_pattern.wordcharCharacterClass(), invert)); 353 359 break; 354 360 case NewlineClassID: … … 387 393 388 394 case WordClassID: 389 m_characterClassConstructor.append(invert ? m_pattern.nonwordcharCharacterClass() : m_pattern.wordcharCharacterClass()); 395 if (m_pattern.unicode() && m_pattern.ignoreCase()) 396 m_characterClassConstructor.append(invert ? m_pattern.nonwordUnicodeIgnoreCaseCharCharacterClass() : m_pattern.wordUnicodeIgnoreCaseCharCharacterClass()); 397 else 398 m_characterClassConstructor.append(invert ? m_pattern.nonwordcharCharacterClass() : m_pattern.wordcharCharacterClass()); 390 399 break; 391 400 … … 885 894 , spacesCached(0) 886 895 , wordcharCached(0) 896 , wordUnicodeIgnoreCaseCharCached(0) 887 897 , nondigitsCached(0) 888 898 , nonspacesCached(0) 889 899 , nonwordcharCached(0) 900 , nonwordUnicodeIgnoreCasecharCached(0) 890 901 { 891 902 *error = compile(pattern); -
trunk/Source/JavaScriptCore/yarr/YarrPattern.h
r197869 r199523 288 288 std::unique_ptr<CharacterClass> spacesCreate(); 289 289 std::unique_ptr<CharacterClass> wordcharCreate(); 290 std::unique_ptr<CharacterClass> wordUnicodeIgnoreCaseCharCreate(); 290 291 std::unique_ptr<CharacterClass> nondigitsCreate(); 291 292 std::unique_ptr<CharacterClass> nonspacesCreate(); 292 293 std::unique_ptr<CharacterClass> nonwordcharCreate(); 294 std::unique_ptr<CharacterClass> nonwordUnicodeIgnoreCaseCharCreate(); 293 295 294 296 struct TermChain { … … 318 320 spacesCached = 0; 319 321 wordcharCached = 0; 322 wordUnicodeIgnoreCaseCharCached = 0; 320 323 nondigitsCached = 0; 321 324 nonspacesCached = 0; 322 325 nonwordcharCached = 0; 326 nonwordUnicodeIgnoreCasecharCached = 0; 323 327 324 328 m_disjunctions.clear(); … … 368 372 return wordcharCached; 369 373 } 374 CharacterClass* wordUnicodeIgnoreCaseCharCharacterClass() 375 { 376 if (!wordUnicodeIgnoreCaseCharCached) { 377 m_userCharacterClasses.append(wordUnicodeIgnoreCaseCharCreate()); 378 wordUnicodeIgnoreCaseCharCached = m_userCharacterClasses.last().get(); 379 } 380 return wordUnicodeIgnoreCaseCharCached; 381 } 370 382 CharacterClass* nondigitsCharacterClass() 371 383 { … … 391 403 } 392 404 return nonwordcharCached; 405 } 406 CharacterClass* nonwordUnicodeIgnoreCaseCharCharacterClass() 407 { 408 if (!nonwordUnicodeIgnoreCasecharCached) { 409 m_userCharacterClasses.append(nonwordUnicodeIgnoreCaseCharCreate()); 410 nonwordUnicodeIgnoreCasecharCached = m_userCharacterClasses.last().get(); 411 } 412 return nonwordUnicodeIgnoreCasecharCached; 393 413 } 394 414 … … 415 435 CharacterClass* spacesCached; 416 436 CharacterClass* wordcharCached; 437 CharacterClass* wordUnicodeIgnoreCaseCharCached; 417 438 CharacterClass* nondigitsCached; 418 439 CharacterClass* nonspacesCached; 419 440 CharacterClass* nonwordcharCached; 441 CharacterClass* nonwordUnicodeIgnoreCasecharCached; 420 442 }; 421 443
Note: See TracChangeset
for help on using the changeset viewer.