Ignore:
Timestamp:
Nov 19, 2008, 1:08:40 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-11-19 Geoffrey Garen <[email protected]>

Reviewed by Darin Adler.


https://bugs.webkit.org/show_bug.cgi?id=22361
A little more RegExp refactoring.


Consistently named variables holding the starting position at which
regexp matching should begin to "startOffset".


A few more "regExpObject" => "regExpConstructor" changes.


Refactored RegExpObject::match for clarity, and replaced a slow "get"
of the "global" property with a fast access to the global bit.


Made the error message you see when RegExpObject::match has no input a
little more informative, as in Firefox.

  • runtime/RegExp.cpp: (JSC::RegExp::match):
  • runtime/RegExp.h:
  • runtime/RegExpObject.cpp: (JSC::RegExpObject::match):
  • runtime/StringPrototype.cpp: (JSC::stringProtoFuncReplace): (JSC::stringProtoFuncMatch): (JSC::stringProtoFuncSearch):

LayoutTests:

2008-11-19 Geoffrey Garen <[email protected]>

Reviewed by Darin Adler.


Test for https://bugs.webkit.org/show_bug.cgi?id=22361
A little more RegExp refactoring

  • fast/js/regexp-test-null-string.html: Added.
  • fast/js/regexp-test-null-expected.txt: Added.
File:
1 edited

Legend:

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

    r38544 r38603  
    114114}
    115115
    116 int RegExp::match(const UString& s, int i, OwnArrayPtr<int>* ovector)
     116int RegExp::match(const UString& s, int startOffset, OwnArrayPtr<int>* ovector)
    117117{
    118     if (i < 0)
    119         i = 0;
     118    if (startOffset < 0)
     119        startOffset = 0;
    120120    if (ovector)
    121121        ovector->clear();
    122122
    123     if (i > s.size() || s.isNull())
     123    if (startOffset > s.size() || s.isNull())
    124124        return -1;
    125125
     
    137137            ovector->set(offsetVector);
    138138
    139         int result = m_wrecFunction(s.data(), i, s.size(), offsetVector);
     139        int result = m_wrecFunction(s.data(), startOffset, s.size(), offsetVector);
    140140
    141141        if (result < 0) {
     
    166166        }
    167167
    168         int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);
     168        int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), startOffset, offsetVector, offsetVectorSize);
    169169   
    170170        if (numMatches < 0) {
Note: See TracChangeset for help on using the changeset viewer.