Changeset 15698 in webkit for trunk/JavaScriptCore/kjs/string_object.cpp
- Timestamp:
- Jul 29, 2006, 5:04:22 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/string_object.cpp
- Property allow-tabs deleted
r15468 r15698 107 107 /* Source for string_object.lut.h 108 108 @begin stringTable 26 109 toString StringProtoFunc::ToString DontEnum|Function0110 valueOf StringProtoFunc::ValueOf DontEnum|Function0111 charAt StringProtoFunc::CharAt DontEnum|Function1112 charCodeAt StringProtoFunc::CharCodeAt DontEnum|Function1113 concat StringProtoFunc::Concat DontEnum|Function1114 indexOf StringProtoFunc::IndexOf DontEnum|Function1115 lastIndexOf StringProtoFunc::LastIndexOf DontEnum|Function1116 match StringProtoFunc::Match DontEnum|Function1117 replace StringProtoFunc::Replace DontEnum|Function2118 search StringProtoFunc::Search DontEnum|Function1119 slice StringProtoFunc::Slice DontEnum|Function2120 split StringProtoFunc::Split DontEnum|Function2121 substr StringProtoFunc::Substr DontEnum|Function2122 substring StringProtoFunc::Substring DontEnum|Function2123 toLowerCase StringProtoFunc::ToLowerCase DontEnum|Function0124 toUpperCase StringProtoFunc::ToUpperCase DontEnum|Function0125 toLocaleLowerCase StringProtoFunc::ToLocaleLowerCase DontEnum|Function0126 toLocaleUpperCase StringProtoFunc::ToLocaleUpperCase DontEnum|Function 109 toString StringProtoFunc::ToString DontEnum|Function 0 110 valueOf StringProtoFunc::ValueOf DontEnum|Function 0 111 charAt StringProtoFunc::CharAt DontEnum|Function 1 112 charCodeAt StringProtoFunc::CharCodeAt DontEnum|Function 1 113 concat StringProtoFunc::Concat DontEnum|Function 1 114 indexOf StringProtoFunc::IndexOf DontEnum|Function 1 115 lastIndexOf StringProtoFunc::LastIndexOf DontEnum|Function 1 116 match StringProtoFunc::Match DontEnum|Function 1 117 replace StringProtoFunc::Replace DontEnum|Function 2 118 search StringProtoFunc::Search DontEnum|Function 1 119 slice StringProtoFunc::Slice DontEnum|Function 2 120 split StringProtoFunc::Split DontEnum|Function 2 121 substr StringProtoFunc::Substr DontEnum|Function 2 122 substring StringProtoFunc::Substring DontEnum|Function 2 123 toLowerCase StringProtoFunc::ToLowerCase DontEnum|Function 0 124 toUpperCase StringProtoFunc::ToUpperCase DontEnum|Function 0 125 toLocaleLowerCase StringProtoFunc::ToLocaleLowerCase DontEnum|Function 0 126 toLocaleUpperCase StringProtoFunc::ToLocaleUpperCase DontEnum|Function 0 127 127 # 128 128 # Under here: html extension, should only exist if KJS_PURE_ECMA is not defined 129 129 # I guess we need to generate two hashtables in the .lut.h file, and use #ifdef 130 130 # to select the right one... TODO. ##### 131 big StringProtoFunc::Big DontEnum|Function0132 small StringProtoFunc::Small DontEnum|Function0133 blink StringProtoFunc::Blink DontEnum|Function0134 bold StringProtoFunc::Bold DontEnum|Function0135 fixed StringProtoFunc::Fixed DontEnum|Function0136 italics StringProtoFunc::Italics DontEnum|Function0137 strike StringProtoFunc::Strike DontEnum|Function0138 sub StringProtoFunc::Sub DontEnum|Function0139 sup StringProtoFunc::Sup DontEnum|Function0140 fontcolor StringProtoFunc::Fontcolor DontEnum|Function1141 fontsize StringProtoFunc::Fontsize DontEnum|Function1142 anchor StringProtoFunc::Anchor DontEnum|Function1143 link StringProtoFunc::Link DontEnum|Function1131 big StringProtoFunc::Big DontEnum|Function 0 132 small StringProtoFunc::Small DontEnum|Function 0 133 blink StringProtoFunc::Blink DontEnum|Function 0 134 bold StringProtoFunc::Bold DontEnum|Function 0 135 fixed StringProtoFunc::Fixed DontEnum|Function 0 136 italics StringProtoFunc::Italics DontEnum|Function 0 137 strike StringProtoFunc::Strike DontEnum|Function 0 138 sub StringProtoFunc::Sub DontEnum|Function 0 139 sup StringProtoFunc::Sup DontEnum|Function 0 140 fontcolor StringProtoFunc::Fontcolor DontEnum|Function 1 141 fontsize StringProtoFunc::Fontsize DontEnum|Function 1 142 anchor StringProtoFunc::Anchor DontEnum|Function 1 143 link StringProtoFunc::Link DontEnum|Function 1 144 144 @end 145 145 */ … … 488 488 // Exec 489 489 if ((reg->flags() & RegExp::Global) == 0) { 490 491 492 493 494 495 490 // case without 'g' flag is handled like RegExp.prototype.exec 491 if (mstr.isNull()) { 492 result = jsNull(); 493 } else { 494 result = regExpObj->arrayOfMatches(exec,mstr); 495 } 496 496 } else { 497 498 499 500 497 // return array of matches 498 List list; 499 int lastIndex = 0; 500 while (pos >= 0) { 501 501 if (mstr.isNull()) 502 502 list.append(jsUndefined()); 503 503 else 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 504 list.append(jsString(mstr)); 505 lastIndex = pos; 506 pos += mstr.isEmpty() ? 1 : mstr.size(); 507 mstr = regExpObj->performMatch(reg, u, pos, &pos); 508 } 509 if (imp) 510 imp->put(exec, "lastIndex", jsNumber(lastIndex), DontDelete|DontEnum); 511 if (list.isEmpty()) { 512 // if there are no matches at all, it's important to return 513 // Null instead of an empty array, because this matches 514 // other browsers and because Null is a false value. 515 result = jsNull(); 516 } else { 517 result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list); 518 } 519 519 } 520 520 } … … 553 553 RegExp *reg = static_cast<RegExpImp *>(a0)->regExp(); 554 554 if (u.isEmpty() && !reg->match(u, 0).isNull()) { 555 556 557 555 // empty string matched by regexp -> empty array 556 res->put(exec,lengthPropertyName, jsNumber(0)); 557 break; 558 558 } 559 559 pos = 0; 560 560 while (static_cast<uint32_t>(i) != limit && pos < u.size()) { 561 561 // TODO: back references 562 562 int mpos; 563 563 int *ovector = 0L; 564 564 UString mstr = reg->match(u, pos, &mpos, &ovector); 565 565 delete [] ovector; ovector = 0L; 566 567 568 569 570 571 572 573 566 if (mpos < 0) 567 break; 568 pos = mpos + (mstr.isEmpty() ? 1 : mstr.size()); 569 if (mpos != p0 || !mstr.isEmpty()) { 570 res->put(exec,i, jsString(u.substr(p0, mpos-p0))); 571 p0 = mpos + mstr.size(); 572 i++; 573 } 574 574 } 575 575 } else { 576 576 u2 = a0->toString(exec); 577 577 if (u2.isEmpty()) { 578 579 580 581 582 583 584 585 578 if (u.isEmpty()) { 579 // empty separator matches empty string -> empty array 580 put(exec,lengthPropertyName, jsNumber(0)); 581 break; 582 } else { 583 while (static_cast<uint32_t>(i) != limit && i < u.size()-1) 584 res->put(exec, i++, jsString(u.substr(p0++, 1))); 585 } 586 586 } else { 587 588 589 590 591 587 while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) { 588 res->put(exec, i, jsString(u.substr(p0, pos-p0))); 589 p0 = pos + u2.size(); 590 i++; 591 } 592 592 } 593 593 }
Note:
See TracChangeset
for help on using the changeset viewer.