Changeset 34560 in webkit for trunk/JavaScriptCore/pcre/pcre_compile.cpp
- Timestamp:
- Jun 14, 2008, 11:23:50 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/pcre/pcre_compile.cpp
r31454 r34560 136 136 struct CompileData { 137 137 CompileData() { 138 top _backref = 0;138 topBackref = 0; 139 139 backrefMap = 0; 140 req _varyopt = 0;140 reqVaryOpt = 0; 141 141 needOuterBracket = false; 142 142 numCapturingBrackets = 0; 143 143 } 144 int top _backref; /* Maximum back reference */144 int topBackref; /* Maximum back reference */ 145 145 unsigned backrefMap; /* Bitmap of low back refs */ 146 int req _varyopt; /* "After variable item" flag for reqbyte */146 int reqVaryOpt; /* "After variable item" flag for reqByte */ 147 147 bool needOuterBracket; 148 148 int numCapturingBrackets; … … 167 167 168 168 Arguments: 169 ptr ptr points to the pattern position pointer170 error codeptr points to the errorcode variable169 ptrPtr points to the pattern position pointer 170 errorCodePtr points to the errorcode variable 171 171 bracount number of previous extracting brackets 172 172 options the options bits 173 is class true if inside a character class173 isClass true if inside a character class 174 174 175 175 Returns: zero or positive => a data character 176 176 negative => a special escape sequence 177 on error, error ptr is set177 on error, errorPtr is set 178 178 */ 179 179 180 static int checkEscape(const UChar** ptr ptr, const UChar* patternEnd, ErrorCode* errorcodeptr, int bracount, bool isclass)180 static int checkEscape(const UChar** ptrPtr, const UChar* patternEnd, ErrorCode* errorCodePtr, int bracount, bool isClass) 181 181 { 182 const UChar* ptr = *ptr ptr + 1;182 const UChar* ptr = *ptrPtr + 1; 183 183 184 184 /* If backslash is at the end of the pattern, it's an error. */ 185 185 if (ptr == patternEnd) { 186 *error codeptr = ERR1;187 *ptr ptr = ptr;186 *errorCodePtr = ERR1; 187 *ptrPtr = ptr; 188 188 return 0; 189 189 } … … 198 198 } else if (int escapeValue = escapes[c - '0']) { 199 199 c = escapeValue; 200 if (is class) {200 if (isClass) { 201 201 if (-c == ESC_b) 202 202 c = '\b'; /* \b is backslash in a class */ … … 222 222 or when we overflow 0-255, whichever comes first. */ 223 223 224 if (!is class) {224 if (!isClass) { 225 225 const UChar* oldptr = ptr; 226 226 c -= '0'; … … 296 296 case 'c': 297 297 if (++ptr == patternEnd) { 298 *error codeptr = ERR2;298 *errorCodePtr = ERR2; 299 299 return 0; 300 300 } … … 308 308 } 309 309 310 *ptr ptr = ptr;310 *ptrPtr = ptr; 311 311 return c; 312 312 } … … 364 364 maxp pointer to int for max 365 365 returned as -1 if no max 366 error codeptr points to error code variable366 errorCodePtr points to error code variable 367 367 368 368 Returns: pointer to '}' on success; 369 current ptr on error, with error codeptr set non-zero369 current ptr on error, with errorCodePtr set non-zero 370 370 */ 371 371 372 static const UChar* readRepeatCounts(const UChar* p, int* minp, int* maxp, ErrorCode* error codeptr)372 static const UChar* readRepeatCounts(const UChar* p, int* minp, int* maxp, ErrorCode* errorCodePtr) 373 373 { 374 374 int min = 0; … … 381 381 min = min * 10 + *p++ - '0'; 382 382 if (min < 0 || min > 65535) { 383 *error codeptr = ERR5;383 *errorCodePtr = ERR5; 384 384 return p; 385 385 } … … 396 396 max = max * 10 + *p++ - '0'; 397 397 if (max < 0 || max > 65535) { 398 *error codeptr = ERR5;398 *errorCodePtr = ERR5; 399 399 return p; 400 400 } 401 401 if (max < min) { 402 *error codeptr = ERR4;402 *errorCodePtr = ERR4; 403 403 return p; 404 404 } … … 538 538 options the option bits 539 539 brackets points to number of extracting brackets used 540 code ptr points to the pointer to the current code point541 ptr ptr points to the current pattern pointer542 error codeptr points to error code variable540 codePtr points to the pointer to the current code point 541 ptrPtr points to the current pattern pointer 542 errorCodePtr points to error code variable 543 543 firstbyteptr set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE) 544 544 reqbyteptr set to the last literal character required, else < 0 … … 546 546 547 547 Returns: true on success 548 false, with *error codeptr set non-zero on error548 false, with *errorCodePtr set non-zero on error 549 549 */ 550 550 … … 555 555 556 556 static bool 557 compileBranch(int options, int* brackets, unsigned char** code ptr,558 const UChar** ptr ptr, const UChar* patternEnd, ErrorCode* errorcodeptr, int *firstbyteptr,557 compileBranch(int options, int* brackets, unsigned char** codePtr, 558 const UChar** ptrPtr, const UChar* patternEnd, ErrorCode* errorCodePtr, int *firstbyteptr, 559 559 int* reqbyteptr, CompileData& cd) 560 560 { 561 int repeat _type, op_type;562 int repeat _min = 0, repeat_max = 0; /* To please picky compilers */561 int repeatType, opType; 562 int repeatMin = 0, repeat_max = 0; /* To please picky compilers */ 563 563 int bravalue = 0; 564 564 int reqvary, tempreqvary; 565 565 int c; 566 unsigned char* code = *code ptr;566 unsigned char* code = *codePtr; 567 567 unsigned char* tempcode; 568 bool groupsetfirstbyte = false;569 const UChar* ptr = *ptr ptr;568 bool didGroupSetFirstByte = false; 569 const UChar* ptr = *ptrPtr; 570 570 const UChar* tempptr; 571 571 unsigned char* previous = NULL; … … 578 578 /* Initialize no first byte, no required byte. REQ_UNSET means "no char 579 579 matching encountered yet". It gets changed to REQ_NONE if we hit something that 580 matches a non-fixed char first char; req byte just remains unset if we never580 matches a non-fixed char first char; reqByte just remains unset if we never 581 581 find one. 582 582 583 583 When we hit a repeat whose minimum is zero, we may have to adjust these values 584 584 to take the zero repeat into account. This is implemented by setting them to 585 zero firstbyte and zeroreqbyte when such a repeat is encountered. The individual585 zeroFirstByte and zeroReqByte when such a repeat is encountered. The individual 586 586 item types that can be repeated set these backoff variables appropriately. */ 587 587 588 int first byte = REQ_UNSET;589 int req byte = REQ_UNSET;590 int zero reqbyte = REQ_UNSET;591 int zero firstbyte = REQ_UNSET;592 593 /* The variable req _caseopt contains either the REQ_IGNORE_CASE value or zero,588 int firstByte = REQ_UNSET; 589 int reqByte = REQ_UNSET; 590 int zeroReqByte = REQ_UNSET; 591 int zeroFirstByte = REQ_UNSET; 592 593 /* The variable reqCaseOpt contains either the REQ_IGNORE_CASE value or zero, 594 594 according to the current setting of the ignores-case flag. REQ_IGNORE_CASE is a bit 595 value > 255. It is added into the first byte or reqbyte variables to record the595 value > 255. It is added into the firstByte or reqByte variables to record the 596 596 case status of the value. This is used only for ASCII characters. */ 597 597 598 int req _caseopt = (options & IgnoreCaseOption) ? REQ_IGNORE_CASE : 0;598 int reqCaseOpt = (options & IgnoreCaseOption) ? REQ_IGNORE_CASE : 0; 599 599 600 600 /* Switch on next character until the end of the branch */ 601 601 602 602 for (;; ptr++) { 603 bool negate _class;604 bool should _flip_negation; /* If a negative special such as \S is used, we should negate the whole class to properly support Unicode. */605 int class _charcount;606 int class _lastchar;607 int skip bytes;608 int sub reqbyte;609 int sub firstbyte;610 int mc length;603 bool negateClass; 604 bool shouldFlipNegation; /* If a negative special such as \S is used, we should negate the whole class to properly support Unicode. */ 605 int classCharCount; 606 int classLastChar; 607 int skipBytes; 608 int subReqByte; 609 int subFirstByte; 610 int mcLength; 611 611 unsigned char mcbuffer[8]; 612 612 … … 618 618 a quantifier. */ 619 619 620 bool is _quantifier = c == '*' || c == '+' || c == '?' || (c == '{' && isCountedRepeat(ptr + 1, patternEnd));620 bool isQuantifier = c == '*' || c == '+' || c == '?' || (c == '{' && isCountedRepeat(ptr + 1, patternEnd)); 621 621 622 622 switch (c) { … … 629 629 case '|': 630 630 case ')': 631 *firstbyteptr = first byte;632 *reqbyteptr = req byte;633 *code ptr = code;634 *ptr ptr = ptr;631 *firstbyteptr = firstByte; 632 *reqbyteptr = reqByte; 633 *codePtr = code; 634 *ptrPtr = ptr; 635 635 return true; 636 636 … … 640 640 case '^': 641 641 if (options & MatchAcrossMultipleLinesOption) { 642 if (first byte == REQ_UNSET)643 first byte = REQ_NONE;642 if (firstByte == REQ_UNSET) 643 firstByte = REQ_NONE; 644 644 *code++ = OP_BOL; 645 645 } else … … 657 657 658 658 /* There can never be a first char if '.' is first, whatever happens about 659 repeats. The value of req byte doesn't change either. */659 repeats. The value of reqByte doesn't change either. */ 660 660 661 661 case '.': 662 if (first byte == REQ_UNSET)663 first byte = REQ_NONE;664 zero firstbyte = firstbyte;665 zero reqbyte = reqbyte;662 if (firstByte == REQ_UNSET) 663 firstByte = REQ_NONE; 664 zeroFirstByte = firstByte; 665 zeroReqByte = reqByte; 666 666 previous = code; 667 667 *code++ = OP_NOT_NEWLINE; … … 682 682 case '[': { 683 683 previous = code; 684 should _flip_negation = false;684 shouldFlipNegation = false; 685 685 686 686 /* PCRE supports POSIX class stuff inside a class. Perl gives an error if … … 690 690 691 691 if (ptr + 1 >= patternEnd) { 692 *error codeptr = ERR6;692 *errorCodePtr = ERR6; 693 693 return false; 694 694 } 695 695 696 696 if (ptr[1] == '^') { 697 negate _class = true;697 negateClass = true; 698 698 ++ptr; 699 699 } else 700 negate _class = false;700 negateClass = false; 701 701 702 702 /* Keep a count of chars with values < 256 so that we can optimize the case … … 704 704 characters, we don't yet do any optimization. */ 705 705 706 class _charcount = 0;707 class _lastchar = -1;706 classCharCount = 0; 707 classLastChar = -1; 708 708 709 709 class_utf8 = false; /* No chars >= 256 */ … … 729 729 it marks a word boundary. Other escapes have preset maps ready to 730 730 or into the one we are building. We assume they have more than one 731 character in them, so set class _charcount bigger than one. */731 character in them, so set classCharCount bigger than one. */ 732 732 733 733 if (c == '\\') { 734 c = checkEscape(&ptr, patternEnd, error codeptr, cd.numCapturingBrackets, true);734 c = checkEscape(&ptr, patternEnd, errorCodePtr, cd.numCapturingBrackets, true); 735 735 if (c < 0) { 736 class _charcount += 2; /* Greater than 1 is what matters */736 classCharCount += 2; /* Greater than 1 is what matters */ 737 737 switch (-c) { 738 738 case ESC_d: … … 742 742 743 743 case ESC_D: 744 should _flip_negation = true;744 shouldFlipNegation = true; 745 745 for (c = 0; c < 32; c++) 746 746 classbits[c] |= ~classBitmapForChar(c + cbit_digit); … … 753 753 754 754 case ESC_W: 755 should _flip_negation = true;755 shouldFlipNegation = true; 756 756 for (c = 0; c < 32; c++) 757 757 classbits[c] |= ~classBitmapForChar(c + cbit_word); … … 764 764 765 765 case ESC_S: 766 should _flip_negation = true;766 shouldFlipNegation = true; 767 767 for (c = 0; c < 32; c++) 768 768 classbits[c] |= ~classBitmapForChar(c + cbit_space); … … 775 775 default: 776 776 c = *ptr; /* The final character */ 777 class _charcount -= 2; /* Undo the default count from above */777 classCharCount -= 2; /* Undo the default count from above */ 778 778 } 779 779 } … … 799 799 if (d == '\\') { 800 800 const UChar* oldptr = ptr; 801 d = checkEscape(&ptr, patternEnd, error codeptr, cd.numCapturingBrackets, true);801 d = checkEscape(&ptr, patternEnd, errorCodePtr, cd.numCapturingBrackets, true); 802 802 803 803 /* \X is literal X; any other special means the '-' was literal */ … … 879 879 classbits[uc/8] |= (1 << (uc&7)); 880 880 } 881 class _charcount++; /* in case a one-char range */882 class _lastchar = c;881 classCharCount++; /* in case a one-char range */ 882 classLastChar = c; 883 883 } 884 884 … … 913 913 classbits[c/8] |= (1 << (c&7)); 914 914 } 915 class _charcount++;916 class _lastchar = c;917 } 918 } 919 920 /* If class _charcount is 1, we saw precisely one character whose value is915 classCharCount++; 916 classLastChar = c; 917 } 918 } 919 920 /* If classCharCount is 1, we saw precisely one character whose value is 921 921 less than 256. In non-UTF-8 mode we can always optimize. In UTF-8 mode, we 922 922 can optimize the negative case only if there were no characters >= 128 … … 928 928 1-character OP_CHAR[NC] if it's positive, or OP_NOT if it's negative. Note 929 929 that OP_NOT does not support multibyte characters. In the positive case, it 930 can cause first byte to be set. Otherwise, there can be no first char if930 can cause firstByte to be set. Otherwise, there can be no first char if 931 931 this item is first, whatever repeat count may follow. In the case of 932 req byte, save the previous value for reinstating. */933 934 if (class _charcount == 1 && (!class_utf8 && (!negate_class || class_lastchar < 128))) {935 zero reqbyte = reqbyte;932 reqByte, save the previous value for reinstating. */ 933 934 if (classCharCount == 1 && (!class_utf8 && (!negateClass || classLastChar < 128))) { 935 zeroReqByte = reqByte; 936 936 937 937 /* The OP_NOT opcode works on one-byte characters only. */ 938 938 939 if (negate _class) {940 if (first byte == REQ_UNSET)941 first byte = REQ_NONE;942 zero firstbyte = firstbyte;939 if (negateClass) { 940 if (firstByte == REQ_UNSET) 941 firstByte = REQ_NONE; 942 zeroFirstByte = firstByte; 943 943 *code++ = OP_NOT; 944 *code++ = class _lastchar;944 *code++ = classLastChar; 945 945 break; 946 946 } … … 949 949 then we can handle this with the normal one-character code. */ 950 950 951 c = class _lastchar;951 c = classLastChar; 952 952 goto NORMAL_CHAR; 953 953 } /* End of 1-char optimization */ … … 955 955 /* The general case - not the one-char optimization. If this is the first 956 956 thing in the branch, there can be no first char setting, whatever the 957 repeat count. Any req byte setting must remain unchanged after any kind of957 repeat count. Any reqByte setting must remain unchanged after any kind of 958 958 repeat. */ 959 959 960 if (first byte == REQ_UNSET) firstbyte = REQ_NONE;961 zero firstbyte = firstbyte;962 zero reqbyte = reqbyte;960 if (firstByte == REQ_UNSET) firstByte = REQ_NONE; 961 zeroFirstByte = firstByte; 962 zeroReqByte = reqByte; 963 963 964 964 /* If there are characters with values > 255, we have to compile an … … 966 966 we can omit the bitmap. */ 967 967 968 if (class_utf8 && !should _flip_negation) {968 if (class_utf8 && !shouldFlipNegation) { 969 969 *class_utf8data++ = XCL_END; /* Marks the end of extra data */ 970 970 *code++ = OP_XCLASS; 971 971 code += LINK_SIZE; 972 *code = negate _class? XCL_NOT : 0;972 *code = negateClass? XCL_NOT : 0; 973 973 974 974 /* If the map is required, install it, and move on to the end of 975 975 the extra data */ 976 976 977 if (class _charcount > 0) {977 if (classCharCount > 0) { 978 978 *code++ |= XCL_MAP; 979 979 memcpy(code, classbits, 32); … … 997 997 /* If there are no characters > 255, negate the 32-byte map if necessary, 998 998 and copy it into the code vector. If this is the first thing in the branch, 999 there can be no first char setting, whatever the repeat count. Any req byte999 there can be no first char setting, whatever the repeat count. Any reqByte 1000 1000 setting must remain unchanged after any kind of repeat. */ 1001 1001 1002 *code++ = (negate _class == should_flip_negation) ? OP_CLASS : OP_NCLASS;1003 if (negate _class)1002 *code++ = (negateClass == shouldFlipNegation) ? OP_CLASS : OP_NCLASS; 1003 if (negateClass) 1004 1004 for (c = 0; c < 32; c++) 1005 1005 code[c] = ~classbits[c]; … … 1014 1014 1015 1015 case '{': 1016 if (!is _quantifier)1016 if (!isQuantifier) 1017 1017 goto NORMAL_CHAR; 1018 ptr = readRepeatCounts(ptr + 1, &repeat _min, &repeat_max, errorcodeptr);1019 if (*error codeptr)1018 ptr = readRepeatCounts(ptr + 1, &repeatMin, &repeat_max, errorCodePtr); 1019 if (*errorCodePtr) 1020 1020 goto FAILED; 1021 1021 goto REPEAT; 1022 1022 1023 1023 case '*': 1024 repeat _min = 0;1024 repeatMin = 0; 1025 1025 repeat_max = -1; 1026 1026 goto REPEAT; 1027 1027 1028 1028 case '+': 1029 repeat _min = 1;1029 repeatMin = 1; 1030 1030 repeat_max = -1; 1031 1031 goto REPEAT; 1032 1032 1033 1033 case '?': 1034 repeat _min = 0;1034 repeatMin = 0; 1035 1035 repeat_max = 1; 1036 1036 1037 1037 REPEAT: 1038 1038 if (!previous) { 1039 *error codeptr = ERR9;1039 *errorCodePtr = ERR9; 1040 1040 goto FAILED; 1041 1041 } 1042 1042 1043 if (repeat _min == 0) {1044 first byte = zerofirstbyte; /* Adjust for zero repeat */1045 req byte = zeroreqbyte; /* Ditto */1043 if (repeatMin == 0) { 1044 firstByte = zeroFirstByte; /* Adjust for zero repeat */ 1045 reqByte = zeroReqByte; /* Ditto */ 1046 1046 } 1047 1047 1048 1048 /* Remember whether this is a variable length repeat */ 1049 1049 1050 reqvary = (repeat _min == repeat_max) ? 0 : REQ_VARY;1051 1052 op _type = 0; /* Default single-char op codes */1050 reqvary = (repeatMin == repeat_max) ? 0 : REQ_VARY; 1051 1052 opType = 0; /* Default single-char op codes */ 1053 1053 1054 1054 /* Save start of previous item, in case we have to move it up to make space … … 1065 1065 1066 1066 if (safelyCheckNextChar(ptr, patternEnd, '?')) { 1067 repeat _type = 1;1067 repeatType = 1; 1068 1068 ptr++; 1069 1069 } else 1070 repeat _type = 0;1070 repeatType = 0; 1071 1071 1072 1072 /* If previous was a character match, abolish the item and generate a 1073 1073 repeat item instead. If a char item has a minumum of more than one, ensure 1074 that it is set in req byte - it might not be if a sequence such as x{3} is1075 the first thing in a branch because the x will have gone into first byte1074 that it is set in reqByte - it might not be if a sequence such as x{3} is 1075 the first thing in a branch because the x will have gone into firstByte 1076 1076 instead. */ 1077 1077 … … 1092 1092 else { 1093 1093 c = code[-1]; 1094 if (repeat _min > 1)1095 req byte = c | req_caseopt | cd.req_varyopt;1094 if (repeatMin > 1) 1095 reqByte = c | reqCaseOpt | cd.reqVaryOpt; 1096 1096 } 1097 1097 … … 1101 1101 else if (*previous == OP_ASCII_CHAR || *previous == OP_ASCII_LETTER_IGNORING_CASE) { 1102 1102 c = previous[1]; 1103 if (repeat _min > 1)1104 req byte = c | req_caseopt | cd.req_varyopt;1103 if (repeatMin > 1) 1104 reqByte = c | reqCaseOpt | cd.reqVaryOpt; 1105 1105 goto OUTPUT_SINGLE_REPEAT; 1106 1106 } … … 1109 1109 one of the special opcodes, replacing it. The code is shared with single- 1110 1110 character repeats by setting opt_type to add a suitable offset into 1111 repeat _type. OP_NOT is currently used only for single-byte chars. */1111 repeatType. OP_NOT is currently used only for single-byte chars. */ 1112 1112 1113 1113 else if (*previous == OP_NOT) { 1114 op _type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */1114 opType = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */ 1115 1115 c = previous[1]; 1116 1116 goto OUTPUT_SINGLE_REPEAT; … … 1119 1119 /* If previous was a character type match (\d or similar), abolish it and 1120 1120 create a suitable repeat item. The code is shared with single-character 1121 repeats by setting op _type to add a suitable offset into repeat_type. */1121 repeats by setting opType to add a suitable offset into repeatType. */ 1122 1122 1123 1123 else if (*previous <= OP_NOT_NEWLINE) { 1124 op _type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */1124 opType = OP_TYPESTAR - OP_STAR; /* Use type opcodes */ 1125 1125 c = *previous; 1126 1126 … … 1138 1138 goto END_REPEAT; 1139 1139 1140 /* Combine the op _type with the repeat_type */1141 1142 repeat _type += op_type;1140 /* Combine the opType with the repeatType */ 1141 1142 repeatType += opType; 1143 1143 1144 1144 /* A minimum of zero is handled either as the special case * or ?, or as 1145 1145 an UPTO, with the maximum given. */ 1146 1146 1147 if (repeat _min == 0) {1147 if (repeatMin == 0) { 1148 1148 if (repeat_max == -1) 1149 *code++ = OP_STAR + repeat _type;1149 *code++ = OP_STAR + repeatType; 1150 1150 else if (repeat_max == 1) 1151 *code++ = OP_QUERY + repeat _type;1151 *code++ = OP_QUERY + repeatType; 1152 1152 else { 1153 *code++ = OP_UPTO + repeat _type;1153 *code++ = OP_UPTO + repeatType; 1154 1154 put2ByteValueAndAdvance(code, repeat_max); 1155 1155 } … … 1161 1161 one less than the maximum. */ 1162 1162 1163 else if (repeat _min == 1) {1163 else if (repeatMin == 1) { 1164 1164 if (repeat_max == -1) 1165 *code++ = OP_PLUS + repeat _type;1165 *code++ = OP_PLUS + repeatType; 1166 1166 else { 1167 1167 code = oldcode; /* leave previous item in place */ 1168 1168 if (repeat_max == 1) 1169 1169 goto END_REPEAT; 1170 *code++ = OP_UPTO + repeat _type;1170 *code++ = OP_UPTO + repeatType; 1171 1171 put2ByteValueAndAdvance(code, repeat_max - 1); 1172 1172 } … … 1177 1177 1178 1178 else { 1179 *code++ = OP_EXACT + op _type; /* NB EXACT doesn't have repeat_type */1180 put2ByteValueAndAdvance(code, repeat _min);1179 *code++ = OP_EXACT + opType; /* NB EXACT doesn't have repeatType */ 1180 put2ByteValueAndAdvance(code, repeatMin); 1181 1181 1182 1182 /* If the maximum is unlimited, insert an OP_STAR. Before doing so, … … 1197 1197 } 1198 1198 } 1199 *code++ = OP_STAR + repeat _type;1199 *code++ = OP_STAR + repeatType; 1200 1200 } 1201 1201 … … 1203 1203 preceded by the character, for the previously inserted code. */ 1204 1204 1205 else if (repeat_max != repeat _min) {1205 else if (repeat_max != repeatMin) { 1206 1206 if (c >= 128) { 1207 1207 memcpy(code, utf8_char, c & 7); … … 1213 1213 *code++ = prop_value; 1214 1214 } 1215 repeat_max -= repeat _min;1216 *code++ = OP_UPTO + repeat _type;1215 repeat_max -= repeatMin; 1216 *code++ = OP_UPTO + repeatType; 1217 1217 put2ByteValueAndAdvance(code, repeat_max); 1218 1218 } … … 1249 1249 } 1250 1250 1251 if (repeat _min == 0 && repeat_max == -1)1252 *code++ = OP_CRSTAR + repeat _type;1253 else if (repeat _min == 1 && repeat_max == -1)1254 *code++ = OP_CRPLUS + repeat _type;1255 else if (repeat _min == 0 && repeat_max == 1)1256 *code++ = OP_CRQUERY + repeat _type;1251 if (repeatMin == 0 && repeat_max == -1) 1252 *code++ = OP_CRSTAR + repeatType; 1253 else if (repeatMin == 1 && repeat_max == -1) 1254 *code++ = OP_CRPLUS + repeatType; 1255 else if (repeatMin == 0 && repeat_max == 1) 1256 *code++ = OP_CRQUERY + repeatType; 1257 1257 else { 1258 *code++ = OP_CRRANGE + repeat _type;1259 put2ByteValueAndAdvance(code, repeat _min);1258 *code++ = OP_CRRANGE + repeatType; 1259 put2ByteValueAndAdvance(code, repeatMin); 1260 1260 if (repeat_max == -1) 1261 1261 repeat_max = 0; /* 2-byte encoding for max */ … … 1291 1291 minimum is zero. */ 1292 1292 1293 if (repeat _min == 0) {1293 if (repeatMin == 0) { 1294 1294 /* If the maximum is also zero, we just omit the group from the output 1295 1295 altogether. */ … … 1310 1310 memmove(previous+1, previous, len); 1311 1311 code++; 1312 *previous++ = OP_BRAZERO + repeat _type;1312 *previous++ = OP_BRAZERO + repeatType; 1313 1313 } 1314 1314 … … 1324 1324 memmove(previous + 2 + LINK_SIZE, previous, len); 1325 1325 code += 2 + LINK_SIZE; 1326 *previous++ = OP_BRAZERO + repeat _type;1326 *previous++ = OP_BRAZERO + repeatType; 1327 1327 *previous++ = OP_BRA; 1328 1328 … … 1344 1344 1345 1345 else { 1346 if (repeat _min > 1) {1347 if ( groupsetfirstbyte && reqbyte < 0)1348 req byte = firstbyte;1349 for (int i = 1; i < repeat _min; i++) {1346 if (repeatMin > 1) { 1347 if (didGroupSetFirstByte && reqByte < 0) 1348 reqByte = firstByte; 1349 for (int i = 1; i < repeatMin; i++) { 1350 1350 memcpy(code, previous, len); 1351 1351 code += len; … … 1353 1353 } 1354 1354 if (repeat_max > 0) 1355 repeat_max -= repeat _min;1355 repeat_max -= repeatMin; 1356 1356 } 1357 1357 … … 1364 1364 if (repeat_max >= 0) { 1365 1365 for (int i = repeat_max - 1; i >= 0; i--) { 1366 *code++ = OP_BRAZERO + repeat _type;1366 *code++ = OP_BRAZERO + repeatType; 1367 1367 1368 1368 /* All but the final copy start a new nesting, maintaining the … … 1400 1400 1401 1401 else 1402 code[-ketoffset] = OP_KETRMAX + repeat _type;1402 code[-ketoffset] = OP_KETRMAX + repeatType; 1403 1403 } 1404 1404 … … 1406 1406 1407 1407 else { 1408 *error codeptr = ERR11;1408 *errorCodePtr = ERR11; 1409 1409 goto FAILED; 1410 1410 } … … 1416 1416 END_REPEAT: 1417 1417 previous = NULL; 1418 cd.req _varyopt |= reqvary;1418 cd.reqVaryOpt |= reqvary; 1419 1419 break; 1420 1420 … … 1427 1427 1428 1428 case '(': 1429 skip bytes = 0;1429 skipBytes = 0; 1430 1430 1431 1431 if (*(++ptr) == '?') { … … 1449 1449 1450 1450 default: 1451 *error codeptr = ERR12;1451 *errorCodePtr = ERR12; 1452 1452 goto FAILED; 1453 1453 } … … 1463 1463 code[1 + LINK_SIZE] = OP_BRANUMBER; 1464 1464 put2ByteValue(code + 2 + LINK_SIZE, *brackets); 1465 skip bytes = 3;1465 skipBytes = 3; 1466 1466 } 1467 1467 else … … 1477 1477 *code = bravalue; 1478 1478 tempcode = code; 1479 tempreqvary = cd.req _varyopt; /* Save value before bracket */1479 tempreqvary = cd.reqVaryOpt; /* Save value before bracket */ 1480 1480 1481 1481 if (!compileBracket( … … 1485 1485 &ptr, /* Input pointer (updated) */ 1486 1486 patternEnd, 1487 error codeptr, /* Where to put an error message */1488 skip bytes, /* Skip over OP_BRANUMBER */1489 &sub firstbyte, /* For possible first char */1490 &sub reqbyte, /* For possible last char */1487 errorCodePtr, /* Where to put an error message */ 1488 skipBytes, /* Skip over OP_BRANUMBER */ 1489 &subFirstByte, /* For possible first char */ 1490 &subReqByte, /* For possible last char */ 1491 1491 cd)) /* Tables block */ 1492 1492 goto FAILED; … … 1500 1500 brackets of all kinds, and conditions with two branches (see code above). 1501 1501 If the bracket is followed by a quantifier with zero repeat, we have to 1502 back off. Hence the definition of zero reqbyte and zerofirstbyte outside the1502 back off. Hence the definition of zeroReqByte and zeroFirstByte outside the 1503 1503 main loop so that they can be accessed for the back off. */ 1504 1504 1505 zero reqbyte = reqbyte;1506 zero firstbyte = firstbyte;1507 groupsetfirstbyte = false;1505 zeroReqByte = reqByte; 1506 zeroFirstByte = firstByte; 1507 didGroupSetFirstByte = false; 1508 1508 1509 1509 if (bravalue >= OP_BRA) { 1510 /* If we have not yet set a first byte in this branch, take it from the1510 /* If we have not yet set a firstByte in this branch, take it from the 1511 1511 subpattern, remembering that it was set here so that a repeat of more 1512 than one can replicate it as req byte if necessary. If the subpattern has1513 no first byte, set "none" for the whole branch. In both cases, a zero1514 repeat forces first byte to "none". */1515 1516 if (first byte == REQ_UNSET) {1517 if (sub firstbyte >= 0) {1518 first byte = subfirstbyte;1519 groupsetfirstbyte = true;1512 than one can replicate it as reqByte if necessary. If the subpattern has 1513 no firstByte, set "none" for the whole branch. In both cases, a zero 1514 repeat forces firstByte to "none". */ 1515 1516 if (firstByte == REQ_UNSET) { 1517 if (subFirstByte >= 0) { 1518 firstByte = subFirstByte; 1519 didGroupSetFirstByte = true; 1520 1520 } 1521 1521 else 1522 first byte = REQ_NONE;1523 zero firstbyte = REQ_NONE;1524 } 1525 1526 /* If first byte was previously set, convert the subpattern's firstbyte1527 into req byte if there wasn't one, using the vary flag that was in1522 firstByte = REQ_NONE; 1523 zeroFirstByte = REQ_NONE; 1524 } 1525 1526 /* If firstByte was previously set, convert the subpattern's firstByte 1527 into reqByte if there wasn't one, using the vary flag that was in 1528 1528 existence beforehand. */ 1529 1529 1530 else if (sub firstbyte >= 0 && subreqbyte < 0)1531 sub reqbyte = subfirstbyte | tempreqvary;1530 else if (subFirstByte >= 0 && subReqByte < 0) 1531 subReqByte = subFirstByte | tempreqvary; 1532 1532 1533 1533 /* If the subpattern set a required byte (or set a first byte that isn't 1534 1534 really the first byte - see above), set it. */ 1535 1535 1536 if (sub reqbyte >= 0)1537 req byte = subreqbyte;1538 } 1539 1540 /* For a forward assertion, we take the req byte, if set. This can be1536 if (subReqByte >= 0) 1537 reqByte = subReqByte; 1538 } 1539 1540 /* For a forward assertion, we take the reqByte, if set. This can be 1541 1541 helpful if the pattern that follows the assertion doesn't set a different 1542 char. For example, it's useful for /(?=abcde).+/. We can't set first byte1542 char. For example, it's useful for /(?=abcde).+/. We can't set firstByte 1543 1543 for an assertion, however because it leads to incorrect effect for patterns 1544 such as /(?=a)a.+/ when the "real" "a" would then become a req byte instead1545 of a first byte. This is overcome by a scan at the end if there's no1546 first byte, looking for an asserted first char. */1547 1548 else if (bravalue == OP_ASSERT && sub reqbyte >= 0)1549 req byte = subreqbyte;1544 such as /(?=a)a.+/ when the "real" "a" would then become a reqByte instead 1545 of a firstByte. This is overcome by a scan at the end if there's no 1546 firstByte, looking for an asserted first char. */ 1547 1548 else if (bravalue == OP_ASSERT && subReqByte >= 0) 1549 reqByte = subReqByte; 1550 1550 1551 1551 /* Now update the main code pointer to the end of the group. */ … … 1556 1556 1557 1557 if (ptr >= patternEnd || *ptr != ')') { 1558 *error codeptr = ERR14;1558 *errorCodePtr = ERR14; 1559 1559 goto FAILED; 1560 1560 } … … 1567 1567 case '\\': 1568 1568 tempptr = ptr; 1569 c = checkEscape(&ptr, patternEnd, error codeptr, cd.numCapturingBrackets, false);1569 c = checkEscape(&ptr, patternEnd, errorCodePtr, cd.numCapturingBrackets, false); 1570 1570 1571 1571 /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values … … 1580 1580 setting of a first character if it hasn't already been set. */ 1581 1581 1582 if (first byte == REQ_UNSET && -c > ESC_b && -c <= ESC_w)1583 first byte = REQ_NONE;1582 if (firstByte == REQ_UNSET && -c > ESC_b && -c <= ESC_w) 1583 firstByte = REQ_NONE; 1584 1584 1585 1585 /* Set values to reset to if this is followed by a zero repeat. */ 1586 1586 1587 zero firstbyte = firstbyte;1588 zero reqbyte = reqbyte;1587 zeroFirstByte = firstByte; 1588 zeroReqByte = reqByte; 1589 1589 1590 1590 /* Back references are handled specially */ … … 1619 1619 1620 1620 if (c < 128) { 1621 mc length = 1;1621 mcLength = 1; 1622 1622 mcbuffer[0] = c; 1623 1623 … … 1630 1630 } 1631 1631 } else { 1632 mc length = encodeUTF8(c, mcbuffer);1632 mcLength = encodeUTF8(c, mcbuffer); 1633 1633 1634 1634 *code++ = (options & IgnoreCaseOption) ? OP_CHAR_IGNORING_CASE : OP_CHAR; 1635 for (c = 0; c < mc length; c++)1635 for (c = 0; c < mcLength; c++) 1636 1636 *code++ = mcbuffer[c]; 1637 1637 } … … 1639 1639 /* Set the first and required bytes appropriately. If no previous first 1640 1640 byte, set it from this character, but revert to none on a zero repeat. 1641 Otherwise, leave the first byte value alone, and don't change it on a zero1641 Otherwise, leave the firstByte value alone, and don't change it on a zero 1642 1642 repeat. */ 1643 1643 1644 if (first byte == REQ_UNSET) {1645 zero firstbyte = REQ_NONE;1646 zero reqbyte = reqbyte;1647 1648 /* If the character is more than one byte long, we can set first byte1644 if (firstByte == REQ_UNSET) { 1645 zeroFirstByte = REQ_NONE; 1646 zeroReqByte = reqByte; 1647 1648 /* If the character is more than one byte long, we can set firstByte 1649 1649 only if it is not to be matched caselessly. */ 1650 1650 1651 if (mc length == 1 || req_caseopt == 0) {1652 first byte = mcbuffer[0] | req_caseopt;1653 if (mc length != 1)1654 req byte = code[-1] | cd.req_varyopt;1651 if (mcLength == 1 || reqCaseOpt == 0) { 1652 firstByte = mcbuffer[0] | reqCaseOpt; 1653 if (mcLength != 1) 1654 reqByte = code[-1] | cd.reqVaryOpt; 1655 1655 } 1656 1656 else 1657 first byte = reqbyte = REQ_NONE;1658 } 1659 1660 /* first byte was previously set; we can set reqbyte only the length is1657 firstByte = reqByte = REQ_NONE; 1658 } 1659 1660 /* firstByte was previously set; we can set reqByte only the length is 1661 1661 1 or the matching is caseful. */ 1662 1662 1663 1663 else { 1664 zero firstbyte = firstbyte;1665 zero reqbyte = reqbyte;1666 if (mc length == 1 || req_caseopt == 0)1667 req byte = code[-1] | req_caseopt | cd.req_varyopt;1664 zeroFirstByte = firstByte; 1665 zeroReqByte = reqByte; 1666 if (mcLength == 1 || reqCaseOpt == 0) 1667 reqByte = code[-1] | reqCaseOpt | cd.reqVaryOpt; 1668 1668 } 1669 1669 … … 1677 1677 1678 1678 FAILED: 1679 *ptr ptr = ptr;1679 *ptrPtr = ptr; 1680 1680 return false; 1681 1681 } … … 1696 1696 options option bits, including any changes for this subpattern 1697 1697 brackets -> int containing the number of extracting brackets used 1698 code ptr -> the address of the current code pointer1699 ptr ptr -> the address of the current pattern pointer1700 error codeptr -> pointer to error code variable1701 skip bytes skip this many bytes at start (for OP_BRANUMBER)1698 codePtr -> the address of the current code pointer 1699 ptrPtr -> the address of the current pattern pointer 1700 errorCodePtr -> pointer to error code variable 1701 skipBytes skip this many bytes at start (for OP_BRANUMBER) 1702 1702 firstbyteptr place to put the first required character, or a negative number 1703 1703 reqbyteptr place to put the last required character, or a negative number … … 1708 1708 1709 1709 static bool 1710 compileBracket(int options, int* brackets, unsigned char** code ptr,1711 const UChar** ptr ptr, const UChar* patternEnd, ErrorCode* errorcodeptr, int skipbytes,1710 compileBracket(int options, int* brackets, unsigned char** codePtr, 1711 const UChar** ptrPtr, const UChar* patternEnd, ErrorCode* errorCodePtr, int skipBytes, 1712 1712 int* firstbyteptr, int* reqbyteptr, CompileData& cd) 1713 1713 { 1714 const UChar* ptr = *ptr ptr;1715 unsigned char* code = *code ptr;1716 unsigned char* last _branch = code;1714 const UChar* ptr = *ptrPtr; 1715 unsigned char* code = *codePtr; 1716 unsigned char* lastBranch = code; 1717 1717 unsigned char* start_bracket = code; 1718 int first byte = REQ_UNSET;1719 int req byte = REQ_UNSET;1718 int firstByte = REQ_UNSET; 1719 int reqByte = REQ_UNSET; 1720 1720 1721 1721 /* Offset is set zero to mark that this bracket is still open */ 1722 1722 1723 1723 putLinkValueAllowZero(code + 1, 0); 1724 code += 1 + LINK_SIZE + skip bytes;1724 code += 1 + LINK_SIZE + skipBytes; 1725 1725 1726 1726 /* Loop for each alternative branch */ … … 1729 1729 /* Now compile the branch */ 1730 1730 1731 int branch firstbyte;1732 int branch reqbyte;1733 if (!compileBranch(options, brackets, &code, &ptr, patternEnd, error codeptr,1734 &branch firstbyte, &branchreqbyte, cd)) {1735 *ptr ptr = ptr;1731 int branchFirstByte; 1732 int branchReqByte; 1733 if (!compileBranch(options, brackets, &code, &ptr, patternEnd, errorCodePtr, 1734 &branchFirstByte, &branchReqByte, cd)) { 1735 *ptrPtr = ptr; 1736 1736 return false; 1737 1737 } 1738 1738 1739 /* If this is the first branch, the first byte and reqbyte values for the1739 /* If this is the first branch, the firstByte and reqByte values for the 1740 1740 branch become the values for the regex. */ 1741 1741 1742 if (*last _branch != OP_ALT) {1743 first byte = branchfirstbyte;1744 req byte = branchreqbyte;1742 if (*lastBranch != OP_ALT) { 1743 firstByte = branchFirstByte; 1744 reqByte = branchReqByte; 1745 1745 } 1746 1746 1747 /* If this is not the first branch, the first char and req byte have to1747 /* If this is not the first branch, the first char and reqByte have to 1748 1748 match the values from all the previous branches, except that if the previous 1749 value for req byte didn't have REQ_VARY set, it can still match, and we set1749 value for reqByte didn't have REQ_VARY set, it can still match, and we set 1750 1750 REQ_VARY for the regex. */ 1751 1751 1752 1752 else { 1753 /* If we previously had a first byte, but it doesn't match the new branch,1754 we have to abandon the first byte for the regex, but if there was previously1755 no req byte, it takes on the value of the old firstbyte. */1753 /* If we previously had a firstByte, but it doesn't match the new branch, 1754 we have to abandon the firstByte for the regex, but if there was previously 1755 no reqByte, it takes on the value of the old firstByte. */ 1756 1756 1757 if (first byte >= 0 && firstbyte != branchfirstbyte) {1758 if (req byte < 0)1759 req byte = firstbyte;1760 first byte = REQ_NONE;1757 if (firstByte >= 0 && firstByte != branchFirstByte) { 1758 if (reqByte < 0) 1759 reqByte = firstByte; 1760 firstByte = REQ_NONE; 1761 1761 } 1762 1762 1763 /* If we (now or from before) have no first byte, a firstbyte from the1764 branch becomes a req byte if there isn't a branch reqbyte. */1763 /* If we (now or from before) have no firstByte, a firstByte from the 1764 branch becomes a reqByte if there isn't a branch reqByte. */ 1765 1765 1766 if (first byte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0)1767 branch reqbyte = branchfirstbyte;1766 if (firstByte < 0 && branchFirstByte >= 0 && branchReqByte < 0) 1767 branchReqByte = branchFirstByte; 1768 1768 1769 1769 /* Now ensure that the reqbytes match */ 1770 1770 1771 if ((req byte & ~REQ_VARY) != (branchreqbyte & ~REQ_VARY))1772 req byte = REQ_NONE;1771 if ((reqByte & ~REQ_VARY) != (branchReqByte & ~REQ_VARY)) 1772 reqByte = REQ_NONE; 1773 1773 else 1774 req byte |= branchreqbyte; /* To "or" REQ_VARY */1774 reqByte |= branchReqByte; /* To "or" REQ_VARY */ 1775 1775 } 1776 1776 … … 1785 1785 1786 1786 if (ptr >= patternEnd || *ptr != '|') { 1787 int length = code - last _branch;1787 int length = code - lastBranch; 1788 1788 do { 1789 int prev _length = getLinkValueAllowZero(last_branch + 1);1790 putLinkValue(last _branch + 1, length);1791 length = prev _length;1792 last _branch -= length;1789 int prevLength = getLinkValueAllowZero(lastBranch + 1); 1790 putLinkValue(lastBranch + 1, length); 1791 length = prevLength; 1792 lastBranch -= length; 1793 1793 } while (length > 0); 1794 1794 … … 1801 1801 /* Set values to pass back */ 1802 1802 1803 *code ptr = code;1804 *ptr ptr = ptr;1805 *firstbyteptr = first byte;1806 *reqbyteptr = req byte;1803 *codePtr = code; 1804 *ptrPtr = ptr; 1805 *firstbyteptr = firstByte; 1806 *reqbyteptr = reqByte; 1807 1807 return true; 1808 1808 } … … 1814 1814 1815 1815 *code = OP_ALT; 1816 putLinkValue(code + 1, code - last _branch);1817 last _branch = code;1816 putLinkValue(code + 1, code - lastBranch); 1817 lastBranch = code; 1818 1818 code += 1 + LINK_SIZE; 1819 1819 ptr++; … … 2062 2062 int refnum = -c - ESC_REF; 2063 2063 cd.backrefMap |= (refnum < 32) ? (1 << refnum) : 1; 2064 if (refnum > cd.top _backref)2065 cd.top _backref = refnum;2064 if (refnum > cd.topBackref) 2065 cd.topBackref = refnum; 2066 2066 length += 2; /* For single back reference */ 2067 2067 if (safelyCheckNextChar(ptr, patternEnd, '{') && isCountedRepeat(ptr + 2, patternEnd)) { … … 2525 2525 pattern the regular expression 2526 2526 options various option bits 2527 error codeptr pointer to error code variable (pcre_compile2() only)2527 errorCodePtr pointer to error code variable (pcre_compile2() only) 2528 2528 can be NULL if you don't want a code value 2529 error ptr pointer to pointer to error text2529 errorPtr pointer to pointer to error text 2530 2530 erroroffset ptr offset in pattern where error was detected 2531 2531 tables pointer to character tables or NULL 2532 2532 2533 2533 Returns: pointer to compiled data block, or NULL on error, 2534 with error ptr and erroroffset set2534 with errorPtr and erroroffset set 2535 2535 */ 2536 2536 2537 static inline JSRegExp* returnError(ErrorCode errorcode, const char** error ptr)2537 static inline JSRegExp* returnError(ErrorCode errorcode, const char** errorPtr) 2538 2538 { 2539 *error ptr = errorText(errorcode);2539 *errorPtr = errorText(errorcode); 2540 2540 return 0; 2541 2541 } … … 2543 2543 JSRegExp* jsRegExpCompile(const UChar* pattern, int patternLength, 2544 2544 JSRegExpIgnoreCaseOption ignoreCase, JSRegExpMultilineOption multiline, 2545 unsigned* numSubpatterns, const char** error ptr)2545 unsigned* numSubpatterns, const char** errorPtr) 2546 2546 { 2547 /* We can't pass back an error message if error ptr is NULL; I guess the best we2547 /* We can't pass back an error message if errorPtr is NULL; I guess the best we 2548 2548 can do is just return NULL, but we can set a code value if there is a code pointer. */ 2549 if (!error ptr)2549 if (!errorPtr) 2550 2550 return 0; 2551 *error ptr = NULL;2551 *errorPtr = NULL; 2552 2552 2553 2553 CompileData cd; … … 2559 2559 int length = calculateCompiledPatternLength(pattern, patternLength, ignoreCase, cd, errorcode); 2560 2560 if (errorcode) 2561 return returnError(errorcode, error ptr);2561 return returnError(errorcode, errorPtr); 2562 2562 2563 2563 if (length > MAX_PATTERN_SIZE) 2564 return returnError(ERR16, error ptr);2564 return returnError(ERR16, errorPtr); 2565 2565 2566 2566 size_t size = length + sizeof(JSRegExp); … … 2568 2568 2569 2569 if (!re) 2570 return returnError(ERR13, error ptr);2570 return returnError(ERR13, errorPtr); 2571 2571 2572 2572 re->options = (ignoreCase ? IgnoreCaseOption : 0) | (multiline ? MatchAcrossMultipleLinesOption : 0); … … 2584 2584 const UChar* patternEnd = pattern + patternLength; 2585 2585 unsigned char* code = (unsigned char*)codeStart; 2586 int first byte, reqbyte;2586 int firstByte, reqByte; 2587 2587 int bracketCount = 0; 2588 2588 if (!cd.needOuterBracket) 2589 compileBranch(re->options, &bracketCount, &code, &ptr, patternEnd, &errorcode, &first byte, &reqbyte, cd);2589 compileBranch(re->options, &bracketCount, &code, &ptr, patternEnd, &errorcode, &firstByte, &reqByte, cd); 2590 2590 else { 2591 2591 *code = OP_BRA; 2592 compileBracket(re->options, &bracketCount, &code, &ptr, patternEnd, &errorcode, 0, &first byte, &reqbyte, cd);2592 compileBracket(re->options, &bracketCount, &code, &ptr, patternEnd, &errorcode, 0, &firstByte, &reqByte, cd); 2593 2593 } 2594 re->top _bracket = bracketCount;2595 re->top _backref = cd.top_backref;2594 re->topBracket = bracketCount; 2595 re->topBackref = cd.topBackref; 2596 2596 2597 2597 /* If not reached end of pattern on success, there's an excess bracket. */ … … 2612 2612 subpattern. */ 2613 2613 2614 if (re->top _backref > re->top_bracket)2614 if (re->topBackref > re->topBracket) 2615 2615 errorcode = ERR15; 2616 2616 … … 2619 2619 if (errorcode != ERR0) { 2620 2620 delete [] reinterpret_cast<char*>(re); 2621 return returnError(errorcode, error ptr);2621 return returnError(errorcode, errorPtr); 2622 2622 } 2623 2623 … … 2635 2635 re->options |= IsAnchoredOption; 2636 2636 else { 2637 if (first byte < 0) {2638 first byte = (cd.needOuterBracket2637 if (firstByte < 0) { 2638 firstByte = (cd.needOuterBracket 2639 2639 ? bracketFindFirstAssertedCharacter(codeStart, false) 2640 2640 : branchFindFirstAssertedCharacter(codeStart, false)) 2641 2641 | ((re->options & IgnoreCaseOption) ? REQ_IGNORE_CASE : 0); 2642 2642 } 2643 if (first byte >= 0) {2644 int ch = first byte & 255;2643 if (firstByte >= 0) { 2644 int ch = firstByte & 255; 2645 2645 if (ch < 127) { 2646 re->first _byte = ((firstbyte & REQ_IGNORE_CASE) && flipCase(ch) == ch) ? ch : firstbyte;2646 re->firstByte = ((firstByte & REQ_IGNORE_CASE) && flipCase(ch) == ch) ? ch : firstByte; 2647 2647 re->options |= UseFirstByteOptimizationOption; 2648 2648 } … … 2657 2657 bytes. */ 2658 2658 2659 if (req byte >= 0 && (!(re->options & IsAnchoredOption) || (reqbyte & REQ_VARY))) {2660 int ch = req byte & 255;2659 if (reqByte >= 0 && (!(re->options & IsAnchoredOption) || (reqByte & REQ_VARY))) { 2660 int ch = reqByte & 255; 2661 2661 if (ch < 127) { 2662 re->req _byte = ((reqbyte & REQ_IGNORE_CASE) && flipCase(ch) == ch) ? (reqbyte & ~REQ_IGNORE_CASE) : reqbyte;2662 re->reqByte = ((reqByte & REQ_IGNORE_CASE) && flipCase(ch) == ch) ? (reqByte & ~REQ_IGNORE_CASE) : reqByte; 2663 2663 re->options |= UseRequiredByteOptimizationOption; 2664 2664 } … … 2666 2666 2667 2667 if (numSubpatterns) 2668 *numSubpatterns = re->top _bracket;2668 *numSubpatterns = re->topBracket; 2669 2669 return re; 2670 2670 }
Note:
See TracChangeset
for help on using the changeset viewer.