Ignore:
Timestamp:
Jan 16, 2009, 12:01:44 AM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-01-15 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Fixed <rdar://problem/6471394> REGRESSION (r39164): Discarding quantifier
on assertion gives incorrect result (23075)


https://bugs.webkit.org/show_bug.cgi?id=23075

  • pcre/pcre_compile.cpp: (compileBranch): Throw away an assertion if it's followed by a quantifier with a 0 minimum, to match SpiderMonkey, v8, and the ECMA spec.
  • wrec/WRECParser.cpp: (JSC::WREC::Parser::parseParentheses): Fall back on PCRE for the rare case of an assertion with a quantifier with a 0 minimum, since we don't handle quantified subexpressions yet, and in this special case, we can't just throw away the quantifier.

LayoutTests:

2009-01-15 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Added a test for <rdar://problem/6471394> REGRESSION (r39164): Discarding
quantifier on assertion gives incorrect result (23075)

  • fast/regex/quantified-assertions-expected.txt:
  • fast/regex/resources/quantified-assertions.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/pcre_compile.cpp

    r39554 r39963  
    10591059                reqvary = (repeatMin == repeat_max) ? 0 : REQ_VARY;
    10601060               
    1061                 // A quantifier after an assertion is meaningless, since assertions
    1062                 // don't move index forward. So, we discard it.
    1063                 if (*previous == OP_ASSERT || *previous == OP_ASSERT_NOT)
    1064                     goto END_REPEAT;
    1065                
    10661061                opType = 0;                    /* Default single-char op codes */
    10671062               
     
    14151410                    else
    14161411                        code[-ketoffset] = OP_KETRMAX + repeatType;
     1412                }
     1413               
     1414                // A quantifier after an assertion is mostly meaningless, but it
     1415                // can nullify the assertion if it has a 0 minimum.
     1416                else if (*previous == OP_ASSERT || *previous == OP_ASSERT_NOT) {
     1417                    if (repeatMin == 0) {
     1418                        code = previous;
     1419                        goto END_REPEAT;
     1420                    }
    14171421                }
    14181422               
Note: See TracChangeset for help on using the changeset viewer.