[webkit-changes] cvs commit: JavaScriptCore/kjs string_object.cpp

Geoffrey ggaren at opensource.apple.com
Sat Dec 17 19:09:32 PST 2005


ggaren      05/12/17 19:09:31

  Modified:    .        ChangeLog
               kjs      string_object.cpp
  Log:
          Reviewed by NOBODY (OOPS!).
  
          Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=6119
          split() function ignores case insensitive modifier.
  
          Glossary:
          RegExpImp: The C++ object you get when JavaScript executes
                     "new RegExp()".
          RegExp:    A C++ wrapper object that performs regular expression
                     matching on behalf of a RegExpImp.
  
          Instead of unnecessarily constructing a RegExp which (wrongly) lacks
          any modifiers, String.split() now uses the RegExp built in to the
          RegExpImp passed to it, which has the right modifiers already.
  
          I also cleaned up other bits of the string code to standardized how
          we handle RegExpImp arguments.
  
          * ChangeLog:
          * kjs/string_object.cpp:
          (replace):
          (StringProtoFunc::callAsFunction):
  
  Revision  Changes    Path
  1.907     +25 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.906
  retrieving revision 1.907
  diff -u -r1.906 -r1.907
  --- ChangeLog	16 Dec 2005 22:27:24 -0000	1.906
  +++ ChangeLog	18 Dec 2005 03:09:29 -0000	1.907
  @@ -1,3 +1,28 @@
  +2005-12-17  Geoffrey Garen  <ggaren at apple.com>
  +
  +        Reviewed by NOBODY (OOPS!).
  +
  +        Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=6119
  +        split() function ignores case insensitive modifier.
  +
  +        Glossary:
  +        RegExpImp: The C++ object you get when JavaScript executes
  +                   "new RegExp()".
  +        RegExp:    A C++ wrapper object that performs regular expression
  +                   matching on behalf of a RegExpImp.
  +
  +        Instead of unnecessarily constructing a RegExp which (wrongly) lacks
  +        any modifiers, String.split() now uses the RegExp built in to the 
  +        RegExpImp passed to it, which has the right modifiers already.
  +
  +        I also cleaned up other bits of the string code to standardized how
  +        we handle RegExpImp arguments.
  +
  +        * ChangeLog:
  +        * kjs/string_object.cpp:
  +        (replace):
  +        (StringProtoFunc::callAsFunction):
  +
   2005-12-16  David Hyatt  <hyatt at apple.com>
   
   	Remove unused RefPtr constructors that can create an ambiguity in ustring on some platforms.
  
  
  
  1.54      +8 -17     JavaScriptCore/kjs/string_object.cpp
  
  Index: string_object.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/string_object.cpp,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- string_object.cpp	13 Dec 2005 21:24:53 -0000	1.53
  +++ string_object.cpp	18 Dec 2005 03:09:31 -0000	1.54
  @@ -168,12 +168,6 @@
     return true;
   }
   
  -static inline bool regExpIsGlobal(RegExpImp *regExp, ExecState *exec)
  -{
  -    JSValue *globalProperty = regExp->get(exec,"global");
  -    return !globalProperty->isUndefined() && globalProperty->toBoolean(exec);
  -}
  -
   static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity)
   {
     int newCapacity;
  @@ -268,10 +262,9 @@
     else
       replacementString = replacement->toString(exec);
   
  -  if (pattern->isObject() && pattern->toObject(exec)->inherits(&RegExpImp::info)) {
  -    RegExpImp* imp = static_cast<RegExpImp *>( pattern->toObject(exec) );
  -    RegExp *reg = imp->regExp();
  -    bool global = regExpIsGlobal(imp, exec);
  +  if (pattern->isObject() && static_cast<JSObject *>(pattern)->inherits(&RegExpImp::info)) {
  +    RegExp *reg = static_cast<RegExpImp *>(pattern)->regExp();
  +    bool global = reg->flags() & RegExp::Global;
   
       RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
   
  @@ -453,9 +446,8 @@
       u = s;
       RegExp *reg, *tmpReg = 0;
       RegExpImp *imp = 0;
  -    if (a0->isObject() && a0->getObject()->inherits(&RegExpImp::info)) {
  -      imp = static_cast<RegExpImp *>(a0);
  -      reg = imp->regExp();
  +    if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpImp::info)) {
  +      reg = static_cast<RegExpImp *>(a0)->regExp();
       } else { 
         /*
          *  ECMA 15.5.4.12 String.prototype.search (regexp)
  @@ -534,9 +526,8 @@
       i = p0 = 0;
       uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec);
       if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpImp::info)) {
  -      JSObject *obj0 = static_cast<JSObject *>(a0);
  -      RegExp reg(obj0->get(exec,"source")->toString(exec));
  -      if (u.isEmpty() && !reg.match(u, 0).isNull()) {
  +      RegExp *reg = static_cast<RegExpImp *>(a0)->regExp();
  +      if (u.isEmpty() && !reg->match(u, 0).isNull()) {
   	// empty string matched by regexp -> empty array
   	res->put(exec,lengthPropertyName, jsNumber(0));
   	break;
  @@ -546,7 +537,7 @@
   	// TODO: back references
           int mpos;
           int *ovector = 0L;
  -	UString mstr = reg.match(u, pos, &mpos, &ovector);
  +	UString mstr = reg->match(u, pos, &mpos, &ovector);
           delete [] ovector; ovector = 0L;
   	if (mpos < 0)
   	  break;
  
  
  



More information about the webkit-changes mailing list