Changeset 27730 in webkit for trunk/JavaScriptCore/pcre/pcre_exec.cpp
- Timestamp:
- Nov 12, 2007, 3:04:41 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/pcre/pcre_exec.cpp
r27686 r27730 41 41 that does pattern matching using an NFA algorithm, following the rules from 42 42 the JavaScript specification. There are also some supporting functions. */ 43 44 #include "config.h" 43 45 44 46 #include "pcre_internal.h" … … 129 131 } match_data; 130 132 131 #define match_isgroup TRUE/* Set if start of bracketed group */133 #define match_isgroup true /* Set if start of bracketed group */ 132 134 133 135 /* Non-error returns from the match() function. Error returns are externally … … 155 157 p points to characters 156 158 length number to print 157 is_subject TRUEif printing from within md->start_subject158 md pointer to matching data block, if is_subject is TRUE159 is_subject true if printing from within md->start_subject 160 md pointer to matching data block, if is_subject is true 159 161 160 162 Returns: nothing … … 188 190 md points to match data block 189 191 190 Returns: TRUEif matched192 Returns: true if matched 191 193 */ 192 194 … … 202 204 { 203 205 printf("matching subject "); 204 pchars(eptr, length, TRUE, md);206 pchars(eptr, length, true, md); 205 207 } 206 208 printf(" against backref "); 207 pchars(p, length, FALSE, md);209 pchars(p, length, false, md); 208 210 printf("\n"); 209 211 #endif … … 211 213 /* Always fail if not enough characters left */ 212 214 213 if (length > md->end_subject - eptr) return FALSE;215 if (length > md->end_subject - eptr) return false; 214 216 215 217 /* Separate the caselesss case for speed */ … … 222 224 int othercase = _pcre_ucp_othercase(c); 223 225 pcre_uchar d = *eptr++; 224 if (c != d && othercase != d) return FALSE;226 if (c != d && othercase != d) return false; 225 227 } 226 228 } 227 229 else 228 { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }229 230 return TRUE;230 { while (length-- > 0) if (*p++ != *eptr++) return false; } 231 232 return true; 231 233 } 232 234 … … 298 300 #define RRETURN_NO_MATCH \ 299 301 {\ 300 is_match = FALSE;\302 is_match = false;\ 301 303 RRETURN;\ 302 304 } … … 333 335 static int match(USPTR eptr, const uschar *ecode, int offset_top, match_data *md) 334 336 { 335 register int is_match = FALSE;337 register int is_match = false; 336 338 register int i; 337 339 register int c; … … 341 343 BOOL cur_is_word; 342 344 BOOL prev_is_word; 343 BOOL is_group_start = TRUE;345 BOOL is_group_start = true; 344 346 int min; 345 BOOL minimize = FALSE; /* Initialization not really needed, but some compilers think so. */347 BOOL minimize = false; /* Initialization not really needed, but some compilers think so. */ 346 348 347 349 /* The value 16 here is large enough that most regular expressions don't require … … 450 452 md->end_match_ptr = frame->eptr; /* Record where we ended */ 451 453 md->end_offset_top = frame->offset_top; /* and how many extracts were taken */ 452 is_match = TRUE;454 is_match = true; 453 455 RRETURN; 454 456 … … 499 501 500 502 BEGIN_OPCODE(ONCE): 501 {502 503 frame->prev = frame->ecode; 503 504 frame->saved_eptr = frame->eptr; … … 554 555 if (is_match) RRETURN; 555 556 } 556 }557 557 RRETURN; 558 558 … … 610 610 md->end_match_ptr = frame->eptr; /* For ONCE */ 611 611 md->end_offset_top = frame->offset_top; 612 is_match = TRUE;612 is_match = true; 613 613 RRETURN; 614 614 } … … 618 618 extraction by setting the offsets and bumping the high water mark. */ 619 619 620 {621 620 frame->number = *frame->prev - OP_BRA; 622 621 … … 639 638 if (frame->number > 0) 640 639 { 641 if (frame->offset >= md->offset_max) md->offset_overflow = TRUE; else640 if (frame->offset >= md->offset_max) md->offset_overflow = true; else 642 641 { 643 642 md->offset_vector[frame->offset] = … … 647 646 } 648 647 } 649 }650 648 651 649 /* For a non-repeating ket, just continue at this level. This also … … 724 722 725 723 { 726 if (frame->eptr == md->start_subject) prev_is_word = FALSE; else724 if (frame->eptr == md->start_subject) prev_is_word = false; else 727 725 { 728 726 const pcre_uchar *lastptr = frame->eptr - 1; … … 731 729 prev_is_word = c < 128 && (md->ctypes[c] & ctype_word) != 0; 732 730 } 733 if (frame->eptr >= md->end_subject) cur_is_word = FALSE; else731 if (frame->eptr >= md->end_subject) cur_is_word = false; else 734 732 { 735 733 GETCHAR(c, frame->eptr); … … 813 811 814 812 BEGIN_OPCODE(REF): 815 {816 813 frame->offset = GET2(frame->ecode, 1) << 1; /* Doubled ref number */ 817 814 frame->ecode += 3; /* Advance past item */ … … 911 908 RRETURN_NO_MATCH; 912 909 } 913 }914 910 /* Control never gets here */ 915 911 … … 927 923 BEGIN_OPCODE(NCLASS): 928 924 BEGIN_OPCODE(CLASS): 929 {930 925 frame->data = frame->ecode + 1; /* Save for matching */ 931 926 frame->ecode += 33; /* Advance past the item */ … … 1037 1032 RRETURN; 1038 1033 } 1039 }1040 1034 /* Control never gets here */ 1041 1035 … … 1044 1038 1045 1039 BEGIN_OPCODE(XCLASS): 1046 {1047 1040 frame->data = frame->ecode + 1 + LINK_SIZE; /* Save for matching */ 1048 1041 frame->ecode += GET(frame->ecode, 1); /* Advance past the item */ … … 1130 1123 } 1131 1124 1132 /* Control never gets here */ 1133 } 1125 /* Control never gets here */ 1134 1126 1135 1127 /* Match a single character, casefully */ 1136 1128 1137 1129 BEGIN_OPCODE(CHAR): 1138 {1139 1130 frame->length = 1; 1140 1131 frame->ecode++; … … 1157 1148 if (frame->fc != dc) RRETURN_NO_MATCH; 1158 1149 } 1159 }1160 1150 NEXT_OPCODE; 1161 1151 … … 1163 1153 1164 1154 BEGIN_OPCODE(CHARNC): 1165 {1166 1155 frame->length = 1; 1167 1156 frame->ecode++; … … 1189 1178 } 1190 1179 } 1191 }1192 1180 NEXT_OPCODE; 1193 1181 … … 1218 1206 BEGIN_OPCODE(EXACT): 1219 1207 min = frame->max = GET2(frame->ecode, 1); 1220 minimize = FALSE;1208 minimize = false; 1221 1209 frame->ecode += 3; 1222 1210 goto REPEATCHAR; … … 1250 1238 frame->length = 1; 1251 1239 GETUTF8CHARLEN(frame->fc, frame->ecode, frame->length); 1252 {1253 1240 if (min * (frame->fc > 0xFFFF ? 2 : 1) > md->end_subject - frame->eptr) RRETURN_NO_MATCH; 1254 1241 frame->ecode += frame->length; … … 1349 1336 /* Control never gets here */ 1350 1337 } 1351 /* Control never gets here */ 1352 } 1338 /* Control never gets here */ 1353 1339 1354 1340 /* Match a negated single one-byte character. The character we are … … 1380 1366 BEGIN_OPCODE(NOTEXACT): 1381 1367 min = frame->max = GET2(frame->ecode, 1); 1382 minimize = FALSE;1368 minimize = false; 1383 1369 frame->ecode += 3; 1384 1370 goto REPEATNOTCHAR; … … 1556 1542 BEGIN_OPCODE(TYPEEXACT): 1557 1543 min = frame->max = GET2(frame->ecode, 1); 1558 minimize = TRUE;1544 minimize = true; 1559 1545 frame->ecode += 3; 1560 1546 goto REPEATTYPE; … … 1911 1897 #ifdef DEBUG 1912 1898 printf("start bracket %d subject=", frame->number); 1913 pchars(frame->eptr, 16, TRUE, md);1899 pchars(frame->eptr, 16, true, md); 1914 1900 printf("\n"); 1915 1901 #endif … … 2044 2030 int req_byte = -1; 2045 2031 int req_byte2 = -1; 2046 BOOL using_temporary_offsets = FALSE;2047 BOOL first_byte_caseless = FALSE;2032 BOOL using_temporary_offsets = false; 2033 BOOL first_byte_caseless = false; 2048 2034 BOOL startline; 2049 BOOL req_byte_caseless = FALSE;2035 BOOL req_byte_caseless = false; 2050 2036 match_data match_block; 2051 2037 USPTR start_match = (USPTR)subject + start_offset; … … 2094 2080 match_block.offset_vector = new int[ocount]; 2095 2081 if (match_block.offset_vector == NULL) return JSRegExpErrorNoMemory; 2096 using_temporary_offsets = TRUE;2082 using_temporary_offsets = true; 2097 2083 DPRINTF(("Got memory to hold back references\n")); 2098 2084 } … … 2101 2087 match_block.offset_end = ocount; 2102 2088 match_block.offset_max = (2*ocount)/3; 2103 match_block.offset_overflow = FALSE;2089 match_block.offset_overflow = false; 2104 2090 2105 2091 /* Compute the minimum number of offsets that we need to reset each time. Doing … … 2130 2116 { 2131 2117 first_byte = re->first_byte & 255; 2132 if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)2118 if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == true) 2133 2119 first_byte = match_block.lcc[first_byte]; 2134 2120 } … … 2160 2146 } 2161 2147 2162 /* Advance to a unique first char if possible. If firstline is TRUE, the2148 /* Advance to a unique first char if possible. If firstline is true, the 2163 2149 start of the match is constrained to the first line of a multiline string. 2164 2150 Implement this by temporarily adjusting end_subject so that we stop scanning … … 2203 2189 #ifdef DEBUG /* Sigh. Some compilers never learn. */ 2204 2190 printf(">>>> Match against: "); 2205 pchars(start_match, end_subject - start_match, TRUE, &match_block);2191 pchars(start_match, end_subject - start_match, true, &match_block); 2206 2192 printf("\n"); 2207 2193 #endif … … 2305 2291 } 2306 2292 if (match_block.end_offset_top > offsetcount) 2307 match_block.offset_overflow = TRUE;2293 match_block.offset_overflow = true; 2308 2294 2309 2295 DPRINTF(("Freeing temporary memory\n"));
Note:
See TracChangeset
for help on using the changeset viewer.