Changeset 52981 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Jan 8, 2010, 3:17:27 AM (15 years ago)
Author:
[email protected]
Message:

2010-01-08 Kent Hansen <[email protected]>

Reviewed by Darin Adler.

RegExp.prototype.toString returns "" for empty regular expressions
https://bugs.webkit.org/show_bug.cgi?id=33319

"" starts a single-line comment, hence "/(?:)/" should be used, according to ECMA.

  • runtime/RegExpPrototype.cpp: (JSC::regExpProtoFuncToString):

2010-01-08 Kent Hansen <[email protected]>

Reviewed by Darin Adler.

RegExp.prototype.toString returns "" for empty regular expressions
https://bugs.webkit.org/show_bug.cgi?id=33319

Add new test cases and adapt existing ones.

  • fast/js/kde/RegExp-expected.txt:
  • fast/js/kde/script-tests/RegExp.js:
  • fast/js/script-tests/regexp-compile.js:
  • fast/regex/non-pattern-characters-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/RegExpPrototype.cpp

    r52028 r52981  
    115115    if (asRegExpObject(thisValue)->get(exec, exec->propertyNames().multiline).toBoolean(exec))
    116116        postfix[index] = 'm';
    117    
    118     return jsNontrivialString(exec, makeString("/", asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec), postfix));
     117    UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec);
     118    return jsNontrivialString(exec, makeString("/", source.size() ? source : UString("(?:)"), postfix));
    119119}
    120120
Note: See TracChangeset for help on using the changeset viewer.