Changeset 10818 in webkit for trunk/JavaScriptCore/kjs/string_object.cpp
- Timestamp:
- Oct 11, 2005, 1:43:49 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/string_object.cpp
r10757 r10818 233 233 } 234 234 235 static inline UString substituteBackreferences(const UString &replacement, const UString &source, int * *ovector, RegExp *reg)235 static inline UString substituteBackreferences(const UString &replacement, const UString &source, int *ovector, RegExp *reg) 236 236 { 237 237 UString substitutedReplacement = replacement; … … 247 247 unsigned backrefIndex = substitutedReplacement.substr(i+1,1).toUInt32(&converted, false /* tolerate empty string */); 248 248 if (converted && backrefIndex <= (unsigned)reg->subPatterns()) { 249 int backrefStart = (*ovector)[2*backrefIndex];250 int backrefLength = (*ovector)[2*backrefIndex+1] - backrefStart;249 int backrefStart = ovector[2*backrefIndex]; 250 int backrefLength = ovector[2*backrefIndex+1] - backrefStart; 251 251 substitutedReplacement = substitutedReplacement.substr(0,i) 252 252 + source.substr(backrefStart, backrefLength) … … 289 289 // This is either a loop (if global is set) or a one-way (if not). 290 290 do { 291 int **ovector = regExpObj->registerRegexp( reg, source ); 292 UString matchString = reg->match(source, startPosition, &matchIndex, ovector); 293 regExpObj->setSubPatterns(reg->subPatterns()); 291 int *ovector; 292 UString matchString = regExpObj->performMatch(reg, source, startPosition, &matchIndex, &ovector); 294 293 if (matchIndex == -1) 295 294 break; … … 299 298 300 299 if (replacementFunction) { 301 int completeMatchStart = (*ovector)[0];300 int completeMatchStart = ovector[0]; 302 301 List args; 303 302 … … 305 304 306 305 for (unsigned i = 0; i < reg->subPatterns(); i++) { 307 int matchStart = (*ovector)[(i + 1) * 2];308 int matchLen = (*ovector)[(i + 1) * 2 + 1] - matchStart;306 int matchStart = ovector[(i + 1) * 2]; 307 int matchLen = ovector[(i + 1) * 2 + 1] - matchStart; 309 308 310 309 args.append(jsString(source.substr(matchStart, matchLen))); … … 455 454 RegExp *reg, *tmpReg = 0; 456 455 RegExpImp *imp = 0; 457 if (a0->isObject() && a0->getObject()->inherits(&RegExpImp::info)) 458 { 456 if (a0->isObject() && a0->getObject()->inherits(&RegExpImp::info)) { 459 457 imp = static_cast<RegExpImp *>(a0); 460 458 reg = imp->regExp(); 461 } 462 else 463 { /* 459 } else { 460 /* 464 461 * ECMA 15.5.4.12 String.prototype.search (regexp) 465 462 * If regexp is not an object whose [[Class]] property is "RegExp", it is … … 469 466 } 470 467 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp()); 471 int **ovector = regExpObj->registerRegexp(reg, u); 472 UString mstr = reg->match(u, -1, &pos, ovector); 468 UString mstr = regExpObj->performMatch(reg, u, 0, &pos); 473 469 if (id == Search) { 474 470 result = Number(pos); … … 480 476 result = Null(); 481 477 } else { 482 regExpObj->setSubPatterns(reg->subPatterns());483 478 result = regExpObj->arrayOfMatches(exec,mstr); 484 479 } … … 494 489 lastIndex = pos; 495 490 pos += mstr.isEmpty() ? 1 : mstr.size(); 496 delete [] *ovector; 497 mstr = reg->match(u, pos, &pos, ovector); 491 mstr = regExpObj->performMatch(reg, u, pos, &pos); 498 492 } 499 493 if (imp) … … 515 509 result = replace(exec, s, a0, a1); 516 510 break; 517 case Slice: // http://developer.netscape.com/docs/manuals/js/client/jsref/string.htm#1194366511 case Slice: 518 512 { 519 513 // The arg processing is very much like ArrayProtoFunc::Slice
Note:
See TracChangeset
for help on using the changeset viewer.