Changeset 29110 in webkit for trunk/JavaScriptCore/pcre/pcre_compile.cpp
- Timestamp:
- Jan 2, 2008, 10:39:50 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/pcre/pcre_compile.cpp
r28796 r29110 136 136 struct CompileData { 137 137 CompileData() { 138 start_code = 0;139 start_pattern = 0;140 138 top_backref = 0; 141 139 backrefMap = 0; 142 140 req_varyopt = 0; 143 141 needOuterBracket = false; 142 numCapturingBrackets = 0; 144 143 } 145 const unsigned char* start_code; /* The start of the compiled code */146 const UChar* start_pattern; /* The start of the pattern */147 144 int top_backref; /* Maximum back reference */ 148 145 unsigned backrefMap; /* Bitmap of low back refs */ 149 146 int req_varyopt; /* "After variable item" flag for reqbyte */ 150 147 bool needOuterBracket; 148 int numCapturingBrackets; 151 149 }; 152 150 … … 730 728 731 729 if (c == '\\') { 732 c = checkEscape(&ptr, patternEnd, errorcodeptr, *brackets, true);730 c = checkEscape(&ptr, patternEnd, errorcodeptr, cd.numCapturingBrackets, true); 733 731 if (c < 0) { 734 732 class_charcount += 2; /* Greater than 1 is what matters */ … … 797 795 if (d == '\\') { 798 796 const UChar* oldptr = ptr; 799 d = checkEscape(&ptr, patternEnd, errorcodeptr, *brackets, true);797 d = checkEscape(&ptr, patternEnd, errorcodeptr, cd.numCapturingBrackets, true); 800 798 801 799 /* \X is literal X; any other special means the '-' was literal */ … … 1565 1563 case '\\': 1566 1564 tempptr = ptr; 1567 c = checkEscape(&ptr, patternEnd, errorcodeptr, *brackets, false);1565 c = checkEscape(&ptr, patternEnd, errorcodeptr, cd.numCapturingBrackets, false); 1568 1566 1569 1567 /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values … … 1988 1986 } 1989 1987 1990 static int calculateCompiledPatternLength AndFlags(const UChar* pattern, int patternLength, JSRegExpIgnoreCaseOption ignoreCase,1988 static int calculateCompiledPatternLength(const UChar* pattern, int patternLength, JSRegExpIgnoreCaseOption ignoreCase, 1991 1989 CompileData& cd, ErrorCode& errorcode) 1992 1990 { 1993 1991 /* Make a pass over the pattern to compute the 1994 1992 amount of store required to hold the compiled code. This does not have to be 1995 perfect as long as errors are overestimates. At the same time we can detect any 1996 flag settings right at the start, and extract them. Make an attempt to correct 1997 for any counted white space if an "extended" flag setting appears late in the 1998 pattern. We can't be so clever for #-comments. */ 1993 perfect as long as errors are overestimates. */ 1999 1994 2000 1995 int length = 1 + LINK_SIZE; /* For initial BRA plus length */ … … 2018 2013 2019 2014 case '\\': 2020 c = checkEscape(&ptr, patternEnd, &errorcode, bracount, false);2015 c = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, false); 2021 2016 if (errorcode != 0) 2022 2017 return -1; … … 2151 2146 2152 2147 if (*ptr == '\\') { 2153 c = checkEscape(&ptr, patternEnd, &errorcode, bracount, true);2148 c = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, true); 2154 2149 if (errorcode != 0) 2155 2150 return -1; … … 2186 2181 if (safelyCheckNextChar(ptr, patternEnd, '\\')) { 2187 2182 ptr++; 2188 d = checkEscape(&ptr, patternEnd, &errorcode, bracount, true);2183 d = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, true); 2189 2184 if (errorcode != 0) 2190 2185 return -1; … … 2469 2464 2470 2465 length += 2 + LINK_SIZE; /* For final KET and END */ 2466 2467 cd.numCapturingBrackets = bracount; 2471 2468 return length; 2472 2469 } … … 2513 2510 2514 2511 ErrorCode errorcode = ERR0; 2515 int length = calculateCompiledPatternLengthAndFlags(pattern, patternLength, ignoreCase, cd, errorcode); 2512 /* Call this once just to count the brackets. */ 2513 calculateCompiledPatternLength(pattern, patternLength, ignoreCase, cd, errorcode); 2514 /* Call it again to compute the length. */ 2515 int length = calculateCompiledPatternLength(pattern, patternLength, ignoreCase, cd, errorcode); 2516 2516 if (errorcode) 2517 2517 return returnError(errorcode, errorptr); … … 2532 2532 2533 2533 const unsigned char* codeStart = (const unsigned char*)(re + 1); 2534 cd.start_code = codeStart;2535 cd.start_pattern = (const UChar*)pattern;2536 2534 2537 2535 /* Set up a starting, non-extracting bracket, then compile the expression. On
Note:
See TracChangeset
for help on using the changeset viewer.