Ignore:
Timestamp:
Nov 11, 2007, 10:56:13 AM (18 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

Reviewed by Sam.

This is a combination of converting to C++, tweaking the API, and adding
some additional optimizations.

Future steps will involve getting rid of the use of UTF-8 completely
(we'll use UTF-16 exclusively instead), eliminating more source files,
and some more speed-ups.

SunSpider says the current round is an 0.9% speed-up overall, and a
5.3% speed-up for regexp.

  • kjs/regexp.cpp: (KJS::RegExp::RegExp): Changed to use the error message without calling strdup on it and to pass the new types and options. (KJS::RegExp::~RegExp): Removed the now-unneeded free of the error message. (KJS::RegExp::match): Pass the new types and options.
  • kjs/regexp.h: Update type of m_constructionError.
  • pcre/AUTHORS: Update to reflect the status of the project -- we don't include the Google parts, and this isn't the PCRE library, per se.
  • pcre/COPYING: Ditto.
  • pcre/dftables.cpp: Copied from JavaScriptCore/pcre/dftables.c. (main): Removed unneeded ctype_digit.
  • pcre/pcre.h: Convert to C++, tweak API a bit. Use UChar instead of JSRegExpChar.
  • pcre/pcre_compile.cpp: Copied from JavaScriptCore/pcre/pcre_compile.c. Moved a lot of private stuff used only within this file here from pcre_internal.h. Renumbered the error codes. (error_text): Use a single string with embedded nulls for the error text (I got this idea from newer versions of PCRE). (check_escape): Changed return type to be enum instead of int. Replaced ctype_digit uses with isASCIIDigit. (is_counted_repeat): Ditto. (read_repeat_counts): Ditto. (first_significant_code): Ditto. (find_fixedlength): Ditto. (could_be_empty_branch): Ditto. (compile_branch): Ditto. Also removed some code that handles changing options. JavaScript doesn't have any of the features that allow options to change. (compile_regex): Updated for change to options parameter. (is_anchored): Ditto. (find_firstassertedchar): Ditto. (jsRegExpCompile): Changed to take separate flags instead of an options int. Also changed to call new/delete instead of pcre_malloc/free. (jsRegExpFree): Ditto.
  • pcre/pcre_exec.cpp: Copied from JavaScriptCore/pcre/pcre_exec.c. Added a case that uses computed goto for the opcode loop, but did not turn it on. Changed the RMATCH macro to handle returns more efficiently by putting the where pointer in the new frame instead of the old one, allowing us to branch to the return with a single statement. Switched to new/delete from pcre_malloc/free. Changed many RRETURN callers to not set the return value since it's already set correctly. Replaced the rrc variable with an is_match variable. Values other than "match" and "no match" are now handled differently. This allows us to remove the code to check for those cases in various rules. (match): All the case statements use a macro BEGIN_OPCODE instead. And all the continue statements, or break statements that break out of the outer case use a macro NEXT_OPCODE instead. Replaced a few if statements with assertions. (jsRegExpExecute): Use new/delete instead of pcre_malloc/free. Removed unused start_match field from the match block.
  • pcre/pcre_internal.h: Moved the last few configuration macros from pcre-config.h in here. Removed various unused types. Converted from JSRegExpChar to UChar. Eliminated pcre_malloc/free. Replaced the opcode enum with a macro that can be used in multiple places. Unfortunately we lose the comments for each opcode; we should find a place to put those back. Removed ctype_digit.
  • pcre/pcre_maketables.cpp: Copied from JavaScriptCore/pcre/pcre_maketables.c. (pcre_maketables): Got rid of the conditional code that allows this to be compiled in -- it's only used for dftables now (and soon may be obsolete entirely). Changed code for cbit_digit to not use isdigit, and took the "_" case out of the loop. Removed ctype_digit.
  • pcre/pcre_ord2utf8.cpp: Copied from JavaScriptCore/pcre/pcre_ord2utf8.c.
  • pcre/pcre_tables.cpp: Copied from JavaScriptCore/pcre/pcre_tables.c. Moved _pcre_OP_lengths out of here into pcre_exec.cpp.
  • pcre/pcre_ucp_searchfuncs.cpp: Copied from JavaScriptCore/pcre/pcre_ucp_searchfuncs.c. Updated for other file name changes.
  • pcre/ucpinternal.h: Updated header.
  • wtf/ASCIICType.h: (WTF::isASCIIDigit): Removed a branch by changing from && to & for this operation. Also added an overload that takes an int because that's useful for PCRE. Later we could optimize for int and overload other functions in this file; stuck to this simple one for now.
  • wtf/unicode/icu/UnicodeIcu.h: Removed unused isUpper.
  • wtf/unicode/qt4/UnicodeQt4.h: Ditto.
  • pcre/LICENCE: Removed.
  • pcre/pcre-config.h: Removed.
  • wtf/FastMallocPCRE.cpp: Removed.
  • pcre/dftables.c: Renamed to cpp.
  • pcre/pcre_compile.c: Ditto.
  • pcre/pcre_exec.c: Ditto.
  • pcre/pcre_maketables.c: Ditto.
  • pcre/pcre_ord2utf8.c: Ditto.
  • pcre/pcre_tables.c: Ditto.
  • pcre/pcre_ucp_searchfuncs.c: Ditto.
  • pcre/pcre_xclass.c: Ditto.
  • pcre/ucptable.c: Ditto.

WebCore:

Reviewed by Sam.

  • updated for JSRegExp function changes
  • platform/RegularExpression.cpp: (WebCore::RegularExpression::Private::compile): (WebCore::RegularExpression::match):
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/pcre_compile.cpp

    r27681 r27686  
    1 /*************************************************
    2 *      Perl-Compatible Regular Expressions       *
    3 *************************************************/
    4 
    5 /* PCRE is a library of functions to support regular expressions whose syntax
    6 and semantics are as close as possible to those of the Perl 5 language.
    7 
    8                        Written by Philip Hazel
     1/* This is JavaScriptCore's variant of the PCRE library. While this library
     2started out as a copy of PCRE, many of the features of PCRE have been
     3removed. This library now supports only the regular expression features
     4required by the JavaScript language specification, and has only the functions
     5needed by JavaScriptCore and the rest of WebKit.
     6
     7                 Originally written by Philip Hazel
    98           Copyright (c) 1997-2006 University of Cambridge
    10            Copyright (c) 2004, 2005 Apple Computer, Inc.
     9    Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved.
    1110
    1211-----------------------------------------------------------------------------
     
    3938*/
    4039
    41 
    42 /* This module contains the external function pcre_compile(), along with
     40/* This module contains the external function jsRegExpExecute(), along with
    4341supporting internal functions that are not used by other modules. */
    4442
    45 
    4643#include "pcre_internal.h"
    4744
    48 
    49 /* WARNING: These macros evaluate their parameters more than once. */
     45#include <wtf/ASCIICType.h>
     46#include <wtf/FastMalloc.h>
     47
     48using namespace WTF;
     49
     50/* WARNING: This macro evaluates its parameters more than once. */
    5051#define DIGITAB(x) ((x) < 128 ? digitab[(x)] : 0)
    51 
    52 
    53 /* When DEBUG is defined, we need the pcre_printint() function, which is also
    54 used by pcretest. DEBUG is not defined when building a production library. */
    55 
    56 #ifdef DEBUG
    57 #include "pcre_printint.src"
    58 #endif
    59 
    60 
    6152
    6253/*************************************************
     
    7768is invalid. */
    7869
    79 static const short int escapes[] = {
     70static const short escapes[] = {
    8071     0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */
    8172     0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */
     
    9081};
    9182
     83/* Error code numbers. They are given names so that they can more easily be
     84tracked. */
     85
     86typedef enum {
     87    ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
     88    ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17
     89} ErrorCode;
     90
     91/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
     92the definition is next to the definition of the opcodes in pcre_internal.h. */
     93
     94static const uschar OP_lengths[] = { OP_LENGTHS };
    9295
    9396/* The texts of compile-time error messages. These are "char *" because they
    9497are passed to the outside world. */
    9598
    96 static const char * const error_texts[] = {
    97   "no error",
    98   "\\ at end of pattern",
    99   "\\c at end of pattern",
    100   "unrecognized character follows \\",
    101   "numbers out of order in {} quantifier",
    102   /* 5 */
    103   "number too big in {} quantifier",
    104   "missing terminating ] for character class",
    105   "invalid escape sequence in character class",
    106   "range out of order in character class",
    107   "nothing to repeat",
    108   /* 10 */
    109   "operand of unlimited repeat could match the empty string",
    110   "internal error: unexpected repeat",
    111   "unrecognized character after (?",
    112   "POSIX named classes are supported only within a class",
    113   "missing )",
    114   /* 15 */
    115   "reference to non-existent subpattern",
    116   "erroffset passed as NULL",
    117   "unknown option bit(s) set",
    118   "missing ) after comment",
    119   "parentheses nested too deeply",
    120   /* 20 */
    121   "regular expression too large",
    122   "failed to get memory",
    123   "unmatched parentheses",
    124   "internal error: code overflow",
    125   "unrecognized character after (?<",
    126   /* 25 */
    127   "lookbehind assertion is not fixed length",
    128   "malformed number after (?(",
    129   "conditional group contains more than two branches",
    130   "assertion expected after (?(",
    131   "(?R or (?digits must be followed by )",
    132   /* 30 */
    133   "unknown POSIX class name",
    134   "POSIX collating elements are not supported",
    135   "this version of PCRE is not compiled with PCRE_UTF8 support",
    136   "spare error",
    137   "character value in \\x{...} sequence is too large",
    138   /* 35 */
    139   "invalid condition (?(0)",
    140   "\\C not allowed in lookbehind assertion",
    141   "PCRE does not support \\L, \\l, \\N, \\U, or \\u",
    142   "number after (?C is > 255",
    143   "closing ) for (?C expected",
    144   /* 40 */
    145   "recursive call could loop indefinitely",
    146   "unrecognized character after (?P",
    147   "syntax error after (?P",
    148   "two named groups have the same name",
    149   "invalid UTF-16 string",
    150   /* 45 */
    151   "support for \\P, \\p, and \\X has not been compiled",
    152   "malformed \\P or \\p sequence",
    153   "unknown property name after \\P or \\p"
    154 };
    155 
    156 
    157 /* Table to identify digits and hex digits. This is used when compiling
     99static const char* error_text(ErrorCode code)
     100{
     101    static const char error_texts[] =
     102      /* 1 */
     103      "\\ at end of pattern\0"
     104      "\\c at end of pattern\0"
     105      "character value in \\x{...} sequence is too large\0"
     106      "numbers out of order in {} quantifier\0"
     107      /* 5 */
     108      "number too big in {} quantifier\0"
     109      "missing terminating ] for character class\0"
     110      "internal error: code overflow\0"
     111      "range out of order in character class\0"
     112      "nothing to repeat\0"
     113      /* 10 */
     114      "unmatched parentheses\0"
     115      "internal error: unexpected repeat\0"
     116      "unrecognized character after (?\0"
     117      "failed to get memory\0"
     118      "missing )\0"
     119      /* 15 */
     120      "reference to non-existent subpattern\0"
     121      "regular expression too large\0"
     122      "parentheses nested too deeply"
     123    ;
     124
     125    int i = code;
     126    const char* text = error_texts;
     127    while (i > 1)
     128        i -= !*text++;
     129    return text;
     130}
     131
     132/* Table to hex digits. This is used when compiling
    158133patterns. Note that the tables in chartables are dependent on the locale, and
    159134may mark arbitrary characters as digits - but the PCRE compiling code expects
     
    164139efficiently.
    165140
    166 For convenience, we use the same bit definitions as in chartables:
    167 
    168   0x04   decimal digit
     141For convenience, we use the same bit definition as in chartables:
     142
    169143  0x08   hexadecimal digit
    170144
    171 Then we can use ctype_digit and ctype_xdigit in the code. */
     145Then we can use ctype_xdigit in the code. */
    172146
    173147static const unsigned char digitab[] =
     
    206180  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
    207181
    208 
    209182/* Definition to allow mutual recursion */
    210183
    211184static BOOL
    212   compile_regex(int, int *, uschar **, const pcre_uchar **, const pcre_uchar *, int *, int,
     185  compile_regex(int, int *, uschar **, const pcre_uchar **, const pcre_uchar *, ErrorCode*, int,
    213186    int *, int *, compile_data *);
    214 
    215 
    216187
    217188/*************************************************
     
    238209
    239210static int
    240 check_escape(const pcre_uchar **ptrptr, const pcre_uchar *patternEnd, int *errorcodeptr, int bracount,
     211check_escape(const pcre_uchar **ptrptr, const pcre_uchar *patternEnd, ErrorCode* errorcodeptr, int bracount,
    241212  BOOL isclass)
    242213{
     
    253224c = *ptr;
    254225
    255 if (0) { } /* Matches with else below; to make merging easier. */
    256 
    257226/* Non-alphamerics are literals. For digits or letters, do an initial lookup in
    258227a table. A non-zero result is something that can be returned immediately.
    259228Otherwise further processing may be required. */
    260229
    261 else if (c < '0' || c > 'z') {}                           /* Not alphameric */
     230if (c < '0' || c > 'z') {}                           /* Not alphameric */
    262231else if ((i = escapes[c - '0']) != 0) c = i;
    263232
     
    291260      oldptr = ptr;
    292261      c -= '0';
    293       while (ptr + 1 < patternEnd && (DIGITAB(ptr[1]) & ctype_digit) != 0)
     262      while (ptr + 1 < patternEnd && isASCIIDigit(ptr[1]))
    294263        c = c * 10 + *(++ptr) - '0';
    295264      if (c < 10 || c <= bracount)
     
    345314      if (pt < patternEnd && *pt == '}')
    346315        {
    347         if (c < 0 || count > 8) *errorcodeptr = ERR34;
    348         else if (c >= 0xD800 && c <= 0xDFFF) *errorcodeptr = ERR34; // half of surrogate pair
    349         else if (c >= 0xFDD0 && c <= 0xFDEF) *errorcodeptr = ERR34; // ?
    350         else if (c == 0xFFFE) *errorcodeptr = ERR34; // not a character
    351         else if (c == 0xFFFF)  *errorcodeptr = ERR34; // not a character
    352         else if (c > 0x10FFFF) *errorcodeptr = ERR34; // out of Unicode character range
     316        if (c < 0 || count > 8) *errorcodeptr = ERR3;
     317        else if (c >= 0xD800 && c <= 0xDFFF) *errorcodeptr = ERR3; // half of surrogate pair
     318        else if (c >= 0xFDD0 && c <= 0xFDEF) *errorcodeptr = ERR3; // ?
     319        else if (c == 0xFFFE) *errorcodeptr = ERR3; // not a character
     320        else if (c == 0xFFFF)  *errorcodeptr = ERR3; // not a character
     321        else if (c > 0x10FFFF) *errorcodeptr = ERR3; // out of Unicode character range
    353322        ptr = pt;
    354323        break;
     
    441410is_counted_repeat(const pcre_uchar *p, const pcre_uchar *patternEnd)
    442411{
    443 if (p >= patternEnd || (DIGITAB(*p) & ctype_digit) == 0)
     412if (p >= patternEnd || !isASCIIDigit(*p))
    444413    return FALSE;
    445414p++;
    446 while (p < patternEnd && (DIGITAB(*p) & ctype_digit) != 0)
     415while (p < patternEnd && isASCIIDigit(*p))
    447416    p++;
    448417if (p < patternEnd && *p == '}')
     
    454423    return TRUE;
    455424
    456 if (p >= patternEnd || (DIGITAB(*p) & ctype_digit) == 0)
     425if (p >= patternEnd || !isASCIIDigit(*p))
    457426    return FALSE;
    458427p++;
    459 while (p < patternEnd && (DIGITAB(*p) & ctype_digit) != 0)
     428while (p < patternEnd && isASCIIDigit(*p))
    460429    p++;
    461430
     
    485454
    486455static const pcre_uchar *
    487 read_repeat_counts(const pcre_uchar *p, int *minp, int *maxp, int *errorcodeptr)
     456read_repeat_counts(const pcre_uchar *p, int *minp, int *maxp, ErrorCode* errorcodeptr)
    488457{
    489458int min = 0;
     
    493462an integer overflow. */
    494463
    495 while ((DIGITAB(*p) & ctype_digit) != 0) min = min * 10 + *p++ - '0';
     464while (isASCIIDigit(*p)) min = min * 10 + *p++ - '0';
    496465if (min < 0 || min > 65535)
    497466  {
     
    508477    {
    509478    max = 0;
    510     while((DIGITAB(*p) & ctype_digit) != 0) max = max * 10 + *p++ - '0';
     479    while (isASCIIDigit(*p)) max = max * 10 + *p++ - '0';
    511480    if (max < 0 || max > 65535)
    512481      {
     
    559528    if (!skipassert) return code;
    560529    do code += GET(code, 1); while (*code == OP_ALT);
    561     code += _pcre_OP_lengths[*code];
     530    code += OP_lengths[*code];
    562531    break;
    563532
     
    568537
    569538    case OP_BRANUMBER:
    570     code += _pcre_OP_lengths[*code];
     539    code += OP_lengths[*code];
    571540    break;
    572541
     
    655624    case OP_NOT_WORD_BOUNDARY:
    656625    case OP_WORD_BOUNDARY:
    657     cc += _pcre_OP_lengths[*cc];
     626    cc += OP_lengths[*cc];
    658627    break;
    659628
     
    766735for (code = first_significant_code(code + 1 + LINK_SIZE, TRUE);
    767736     code < endcode;
    768      code = first_significant_code(code + _pcre_OP_lengths[c], TRUE))
     737     code = first_significant_code(code + OP_lengths[c], TRUE))
    769738  {
    770739  const uschar *ccode;
     
    956925
    957926Arguments:
    958   optionsptr     pointer to the option bits
     927  options        the option bits
    959928  brackets       points to number of extracting brackets used
    960929  codeptr        points to the pointer to the current code point
     
    970939
    971940static BOOL
    972 compile_branch(int *optionsptr, int *brackets, uschar **codeptr,
    973   const pcre_uchar **ptrptr, const pcre_uchar *patternEnd, int *errorcodeptr, int *firstbyteptr,
     941compile_branch(int options, int *brackets, uschar **codeptr,
     942  const pcre_uchar **ptrptr, const pcre_uchar *patternEnd, ErrorCode* errorcodeptr, int *firstbyteptr,
    974943  int *reqbyteptr, compile_data *cd)
    975944{
     
    980949int zeroreqbyte, zerofirstbyte;
    981950int req_caseopt, reqvary, tempreqvary;
    982 int options = *optionsptr;
    983951int after_manual_callout = 0;
    984952register int c;
     
    1025993  int class_charcount;
    1026994  int class_lastchar;
    1027   int newoptions;
    1028995  int skipbytes;
    1029996  int subreqbyte;
     
    19551922
    19561923    case '(':
    1957     newoptions = options;
    19581924    skipbytes = 0;
    19591925
     
    20121978
    20131979    if (!compile_regex(
    2014          newoptions,                   /* The complete new option state */
     1980         options,
    20151981         brackets,                     /* Extracting bracket count */
    20161982         &tempcode,                    /* Where to put code (updated) */
     
    22542220static BOOL
    22552221compile_regex(int options, int *brackets, uschar **codeptr,
    2256   const pcre_uchar **ptrptr, const pcre_uchar *patternEnd, int *errorcodeptr, int skipbytes,
     2222  const pcre_uchar **ptrptr, const pcre_uchar *patternEnd, ErrorCode* errorcodeptr, int skipbytes,
    22572223  int *firstbyteptr, int *reqbyteptr, compile_data *cd)
    22582224{
     
    22772243  /* Now compile the branch */
    22782244
    2279   if (!compile_branch(&options, brackets, &code, &ptr, patternEnd, errorcodeptr,
     2245  if (!compile_branch(options, brackets, &code, &ptr, patternEnd, errorcodeptr,
    22802246        &branchfirstbyte, &branchreqbyte, cd))
    22812247    {
     
    24152381
    24162382static BOOL
    2417 is_anchored(register const uschar *code, int *options, unsigned int bracket_map,
     2383is_anchored(register const uschar *code, int options, unsigned int bracket_map,
    24182384  unsigned int backref_map)
    24192385{
     
    24432409   /* Check for explicit anchoring */
    24442410
    2445    else if (((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
     2411   else if (((options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
    24462412     return FALSE;
    24472413   code += GET(code, 1);
     
    25412507
    25422508static int
    2543 find_firstassertedchar(const uschar *code, int *options, BOOL inassert)
     2509find_firstassertedchar(const uschar *code, int options, BOOL inassert)
    25442510{
    25452511register int c = -1;
     
    25782544       {
    25792545       c = scode[1];
    2580        if ((*options & PCRE_CASELESS) != 0) c |= REQ_CASELESS;
     2546       if ((options & PCRE_CASELESS) != 0) c |= REQ_CASELESS;
    25812547       }
    25822548     else if (c != scode[1]) return -1;
     
    26152581
    26162582pcre *
    2617 jsRegExpCompile(const pcre_char* pattern, int patternLength, int options, unsigned* numSubpatterns, const char** errorptr)
     2583jsRegExpCompile(const pcre_char* pattern, int patternLength,
     2584    JSRegExpIgnoreCaseOption ignoreCase, JSRegExpMultilineOption multiline,
     2585    unsigned* numSubpatterns, const char** errorptr)
    26182586{
    26192587real_pcre *re;
     
    26272595int max_name_size = 0;
    26282596int lastitemlength = 0;
    2629 int errorcode = 0;
     2597ErrorCode errorcode = ERR0;
    26302598BOOL class_utf8;
    26312599BOOL capturing;
     
    29092877            }
    29102878
    2911           if ((d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))
     2879          if ((d > 255 || (ignoreCase && d > 127)))
    29122880            {
    29132881            uschar buffer[6];
     
    29242892            another byte in the UTF-8 representation. */
    29252893
    2926             if ((options & PCRE_CASELESS) != 0)
     2894            if (ignoreCase)
    29272895              {
    29282896              int occ, ocd;
     
    29652933        else
    29662934          {
    2967           if ((c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))
     2935          if ((c > 255 || (ignoreCase && c > 127)))
    29682936            {
    29692937            uschar buffer[6];
     
    29742942              length += LINK_SIZE + 2;
    29752943              }
    2976             length += (((options & PCRE_CASELESS) != 0)? 2 : 1) *
    2977               (1 + _pcre_ord2utf8(c, buffer));
     2944            length += (ignoreCase ? 2 : 1) * (1 + _pcre_ord2utf8(c, buffer));
    29782945            }
    29792946          }
     
    30713038    if (brastackptr >= sizeof(brastack)/sizeof(int))
    30723039      {
    3073       errorcode = ERR19;
     3040      errorcode = ERR17;
    30743041      goto PCRE_ERROR_RETURN;
    30753042      }
     
    31813148if (length > MAX_PATTERN_SIZE)
    31823149  {
    3183   errorcode = ERR20;
    3184   goto PCRE_EARLY_ERROR_RETURN;
     3150  errorcode = ERR16;
     3151  goto PCRE_ERROR_RETURN;
    31853152  }
    31863153
    3187 /* Compute the size of data block needed and get it, either from malloc or
    3188 externally provided function. */
     3154/* Compute the size of data block needed and get it. */
    31893155
    31903156size = length + sizeof(real_pcre) + name_count * (max_name_size + 3);
    3191 re = (real_pcre *)(pcre_malloc)(size);
     3157re = reinterpret_cast<real_pcre*>(new char[size]);
    31923158
    31933159if (re == NULL)
    31943160  {
    3195   errorcode = ERR21;
    3196   goto PCRE_EARLY_ERROR_RETURN;
     3161  errorcode = ERR13;
     3162  goto PCRE_ERROR_RETURN;
    31973163  }
    31983164
     
    32033169
    32043170re->size = (pcre_uint32)size;
    3205 re->options = options;
     3171re->options = (ignoreCase ? PCRE_CASELESS : 0) | (multiline ? PCRE_MULTILINE : 0);
    32063172
    32073173/* The starting points of the name/number translation table and of the code are
     
    32213187*code = OP_BRA;
    32223188bracount = 0;
    3223 (void)compile_regex(options, &bracount, &code, &ptr,
     3189(void)compile_regex(re->options, &bracount, &code, &ptr,
    32243190  patternEnd,
    32253191  &errorcode, 0, &firstbyte, &reqbyte, &compile_block);
     
    32293195/* If not reached end of pattern on success, there's an excess bracket. */
    32303196
    3231 if (errorcode == 0 && ptr < patternEnd) errorcode = ERR22;
     3197if (errorcode == 0 && ptr < patternEnd) errorcode = ERR10;
    32323198
    32333199/* Fill in the terminating state and check for disastrous overflow, but
     
    32373203
    32383204#ifndef DEBUG
    3239 if (code - codestart > length) errorcode = ERR23;
     3205if (code - codestart > length) errorcode = ERR7;
    32403206#endif
    32413207
     
    32473213/* Failed to compile, or error while post-processing */
    32483214
    3249 if (errorcode != 0)
     3215if (errorcode != ERR0)
    32503216  {
    3251   (pcre_free)(re);
     3217  delete [] reinterpret_cast<char*>(re);
    32523218  PCRE_ERROR_RETURN:
    3253   PCRE_EARLY_ERROR_RETURN:
    3254   *errorptr = error_texts[errorcode];
     3219  *errorptr = error_text(errorcode);
    32553220  return NULL;
    32563221  }
     
    32673232
    32683233  {
    3269   int temp_options = options;
    3270   if (is_anchored(codestart, &temp_options, 0, compile_block.backref_map))
     3234  if (is_anchored(codestart, re->options, 0, compile_block.backref_map))
    32713235    re->options |= PCRE_ANCHORED;
    32723236  else
    32733237    {
    32743238    if (firstbyte < 0)
    3275       firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);
     3239      firstbyte = find_firstassertedchar(codestart, re->options, FALSE);
    32763240    if (firstbyte >= 0)   /* Remove caseless flag for non-caseable chars */
    32773241      {
     
    33473311  {
    33483312  (pcre_free)(re);
    3349   *errorptr = error_texts[ERR23];
     3313  *errorptr = error_text(ERR7);
    33503314  return NULL;
    33513315  }
     3316
    33523317#endif
    33533318
     
    33593324void jsRegExpFree(JSRegExp* re)
    33603325{
    3361     pcre_free(re);
     3326    delete [] reinterpret_cast<char*>(re);
    33623327}
    3363 
    3364 /* End of pcre_compile.c */
Note: See TracChangeset for help on using the changeset viewer.