Ignore:
Timestamp:
Aug 12, 2007, 7:42:17 PM (18 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Maciej.

Test: fast/js/regexp-non-capturing-groups.html

  • kjs/string_object.cpp: (KJS::replace): Add missing code to handle undefined backreferences; before we'd get the empty string instead of a JavaScript "undefined" value. (KJS::StringProtoFunc::callAsFunction): Implemented backreference support for split.
  • pcre/pcre_exec.c: (match): Made backreferences to undefined groups match the empty string instead of always failing. Only in JAVASCRIPT mode.
  • tests/mozilla/expected.html: Add a new expected test success, since this fixed one test result.

LayoutTests:

Reviewed by Maciej.

  • fast/js/regexp-non-capturing-groups-expected.txt: Added.
  • fast/js/regexp-non-capturing-groups.html: Added.
  • fast/js/resources/regexp-non-capturing-groups.js: Added.
  • fast/js/resources/js-test-pre.js: Updated to add a special case for array results, since there are some array results in the test. Also cut down on the verbosity of failures when the type of the actual result is the same as the type of the expected result. And get rid of the special case function just for NaN.
  • fast/js/regexp-unicode-overflow.html: Let the make-js-test-wrappers script regenerate this file (it removed one of the trailing newlines).
  • fast/js/kde/encode_decode_uri-expected.txt: This test now passes. I'm not sure why it was failing before.
  • fast/js/char-at-expected.txt: Removed all the periods at the end of NaN test PASS messages; they are now consistent with all the other tests.
  • fast/js/date-parse-comments-test-expected.txt: Ditto.
  • fast/js/date-parse-test-expected.txt: Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r24919 r25026  
    33 *  This file is part of the KDE libraries
    44 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    5  *  Copyright (C) 2004 Apple Computer, Inc.
     5 *  Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    66 *
    77 *  This library is free software; you can redistribute it and/or
     
    363363              int matchLen = ovector[(i + 1) * 2 + 1] - matchStart;
    364364
    365               args.append(jsString(source.substr(matchStart, matchLen)));
     365              if (matchStart < 0)
     366                args.append(jsUndefined());
     367              else
     368                args.append(jsString(source.substr(matchStart, matchLen)));
    366369          }
    367370         
     
    609612      pos = 0;
    610613      while (static_cast<uint32_t>(i) != limit && pos < u.size()) {
    611         // TODO: back references
    612614        int mpos;
    613         int *ovector = 0L;
     615        int* ovector;
    614616        UString mstr = reg->match(u, pos, &mpos, &ovector);
    615         delete [] ovector; ovector = 0L;
    616         if (mpos < 0)
     617        if (mpos < 0) {
     618          delete [] ovector;
    617619          break;
     620        }
    618621        pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
    619622        if (mpos != p0 || !mstr.isEmpty()) {
     
    622625          i++;
    623626        }
     627        for (unsigned si = 1; si <= reg->subPatterns(); ++si) {
     628          int spos = ovector[si * 2];
     629          if (spos < 0)
     630            res->put(exec, i++, jsUndefined());
     631          else
     632            res->put(exec, i++, jsString(u.substr(spos, ovector[si * 2 + 1] - spos)));
     633        }
     634        delete [] ovector;
    624635      }
    625636    } else {
Note: See TracChangeset for help on using the changeset viewer.