+++ /dev/null
-Index: /icu/trunk/source/common/unicode/utypes.h\r
-===================================================================\r
---- /icu/trunk/source/common/unicode/utypes.h (revision 36800)\r
-+++ /icu/trunk/source/common/unicode/utypes.h (revision 36801)\r
-@@ -648,4 +648,5 @@\r
- U_REGEX_TIME_OUT, /**< Maximum allowed match time exceeded */\r
- U_REGEX_STOPPED_BY_CALLER, /**< Matching operation aborted by user callback fn. */\r
-+ U_REGEX_PATTERN_TOO_BIG, /**< Pattern exceeds limits on size or complexity. @draft ICU 55 */\r
- U_REGEX_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for regexp errors */\r
- \r
-Index: /icu/trunk/source/common/utypes.c\r
-===================================================================\r
---- /icu/trunk/source/common/utypes.c (revision 36800)\r
-+++ /icu/trunk/source/common/utypes.c (revision 36801)\r
-@@ -2,5 +2,5 @@\r
- ******************************************************************************\r
- *\r
--* Copyright (C) 1997-2011, International Business Machines\r
-+* Copyright (C) 1997-2014, International Business Machines\r
- * Corporation and others. All Rights Reserved.\r
- *\r
-@@ -166,5 +166,6 @@\r
- "U_REGEX_STACK_OVERFLOW",\r
- "U_REGEX_TIME_OUT",\r
-- "U_REGEX_STOPPED_BY_CALLER"\r
-+ "U_REGEX_STOPPED_BY_CALLER",\r
-+ "U_REGEX_PATTERN_TOO_BIG"\r
- };\r
- \r
-Index: /icu/trunk/source/i18n/regexcmp.cpp\r
-===================================================================\r
---- /icu/trunk/source/i18n/regexcmp.cpp (revision 36800)\r
-+++ /icu/trunk/source/i18n/regexcmp.cpp (revision 36801)\r
-@@ -305,5 +305,5 @@\r
- // the position in the compiled pattern.\r
- //\r
-- fRXPat->fFrameSize+=RESTACKFRAME_HDRCOUNT;\r
-+ allocateStackData(RESTACKFRAME_HDRCOUNT);\r
- \r
- //\r
-@@ -371,7 +371,7 @@\r
- //4 NOP Resreved, will be replaced by a save if there are\r
- // OR | operators at the top level\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_STATE_SAVE, 2), *fStatus);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_JMP, 3), *fStatus);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_FAIL, 0), *fStatus);\r
-+ appendOp(URX_STATE_SAVE, 2);\r
-+ appendOp(URX_JMP, 3);\r
-+ appendOp(URX_FAIL, 0);\r
- \r
- // Standard open nonCapture paren action emits the two NOPs and\r
-@@ -396,5 +396,5 @@\r
- \r
- // add the END operation to the compiled pattern.\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_END, 0), *fStatus);\r
-+ appendOp(URX_END, 0);\r
- \r
- // Terminate the pattern compilation state machine.\r
-@@ -418,5 +418,5 @@\r
- int32_t op = (int32_t)fRXPat->fCompiledPat->elementAti(savePosition);\r
- U_ASSERT(URX_TYPE(op) == URX_NOP); // original contents of reserved location\r
-- op = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+1);\r
-+ op = buildOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+1);\r
- fRXPat->fCompiledPat->setElementAt(op, savePosition);\r
- \r
-@@ -424,6 +424,5 @@\r
- // the JMP will eventually be the location following the ')' for the\r
- // group. This will be patched in later, when the ')' is encountered.\r
-- op = URX_BUILD(URX_JMP, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_JMP, 0);\r
- \r
- // Push the position of the newly added JMP op onto the parentheses stack.\r
-@@ -434,5 +433,5 @@\r
- // for a SAVE in the event that there is yet another '|' following\r
- // this one.\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-+ appendOp(URX_NOP, 0);\r
- fParenStack.push(fRXPat->fCompiledPat->size()-1, *fStatus);\r
- }\r
-@@ -460,10 +459,8 @@\r
- {\r
- fixLiterals();\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-- int32_t varsLoc = fRXPat->fFrameSize; // Reserve three slots in match stack frame.\r
-- fRXPat->fFrameSize += 3;\r
-- int32_t cop = URX_BUILD(URX_START_CAPTURE, varsLoc);\r
-- fRXPat->fCompiledPat->addElement(cop, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-+ appendOp(URX_NOP, 0);\r
-+ int32_t varsLoc = allocateStackData(3); // Reserve three slots in match stack frame.\r
-+ appendOp(URX_START_CAPTURE, varsLoc);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -490,6 +487,6 @@\r
- {\r
- fixLiterals();\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-+ appendOp(URX_NOP, 0);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -513,10 +510,8 @@\r
- {\r
- fixLiterals();\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-- int32_t varLoc = fRXPat->fDataSize; // Reserve a data location for saving the\r
-- fRXPat->fDataSize += 1; // state stack ptr.\r
-- int32_t stoOp = URX_BUILD(URX_STO_SP, varLoc);\r
-- fRXPat->fCompiledPat->addElement(stoOp, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-+ appendOp(URX_NOP, 0);\r
-+ int32_t varLoc = allocateData(1); // Reserve a data location for saving the state stack ptr.\r
-+ appendOp(URX_STO_SP, varLoc);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -561,24 +556,12 @@\r
- {\r
- fixLiterals();\r
-- int32_t dataLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize += 2;\r
-- int32_t op = URX_BUILD(URX_LA_START, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+ 2);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_JMP, fRXPat->fCompiledPat->size()+ 3);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_LA_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_BACKTRACK, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_NOP, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ int32_t dataLoc = allocateData(2);\r
-+ appendOp(URX_LA_START, dataLoc);\r
-+ appendOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+ 2);\r
-+ appendOp(URX_JMP, fRXPat->fCompiledPat->size()+ 3);\r
-+ appendOp(URX_LA_END, dataLoc);\r
-+ appendOp(URX_BACKTRACK, 0);\r
-+ appendOp(URX_NOP, 0);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -605,14 +588,8 @@\r
- {\r
- fixLiterals();\r
-- int32_t dataLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize += 2;\r
-- int32_t op = URX_BUILD(URX_LA_START, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_STATE_SAVE, 0); // dest address will be patched later.\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
--\r
-- op = URX_BUILD(URX_NOP, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ int32_t dataLoc = allocateData(2);\r
-+ appendOp(URX_LA_START, dataLoc);\r
-+ appendOp(URX_STATE_SAVE, 0); // dest address will be patched later.\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -652,21 +629,17 @@\r
- \r
- // Allocate data space\r
-- int32_t dataLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize += 4;\r
-+ int32_t dataLoc = allocateData(4);\r
- \r
- // Emit URX_LB_START\r
-- int32_t op = URX_BUILD(URX_LB_START, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LB_START, dataLoc);\r
- \r
- // Emit URX_LB_CONT\r
-- op = URX_BUILD(URX_LB_CONT, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(0, *fStatus); // MinMatchLength. To be filled later.\r
-- fRXPat->fCompiledPat->addElement(0, *fStatus); // MaxMatchLength. To be filled later.\r
--\r
-- // Emit the NOP\r
-- op = URX_BUILD(URX_NOP, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LB_CONT, dataLoc);\r
-+ appendOp(URX_RESERVED_OP, 0); // MinMatchLength. To be filled later.\r
-+ appendOp(URX_RESERVED_OP, 0); // MaxMatchLength. To be filled later.\r
-+\r
-+ // Emit the NOPs\r
-+ appendOp(URX_NOP, 0);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -708,22 +681,18 @@\r
- \r
- // Allocate data space\r
-- int32_t dataLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize += 4;\r
-+ int32_t dataLoc = allocateData(4);\r
- \r
- // Emit URX_LB_START\r
-- int32_t op = URX_BUILD(URX_LB_START, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LB_START, dataLoc);\r
- \r
- // Emit URX_LBN_CONT\r
-- op = URX_BUILD(URX_LBN_CONT, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(0, *fStatus); // MinMatchLength. To be filled later.\r
-- fRXPat->fCompiledPat->addElement(0, *fStatus); // MaxMatchLength. To be filled later.\r
-- fRXPat->fCompiledPat->addElement(0, *fStatus); // Continue Loc. To be filled later.\r
--\r
-- // Emit the NOP\r
-- op = URX_BUILD(URX_NOP, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LBN_CONT, dataLoc);\r
-+ appendOp(URX_RESERVED_OP, 0); // MinMatchLength. To be filled later.\r
-+ appendOp(URX_RESERVED_OP, 0); // MaxMatchLength. To be filled later.\r
-+ appendOp(URX_RESERVED_OP, 0); // Continue Loc. To be filled later.\r
-+\r
-+ // Emit the NOPs\r
-+ appendOp(URX_NOP, 0);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -795,10 +764,7 @@\r
- if (URX_TYPE(repeatedOp) == URX_SETREF) {\r
- // Emit optimized code for [char set]+\r
-- int32_t loopOpI = URX_BUILD(URX_LOOP_SR_I, URX_VAL(repeatedOp));\r
-- fRXPat->fCompiledPat->addElement(loopOpI, *fStatus);\r
-- frameLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
-- int32_t loopOpC = URX_BUILD(URX_LOOP_C, frameLoc);\r
-- fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);\r
-+ appendOp(URX_LOOP_SR_I, URX_VAL(repeatedOp));\r
-+ frameLoc = allocateStackData(1);\r
-+ appendOp(URX_LOOP_C, frameLoc);\r
- break;\r
- }\r
-@@ -808,5 +774,5 @@\r
- URX_TYPE(repeatedOp) == URX_DOTANY_UNIX) {\r
- // Emit Optimized code for .+ operations.\r
-- int32_t loopOpI = URX_BUILD(URX_LOOP_DOT_I, 0);\r
-+ int32_t loopOpI = buildOp(URX_LOOP_DOT_I, 0);\r
- if (URX_TYPE(repeatedOp) == URX_DOTANY_ALL) {\r
- // URX_LOOP_DOT_I operand is a flag indicating ". matches any" mode.\r
-@@ -816,9 +782,7 @@\r
- loopOpI |= 2;\r
- }\r
-- fRXPat->fCompiledPat->addElement(loopOpI, *fStatus);\r
-- frameLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
-- int32_t loopOpC = URX_BUILD(URX_LOOP_C, frameLoc);\r
-- fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);\r
-+ appendOp(loopOpI);\r
-+ frameLoc = allocateStackData(1);\r
-+ appendOp(URX_LOOP_C, frameLoc);\r
- break;\r
- }\r
-@@ -834,16 +798,13 @@\r
- // Emit the code sequence that can handle it.\r
- insertOp(topLoc);\r
-- frameLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
--\r
-- int32_t op = URX_BUILD(URX_STO_INP_LOC, frameLoc);\r
-+ frameLoc = allocateStackData(1);\r
-+\r
-+ int32_t op = buildOp(URX_STO_INP_LOC, frameLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc);\r
- \r
-- op = URX_BUILD(URX_JMP_SAV_X, topLoc+1);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_JMP_SAV_X, topLoc+1);\r
- } else {\r
- // Simpler code when the repeated body must match something non-empty\r
-- int32_t jmpOp = URX_BUILD(URX_JMP_SAV, topLoc);\r
-- fRXPat->fCompiledPat->addElement(jmpOp, *fStatus);\r
-+ appendOp(URX_JMP_SAV, topLoc);\r
- }\r
- }\r
-@@ -857,6 +818,5 @@\r
- {\r
- int32_t topLoc = blockTopLoc(FALSE);\r
-- int32_t saveStateOp = URX_BUILD(URX_STATE_SAVE, topLoc);\r
-- fRXPat->fCompiledPat->addElement(saveStateOp, *fStatus);\r
-+ appendOp(URX_STATE_SAVE, topLoc);\r
- }\r
- break;\r
-@@ -872,5 +832,5 @@\r
- {\r
- int32_t saveStateLoc = blockTopLoc(TRUE);\r
-- int32_t saveStateOp = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size());\r
-+ int32_t saveStateOp = buildOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size());\r
- fRXPat->fCompiledPat->setElementAt(saveStateOp, saveStateLoc);\r
- }\r
-@@ -891,12 +851,10 @@\r
- int32_t jmp2_loc = fRXPat->fCompiledPat->size();\r
- \r
-- int32_t jmp1_op = URX_BUILD(URX_JMP, jmp2_loc+1);\r
-+ int32_t jmp1_op = buildOp(URX_JMP, jmp2_loc+1);\r
- fRXPat->fCompiledPat->setElementAt(jmp1_op, jmp1_loc);\r
- \r
-- int32_t jmp2_op = URX_BUILD(URX_JMP, jmp2_loc+2);\r
-- fRXPat->fCompiledPat->addElement(jmp2_op, *fStatus);\r
--\r
-- int32_t save_op = URX_BUILD(URX_STATE_SAVE, jmp1_loc+1);\r
-- fRXPat->fCompiledPat->addElement(save_op, *fStatus);\r
-+ appendOp(URX_JMP, jmp2_loc+2);\r
-+\r
-+ appendOp(URX_STATE_SAVE, jmp1_loc+1);\r
- }\r
- break;\r
-@@ -938,10 +896,8 @@\r
- if (URX_TYPE(repeatedOp) == URX_SETREF) {\r
- // Emit optimized code for a [char set]*\r
-- int32_t loopOpI = URX_BUILD(URX_LOOP_SR_I, URX_VAL(repeatedOp));\r
-+ int32_t loopOpI = buildOp(URX_LOOP_SR_I, URX_VAL(repeatedOp));\r
- fRXPat->fCompiledPat->setElementAt(loopOpI, topLoc);\r
-- dataLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
-- int32_t loopOpC = URX_BUILD(URX_LOOP_C, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);\r
-+ dataLoc = allocateStackData(1);\r
-+ appendOp(URX_LOOP_C, dataLoc);\r
- break;\r
- }\r
-@@ -951,5 +907,5 @@\r
- URX_TYPE(repeatedOp) == URX_DOTANY_UNIX) {\r
- // Emit Optimized code for .* operations.\r
-- int32_t loopOpI = URX_BUILD(URX_LOOP_DOT_I, 0);\r
-+ int32_t loopOpI = buildOp(URX_LOOP_DOT_I, 0);\r
- if (URX_TYPE(repeatedOp) == URX_DOTANY_ALL) {\r
- // URX_LOOP_DOT_I operand is a flag indicating . matches any mode.\r
-@@ -960,8 +916,6 @@\r
- }\r
- fRXPat->fCompiledPat->setElementAt(loopOpI, topLoc);\r
-- dataLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
-- int32_t loopOpC = URX_BUILD(URX_LOOP_C, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(loopOpC, *fStatus);\r
-+ dataLoc = allocateStackData(1);\r
-+ appendOp(URX_LOOP_C, dataLoc);\r
- break;\r
- }\r
-@@ -972,5 +926,5 @@\r
- \r
- int32_t saveStateLoc = blockTopLoc(TRUE);\r
-- int32_t jmpOp = URX_BUILD(URX_JMP_SAV, saveStateLoc+1);\r
-+ int32_t jmpOp = buildOp(URX_JMP_SAV, saveStateLoc+1);\r
- \r
- // Check for minimum match length of zero, which requires\r
-@@ -978,10 +932,9 @@\r
- if (minMatchLength(saveStateLoc, fRXPat->fCompiledPat->size()-1) == 0) {\r
- insertOp(saveStateLoc);\r
-- dataLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
--\r
-- int32_t op = URX_BUILD(URX_STO_INP_LOC, dataLoc);\r
-+ dataLoc = allocateStackData(1);\r
-+\r
-+ int32_t op = buildOp(URX_STO_INP_LOC, dataLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, saveStateLoc+1);\r
-- jmpOp = URX_BUILD(URX_JMP_SAV_X, saveStateLoc+2);\r
-+ jmpOp = buildOp(URX_JMP_SAV_X, saveStateLoc+2);\r
- }\r
- \r
-@@ -990,10 +943,10 @@\r
- int32_t continueLoc = fRXPat->fCompiledPat->size()+1;\r
- \r
-- // Put together the save state op store it into the compiled code.\r
-- int32_t saveStateOp = URX_BUILD(URX_STATE_SAVE, continueLoc);\r
-+ // Put together the save state op and store it into the compiled code.\r
-+ int32_t saveStateOp = buildOp(URX_STATE_SAVE, continueLoc);\r
- fRXPat->fCompiledPat->setElementAt(saveStateOp, saveStateLoc);\r
- \r
- // Append the URX_JMP_SAV or URX_JMPX operation to the compiled pattern.\r
-- fRXPat->fCompiledPat->addElement(jmpOp, *fStatus);\r
-+ appendOp(jmpOp);\r
- }\r
- break;\r
-@@ -1009,8 +962,7 @@\r
- int32_t jmpLoc = blockTopLoc(TRUE); // loc 1.\r
- int32_t saveLoc = fRXPat->fCompiledPat->size(); // loc 3.\r
-- int32_t jmpOp = URX_BUILD(URX_JMP, saveLoc);\r
-- int32_t stateSaveOp = URX_BUILD(URX_STATE_SAVE, jmpLoc+1);\r
-+ int32_t jmpOp = buildOp(URX_JMP, saveLoc);\r
- fRXPat->fCompiledPat->setElementAt(jmpOp, jmpLoc);\r
-- fRXPat->fCompiledPat->addElement(stateSaveOp, *fStatus);\r
-+ appendOp(URX_STATE_SAVE, jmpLoc+1);\r
- }\r
- break;\r
-@@ -1085,7 +1037,7 @@\r
- // First the STO_SP before the start of the loop\r
- insertOp(topLoc);\r
-- int32_t varLoc = fRXPat->fDataSize; // Reserve a data location for saving the\r
-- fRXPat->fDataSize += 1; // state stack ptr.\r
-- int32_t op = URX_BUILD(URX_STO_SP, varLoc);\r
-+\r
-+ int32_t varLoc = allocateData(1); // Reserve a data location for saving the\r
-+ int32_t op = buildOp(URX_STO_SP, varLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc);\r
- \r
-@@ -1096,6 +1048,5 @@\r
- \r
- // Then the LD_SP after the end of the loop\r
-- op = URX_BUILD(URX_LD_SP, varLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LD_SP, varLoc);\r
- }\r
- \r
-@@ -1133,13 +1084,11 @@\r
- {\r
- fixLiterals(FALSE);\r
-- int32_t op;\r
- if (fModeFlags & UREGEX_DOTALL) {\r
-- op = URX_BUILD(URX_DOTANY_ALL, 0);\r
-+ appendOp(URX_DOTANY_ALL, 0);\r
- } else if (fModeFlags & UREGEX_UNIX_LINES) {\r
-- op = URX_BUILD(URX_DOTANY_UNIX, 0);\r
-+ appendOp(URX_DOTANY_UNIX, 0);\r
- } else {\r
-- op = URX_BUILD(URX_DOTANY, 0);\r
-- }\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_DOTANY, 0);\r
-+ }\r
- }\r
- break;\r
-@@ -1148,15 +1097,13 @@\r
- {\r
- fixLiterals(FALSE);\r
-- int32_t op = 0;\r
- if ( (fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {\r
-- op = URX_CARET;\r
-+ appendOp(URX_CARET, 0);\r
- } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {\r
-- op = URX_CARET_M;\r
-+ appendOp(URX_CARET_M, 0);\r
- } else if ((fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {\r
-- op = URX_CARET; // Only testing true start of input.\r
-+ appendOp(URX_CARET, 0); // Only testing true start of input.\r
- } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {\r
-- op = URX_CARET_M_UNIX;\r
-- }\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(op, 0), *fStatus);\r
-+ appendOp(URX_CARET_M_UNIX, 0);\r
-+ }\r
- }\r
- break;\r
-@@ -1165,15 +1112,13 @@\r
- {\r
- fixLiterals(FALSE);\r
-- int32_t op = 0;\r
- if ( (fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {\r
-- op = URX_DOLLAR;\r
-+ appendOp(URX_DOLLAR, 0);\r
- } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {\r
-- op = URX_DOLLAR_M;\r
-+ appendOp(URX_DOLLAR_M, 0);\r
- } else if ((fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {\r
-- op = URX_DOLLAR_D;\r
-+ appendOp(URX_DOLLAR_D, 0);\r
- } else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) != 0) {\r
-- op = URX_DOLLAR_MD;\r
-- }\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(op, 0), *fStatus);\r
-+ appendOp(URX_DOLLAR_MD, 0);\r
-+ }\r
- }\r
- break;\r
-@@ -1181,5 +1126,5 @@\r
- case doBackslashA:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_CARET, 0), *fStatus);\r
-+ appendOp(URX_CARET, 0);\r
- break;\r
- \r
-@@ -1193,5 +1138,5 @@\r
- fixLiterals(FALSE);\r
- int32_t op = (fModeFlags & UREGEX_UWORD)? URX_BACKSLASH_BU : URX_BACKSLASH_B;\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(op, 1), *fStatus);\r
-+ appendOp(op, 1);\r
- }\r
- break;\r
-@@ -1206,5 +1151,5 @@\r
- fixLiterals(FALSE);\r
- int32_t op = (fModeFlags & UREGEX_UWORD)? URX_BACKSLASH_BU : URX_BACKSLASH_B;\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(op, 0), *fStatus);\r
-+ appendOp(op, 0);\r
- }\r
- break;\r
-@@ -1212,44 +1157,40 @@\r
- case doBackslashD:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_D, 1), *fStatus);\r
-+ appendOp(URX_BACKSLASH_D, 1);\r
- break;\r
- \r
- case doBackslashd:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_D, 0), *fStatus);\r
-+ appendOp(URX_BACKSLASH_D, 0);\r
- break;\r
- \r
- case doBackslashG:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_G, 0), *fStatus);\r
-+ appendOp(URX_BACKSLASH_G, 0);\r
- break;\r
- \r
- case doBackslashS:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(\r
-- URX_BUILD(URX_STAT_SETREF_N, URX_ISSPACE_SET), *fStatus);\r
-+ appendOp(URX_STAT_SETREF_N, URX_ISSPACE_SET);\r
- break;\r
- \r
- case doBackslashs:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(\r
-- URX_BUILD(URX_STATIC_SETREF, URX_ISSPACE_SET), *fStatus);\r
-+ appendOp(URX_STATIC_SETREF, URX_ISSPACE_SET);\r
- break;\r
- \r
- case doBackslashW:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(\r
-- URX_BUILD(URX_STAT_SETREF_N, URX_ISWORD_SET), *fStatus);\r
-+ appendOp(URX_STAT_SETREF_N, URX_ISWORD_SET);\r
- break;\r
- \r
- case doBackslashw:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(\r
-- URX_BUILD(URX_STATIC_SETREF, URX_ISWORD_SET), *fStatus);\r
-+ appendOp(URX_STATIC_SETREF, URX_ISWORD_SET);\r
- break;\r
- \r
- case doBackslashX:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_X, 0), *fStatus);\r
-+ appendOp(URX_BACKSLASH_X, 0);\r
- break;\r
- \r
-@@ -1257,10 +1198,10 @@\r
- case doBackslashZ:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_DOLLAR, 0), *fStatus);\r
-+ appendOp(URX_DOLLAR, 0);\r
- break;\r
- \r
- case doBackslashz:\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKSLASH_Z, 0), *fStatus);\r
-+ appendOp(URX_BACKSLASH_Z, 0);\r
- break;\r
- \r
-@@ -1322,11 +1263,9 @@\r
- // and shouldn't enter this code path at all.\r
- fixLiterals(FALSE);\r
-- int32_t op;\r
- if (fModeFlags & UREGEX_CASE_INSENSITIVE) {\r
-- op = URX_BUILD(URX_BACKREF_I, groupNum);\r
-+ appendOp(URX_BACKREF_I, groupNum);\r
- } else {\r
-- op = URX_BUILD(URX_BACKREF, groupNum);\r
-- }\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_BACKREF, groupNum);\r
-+ }\r
- }\r
- break;\r
-@@ -1349,20 +1288,16 @@\r
- // Emit the STO_SP\r
- int32_t topLoc = blockTopLoc(TRUE);\r
-- int32_t stoLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize++; // Reserve the data location for storing save stack ptr.\r
-- int32_t op = URX_BUILD(URX_STO_SP, stoLoc);\r
-+ int32_t stoLoc = allocateData(1); // Reserve the data location for storing save stack ptr.\r
-+ int32_t op = buildOp(URX_STO_SP, stoLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc);\r
- \r
- // Emit the STATE_SAVE\r
-- op = URX_BUILD(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+2);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size()+2);\r
- \r
- // Emit the JMP\r
-- op = URX_BUILD(URX_JMP, topLoc+1);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_JMP, topLoc+1);\r
- \r
- // Emit the LD_SP\r
-- op = URX_BUILD(URX_LD_SP, stoLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LD_SP, stoLoc);\r
- }\r
- break;\r
-@@ -1384,21 +1319,18 @@\r
- \r
- // emit STO_SP loc\r
-- int32_t stoLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize++; // Reserve the data location for storing save stack ptr.\r
-- int32_t op = URX_BUILD(URX_STO_SP, stoLoc);\r
-+ int32_t stoLoc = allocateData(1); // Reserve the data location for storing save stack ptr.\r
-+ int32_t op = buildOp(URX_STO_SP, stoLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc);\r
- \r
- // Emit the SAVE_STATE 5\r
- int32_t L7 = fRXPat->fCompiledPat->size()+1;\r
-- op = URX_BUILD(URX_STATE_SAVE, L7);\r
-+ op = buildOp(URX_STATE_SAVE, L7);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc+1);\r
- \r
- // Append the JMP operation.\r
-- op = URX_BUILD(URX_JMP, topLoc+1);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_JMP, topLoc+1);\r
- \r
- // Emit the LD_SP loc\r
-- op = URX_BUILD(URX_LD_SP, stoLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LD_SP, stoLoc);\r
- }\r
- break;\r
-@@ -1419,17 +1351,15 @@\r
- \r
- // Emit the STO_SP\r
-- int32_t stoLoc = fRXPat->fDataSize;\r
-- fRXPat->fDataSize++; // Reserve the data location for storing save stack ptr.\r
-- int32_t op = URX_BUILD(URX_STO_SP, stoLoc);\r
-+ int32_t stoLoc = allocateData(1); // Reserve the data location for storing save stack ptr.\r
-+ int32_t op = buildOp(URX_STO_SP, stoLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc);\r
- \r
- // Emit the SAVE_STATE\r
- int32_t continueLoc = fRXPat->fCompiledPat->size()+1;\r
-- op = URX_BUILD(URX_STATE_SAVE, continueLoc);\r
-+ op = buildOp(URX_STATE_SAVE, continueLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topLoc+1);\r
- \r
- // Emit the LD_SP\r
-- op = URX_BUILD(URX_LD_SP, stoLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LD_SP, stoLoc);\r
- }\r
- break;\r
-@@ -1488,6 +1418,6 @@\r
- {\r
- fixLiterals(FALSE);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_NOP, 0), *fStatus);\r
-+ appendOp(URX_NOP, 0);\r
-+ appendOp(URX_NOP, 0);\r
- \r
- // On the Parentheses stack, start a new frame and add the postions\r
-@@ -1826,5 +1756,4 @@\r
- //------------------------------------------------------------------------------\r
- void RegexCompile::fixLiterals(UBool split) {\r
-- int32_t op = 0; // An op from/for the compiled pattern.\r
- \r
- // If no literal characters have been scanned but not yet had code generated\r
-@@ -1865,21 +1794,21 @@\r
- if ((fModeFlags & UREGEX_CASE_INSENSITIVE) &&\r
- u_hasBinaryProperty(lastCodePoint, UCHAR_CASE_SENSITIVE)) {\r
-- op = URX_BUILD(URX_ONECHAR_I, lastCodePoint);\r
-+ appendOp(URX_ONECHAR_I, lastCodePoint);\r
- } else {\r
-- op = URX_BUILD(URX_ONECHAR, lastCodePoint);\r
-- }\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_ONECHAR, lastCodePoint);\r
-+ }\r
- } else {\r
- // Two or more chars, emit a URX_STRING to match them.\r
-+ if (fLiteralChars.length() > 0x00ffffff || fRXPat->fLiteralText.length() > 0x00ffffff) {\r
-+ error(U_REGEX_PATTERN_TOO_BIG);\r
-+ }\r
- if (fModeFlags & UREGEX_CASE_INSENSITIVE) {\r
-- op = URX_BUILD(URX_STRING_I, fRXPat->fLiteralText.length());\r
-+ appendOp(URX_STRING_I, fRXPat->fLiteralText.length());\r
- } else {\r
- // TODO here: add optimization to split case sensitive strings of length two\r
- // into two single char ops, for efficiency.\r
-- op = URX_BUILD(URX_STRING, fRXPat->fLiteralText.length());\r
-- }\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- op = URX_BUILD(URX_STRING_LEN, fLiteralChars.length());\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_STRING, fRXPat->fLiteralText.length());\r
-+ }\r
-+ appendOp(URX_STRING_LEN, fLiteralChars.length());\r
- \r
- // Add this string into the accumulated strings of the compiled pattern.\r
-@@ -1891,6 +1820,56 @@\r
- \r
- \r
--\r
--\r
-+int32_t RegexCompile::buildOp(int32_t type, int32_t val) {\r
-+ if (U_FAILURE(*fStatus)) {\r
-+ return 0;\r
-+ }\r
-+ if (type < 0 || type > 255) {\r
-+ U_ASSERT(FALSE);\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ type = URX_RESERVED_OP;\r
-+ }\r
-+ if (val > 0x00ffffff) {\r
-+ U_ASSERT(FALSE);\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ val = 0;\r
-+ }\r
-+ if (val < 0) {\r
-+ if (!(type == URX_RESERVED_OP_N || type == URX_RESERVED_OP)) {\r
-+ U_ASSERT(FALSE);\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ return -1;\r
-+ }\r
-+ if (URX_TYPE(val) != 0xff) {\r
-+ U_ASSERT(FALSE);\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ return -1;\r
-+ }\r
-+ type = URX_RESERVED_OP_N;\r
-+ }\r
-+ return (type << 24) | val;\r
-+}\r
-+\r
-+\r
-+//------------------------------------------------------------------------------\r
-+//\r
-+// appendOp() Append a new instruction onto the compiled pattern\r
-+// Includes error checking, limiting the size of the\r
-+// pattern to lengths that can be represented in the\r
-+// 24 bit operand field of an instruction.\r
-+//\r
-+//------------------------------------------------------------------------------\r
-+void RegexCompile::appendOp(int32_t op) {\r
-+ if (U_FAILURE(*fStatus)) {\r
-+ return;\r
-+ }\r
-+ fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ if ((fRXPat->fCompiledPat->size() > 0x00fffff0) && U_SUCCESS(*fStatus)) {\r
-+ error(U_REGEX_PATTERN_TOO_BIG);\r
-+ }\r
-+}\r
-+\r
-+void RegexCompile::appendOp(int32_t type, int32_t val) {\r
-+ appendOp(buildOp(type, val));\r
-+}\r
- \r
- \r
-@@ -1908,5 +1887,5 @@\r
- U_ASSERT(where>0 && where < code->size());\r
- \r
-- int32_t nop = URX_BUILD(URX_NOP, 0);\r
-+ int32_t nop = buildOp(URX_NOP, 0);\r
- code->insertElementAt(nop, where, *fStatus);\r
- \r
-@@ -1929,5 +1908,5 @@\r
- // needs to be incremented to adjust for the insertion.\r
- opValue++;\r
-- op = URX_BUILD(opType, opValue);\r
-+ op = buildOp(opType, opValue);\r
- code->setElementAt(op, loc);\r
- }\r
-@@ -1953,4 +1932,56 @@\r
- }\r
- \r
-+\r
-+//------------------------------------------------------------------------------\r
-+//\r
-+// allocateData() Allocate storage in the matcher's static data area.\r
-+// Return the index for the newly allocated data.\r
-+// The storage won't actually exist until we are running a match\r
-+// operation, but the storage indexes are inserted into various\r
-+// opcodes while compiling the pattern.\r
-+//\r
-+//------------------------------------------------------------------------------\r
-+int32_t RegexCompile::allocateData(int32_t size) {\r
-+ if (U_FAILURE(*fStatus)) {\r
-+ return 0;\r
-+ }\r
-+ if (size <= 0 || size > 0x100 || fRXPat->fDataSize < 0) {\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ return 0;\r
-+ }\r
-+ int32_t dataIndex = fRXPat->fDataSize;\r
-+ fRXPat->fDataSize += size;\r
-+ if (fRXPat->fDataSize >= 0x00fffff0) {\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ }\r
-+ return dataIndex;\r
-+}\r
-+\r
-+\r
-+//------------------------------------------------------------------------------\r
-+//\r
-+// allocateStackData() Allocate space in the back-tracking stack frame.\r
-+// Return the index for the newly allocated data.\r
-+// The frame indexes are inserted into various\r
-+// opcodes while compiling the pattern, meaning that frame\r
-+// size must be restricted to the size that will fit\r
-+// as an operand (24 bits).\r
-+//\r
-+//------------------------------------------------------------------------------\r
-+int32_t RegexCompile::allocateStackData(int32_t size) {\r
-+ if (U_FAILURE(*fStatus)) {\r
-+ return 0;\r
-+ }\r
-+ if (size <= 0 || size > 0x100 || fRXPat->fFrameSize < 0) {\r
-+ error(U_REGEX_INTERNAL_ERROR);\r
-+ return 0;\r
-+ }\r
-+ int32_t dataIndex = fRXPat->fFrameSize;\r
-+ fRXPat->fFrameSize += size;\r
-+ if (fRXPat->fFrameSize >= 0x00fffff0) {\r
-+ error(U_REGEX_PATTERN_TOO_BIG);\r
-+ }\r
-+ return dataIndex;\r
-+}\r
- \r
- \r
-@@ -1996,5 +2027,5 @@\r
- }\r
- if (reserveLoc) {\r
-- int32_t nop = URX_BUILD(URX_NOP, 0);\r
-+ int32_t nop = buildOp(URX_NOP, 0);\r
- fRXPat->fCompiledPat->insertElementAt(nop, theLoc, *fStatus);\r
- }\r
-@@ -2071,6 +2102,5 @@\r
- \r
- int32_t frameVarLocation = URX_VAL(captureOp);\r
-- int32_t endCaptureOp = URX_BUILD(URX_END_CAPTURE, frameVarLocation);\r
-- fRXPat->fCompiledPat->addElement(endCaptureOp, *fStatus);\r
-+ appendOp(URX_END_CAPTURE, frameVarLocation);\r
- }\r
- break;\r
-@@ -2083,6 +2113,5 @@\r
- U_ASSERT(URX_TYPE(stoOp) == URX_STO_SP);\r
- int32_t stoLoc = URX_VAL(stoOp);\r
-- int32_t ldOp = URX_BUILD(URX_LD_SP, stoLoc);\r
-- fRXPat->fCompiledPat->addElement(ldOp, *fStatus);\r
-+ appendOp(URX_LD_SP, stoLoc);\r
- }\r
- break;\r
-@@ -2093,6 +2122,5 @@\r
- U_ASSERT(URX_TYPE(startOp) == URX_LA_START);\r
- int32_t dataLoc = URX_VAL(startOp);\r
-- int32_t op = URX_BUILD(URX_LA_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LA_END, dataLoc);\r
- }\r
- break;\r
-@@ -2104,10 +2132,7 @@\r
- U_ASSERT(URX_TYPE(startOp) == URX_LA_START);\r
- int32_t dataLoc = URX_VAL(startOp);\r
-- int32_t op = URX_BUILD(URX_LA_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- op = URX_BUILD(URX_BACKTRACK, 0);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- op = URX_BUILD(URX_LA_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LA_END, dataLoc);\r
-+ appendOp(URX_BACKTRACK, 0);\r
-+ appendOp(URX_LA_END, dataLoc);\r
- \r
- // Patch the URX_SAVE near the top of the block.\r
-@@ -2116,5 +2141,5 @@\r
- U_ASSERT(URX_TYPE(saveOp) == URX_STATE_SAVE);\r
- int32_t dest = fRXPat->fCompiledPat->size()-1;\r
-- saveOp = URX_BUILD(URX_STATE_SAVE, dest);\r
-+ saveOp = buildOp(URX_STATE_SAVE, dest);\r
- fRXPat->fCompiledPat->setElementAt(saveOp, fMatchOpenParen);\r
- }\r
-@@ -2129,8 +2154,6 @@\r
- U_ASSERT(URX_TYPE(startOp) == URX_LB_START);\r
- int32_t dataLoc = URX_VAL(startOp);\r
-- int32_t op = URX_BUILD(URX_LB_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-- op = URX_BUILD(URX_LA_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LB_END, dataLoc);\r
-+ appendOp(URX_LA_END, dataLoc);\r
- \r
- // Determine the min and max bounds for the length of the\r
-@@ -2168,6 +2191,5 @@\r
- U_ASSERT(URX_TYPE(startOp) == URX_LB_START);\r
- int32_t dataLoc = URX_VAL(startOp);\r
-- int32_t op = URX_BUILD(URX_LBN_END, dataLoc);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(URX_LBN_END, dataLoc);\r
- \r
- // Determine the min and max bounds for the length of the\r
-@@ -2194,5 +2216,5 @@\r
- // Insert the pattern location to continue at after a successful match\r
- // as the last operand of the URX_LBN_CONT\r
-- op = URX_BUILD(URX_RELOC_OPRND, fRXPat->fCompiledPat->size());\r
-+ int32_t op = buildOp(URX_RELOC_OPRND, fRXPat->fCompiledPat->size());\r
- fRXPat->fCompiledPat->setElementAt(op, fMatchOpenParen-1);\r
- }\r
-@@ -2235,5 +2257,5 @@\r
- {\r
- // Set of no elements. Always fails to match.\r
-- fRXPat->fCompiledPat->addElement(URX_BUILD(URX_BACKTRACK, 0), *fStatus);\r
-+ appendOp(URX_BACKTRACK, 0);\r
- delete theSet;\r
- }\r
-@@ -2256,6 +2278,5 @@\r
- int32_t setNumber = fRXPat->fSets->size();\r
- fRXPat->fSets->addElement(theSet, *fStatus);\r
-- int32_t setOp = URX_BUILD(URX_SETREF, setNumber);\r
-- fRXPat->fCompiledPat->addElement(setOp, *fStatus);\r
-+ appendOp(URX_SETREF, setNumber);\r
- }\r
- }\r
-@@ -2296,11 +2317,8 @@\r
- // +1 --> Input index (for breaking non-progressing loops)\r
- // (Only present if unbounded upper limit on loop)\r
-- int32_t counterLoc = fRXPat->fFrameSize;\r
-- fRXPat->fFrameSize++;\r
-- if (fIntervalUpper < 0) {\r
-- fRXPat->fFrameSize++;\r
-- }\r
--\r
-- int32_t op = URX_BUILD(InitOp, counterLoc);\r
-+ int32_t dataSize = fIntervalUpper < 0 ? 2 : 1;\r
-+ int32_t counterLoc = allocateStackData(dataSize);\r
-+\r
-+ int32_t op = buildOp(InitOp, counterLoc);\r
- fRXPat->fCompiledPat->setElementAt(op, topOfBlock);\r
- \r
-@@ -2310,5 +2328,5 @@\r
- // position to move.\r
- int32_t loopEnd = fRXPat->fCompiledPat->size();\r
-- op = URX_BUILD(URX_RELOC_OPRND, loopEnd);\r
-+ op = buildOp(URX_RELOC_OPRND, loopEnd);\r
- fRXPat->fCompiledPat->setElementAt(op, topOfBlock+1);\r
- \r
-@@ -2319,6 +2337,5 @@\r
- // Apend the CTR_LOOP op. The operand is the location of the CTR_INIT op.\r
- // Goes at end of the block being looped over, so just append to the code so far.\r
-- op = URX_BUILD(LoopOp, topOfBlock);\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ appendOp(LoopOp, topOfBlock);\r
- \r
- if ((fIntervalLow & 0xff000000) != 0 ||\r
-@@ -2373,5 +2390,5 @@\r
- int32_t endOfSequenceLoc = fRXPat->fCompiledPat->size()-1\r
- + fIntervalUpper + (fIntervalUpper-fIntervalLow);\r
-- int32_t saveOp = URX_BUILD(URX_STATE_SAVE, endOfSequenceLoc);\r
-+ int32_t saveOp = buildOp(URX_STATE_SAVE, endOfSequenceLoc);\r
- if (fIntervalLow == 0) {\r
- insertOp(topOfBlock);\r
-@@ -2386,11 +2403,8 @@\r
- int32_t i;\r
- for (i=1; i<fIntervalUpper; i++ ) {\r
-- if (i == fIntervalLow) {\r
-- fRXPat->fCompiledPat->addElement(saveOp, *fStatus);\r
-- }\r
-- if (i > fIntervalLow) {\r
-- fRXPat->fCompiledPat->addElement(saveOp, *fStatus);\r
-- }\r
-- fRXPat->fCompiledPat->addElement(op, *fStatus);\r
-+ if (i >= fIntervalLow) {\r
-+ appendOp(saveOp);\r
-+ }\r
-+ appendOp(op);\r
- }\r
- return TRUE;\r
-@@ -3612,5 +3626,5 @@\r
- U_ASSERT(operandAddress>=0 && operandAddress<deltas.size());\r
- int32_t fixedOperandAddress = operandAddress - deltas.elementAti(operandAddress);\r
-- op = URX_BUILD(opType, fixedOperandAddress);\r
-+ op = buildOp(opType, fixedOperandAddress);\r
- fRXPat->fCompiledPat->setElementAt(op, dst);\r
- dst++;\r
-@@ -3627,5 +3641,5 @@\r
- }\r
- where = fRXPat->fGroupMap->elementAti(where-1);\r
-- op = URX_BUILD(opType, where);\r
-+ op = buildOp(opType, where);\r
- fRXPat->fCompiledPat->setElementAt(op, dst);\r
- dst++;\r
-@@ -3979,5 +3993,5 @@\r
- //\r
- // scanNamedChar\r
-- // Get a UChar32 from a \N{UNICODE CHARACTER NAME} in the pattern.\r
-+// Get a UChar32 from a \N{UNICODE CHARACTER NAME} in the pattern.\r
- //\r
- // The scan position will be at the 'N'. On return\r
-Index: /icu/trunk/source/i18n/regexcmp.h\r
-===================================================================\r
---- /icu/trunk/source/i18n/regexcmp.h (revision 36800)\r
-+++ /icu/trunk/source/i18n/regexcmp.h (revision 36801)\r
-@@ -105,4 +105,11 @@\r
- void insertOp(int32_t where); // Open up a slot for a new op in the\r
- // generated code at the specified location.\r
-+ void appendOp(int32_t op); // Append a new op to the compiled pattern.\r
-+ void appendOp(int32_t type, int32_t val); // Build & append a new op to the compiled pattern.\r
-+ int32_t buildOp(int32_t type, int32_t val); // Construct a new pcode instruction.\r
-+ int32_t allocateData(int32_t size); // Allocate space in the matcher data area.\r
-+ // Return index of the newly allocated data.\r
-+ int32_t allocateStackData(int32_t size); // Allocate space in the match back-track stack frame.\r
-+ // Return offset index in the frame.\r
- int32_t minMatchLength(int32_t start,\r
- int32_t end);\r
-Index: /icu/trunk/source/i18n/regeximp.h\r
-===================================================================\r
---- /icu/trunk/source/i18n/regeximp.h (revision 36800)\r
-+++ /icu/trunk/source/i18n/regeximp.h (revision 36801)\r
-@@ -1,4 +1,4 @@\r
- //\r
--// Copyright (C) 2002-2013 International Business Machines Corporation\r
-+// Copyright (C) 2002-2014 International Business Machines Corporation\r
- // and others. All rights reserved.\r
- //\r
-@@ -242,5 +242,4 @@\r
- // Convenience macros for assembling and disassembling a compiled operation.\r
- //\r
--#define URX_BUILD(type, val) (int32_t)((type << 24) | (val))\r
- #define URX_TYPE(x) ((uint32_t)(x) >> 24)\r
- #define URX_VAL(x) ((x) & 0xffffff)\r
-Index: /icu/trunk/source/test/intltest/regextst.cpp\r
-===================================================================\r
---- /icu/trunk/source/test/intltest/regextst.cpp (revision 36800)\r
-+++ /icu/trunk/source/test/intltest/regextst.cpp (revision 36801)\r
-@@ -145,4 +145,7 @@\r
- if (exec) TestBug11049();\r
- break;\r
-+ case 25: name = "TestBug11371";\r
-+ if (exec) TestBug11371();\r
-+ break;\r
- default: name = "";\r
- break; //needed to end loop\r
-@@ -5368,4 +5371,47 @@\r
- \r
- \r
-+void RegexTest::TestBug11371() {\r
-+ if (quick) {\r
-+ logln("Skipping test. Runs in exhuastive mode only.");\r
-+ return;\r
-+ }\r
-+ UErrorCode status = U_ZERO_ERROR;\r
-+ UnicodeString patternString;\r
-+\r
-+ for (int i=0; i<8000000; i++) {\r
-+ patternString.append(UnicodeString("()"));\r
-+ }\r
-+ LocalPointer<RegexPattern> compiledPat(RegexPattern::compile(patternString, 0, status));\r
-+ if (status != U_REGEX_PATTERN_TOO_BIG) {\r
-+ errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",\r
-+ __FILE__, __LINE__, u_errorName(status));\r
-+ }\r
-+\r
-+ status = U_ZERO_ERROR;\r
-+ patternString = "(";\r
-+ for (int i=0; i<20000000; i++) {\r
-+ patternString.append(UnicodeString("A++"));\r
-+ }\r
-+ patternString.append(UnicodeString("){0}B++"));\r
-+ LocalPointer<RegexPattern> compiledPat2(RegexPattern::compile(patternString, 0, status));\r
-+ if (status != U_REGEX_PATTERN_TOO_BIG) {\r
-+ errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",\r
-+ __FILE__, __LINE__, u_errorName(status));\r
-+ }\r
-+\r
-+ // Pattern with too much string data, such that string indexes overflow operand data field size\r
-+ // in compiled instruction.\r
-+ status = U_ZERO_ERROR;\r
-+ patternString = "";\r
-+ while (patternString.length() < 0x00ffffff) {\r
-+ patternString.append(UnicodeString("stuff and things dont you know, these are a few of my favorite strings\n"));\r
-+ }\r
-+ patternString.append(UnicodeString("X? trailing string"));\r
-+ LocalPointer<RegexPattern> compiledPat3(RegexPattern::compile(patternString, 0, status));\r
-+ if (status != U_REGEX_PATTERN_TOO_BIG) {\r
-+ errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",\r
-+ __FILE__, __LINE__, u_errorName(status));\r
-+ }\r
-+}\r
- \r
- #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */\r
-Index: /icu/trunk/source/test/intltest/regextst.h\r
-===================================================================\r
---- /icu/trunk/source/test/intltest/regextst.h (revision 36800)\r
-+++ /icu/trunk/source/test/intltest/regextst.h (revision 36801)\r
-@@ -51,4 +51,5 @@\r
- virtual void TestCaseInsensitiveStarters();\r
- virtual void TestBug11049();\r
-+ virtual void TestBug11371();\r
- \r
- // The following functions are internal to the regexp tests.\r