Mercurial > hg > octave-kai > gnulib-hg
comparison regex.c @ 480:998dc67883fb
(PUSH_FAILURE_POINT, POP_FAILURE_POINT): Don't push or pop
register values if POSIX backtracking is turned off.
(NUM_FAILURE_ITEMS): Value is 0 if no POSIX backtracking.
author | Richard Stallman <rms@gnu.org> |
---|---|
date | Tue, 22 Aug 1995 19:44:26 +0000 |
parents | 8b8df28857af |
children | 35afc74165b7 |
comparison
equal
deleted
inserted
replaced
479:df93ab9a5de7 | 480:998dc67883fb |
---|---|
1151 } \ | 1151 } \ |
1152 \ | 1152 \ |
1153 /* Push the info, starting with the registers. */ \ | 1153 /* Push the info, starting with the registers. */ \ |
1154 DEBUG_PRINT1 ("\n"); \ | 1154 DEBUG_PRINT1 ("\n"); \ |
1155 \ | 1155 \ |
1156 for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ | 1156 if (!RE_NO_POSIX_BACKTRACKING & bufp->syntax) \ |
1157 this_reg++) \ | 1157 for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ |
1158 { \ | 1158 this_reg++) \ |
1159 DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ | 1159 { \ |
1160 DEBUG_STATEMENT (num_regs_pushed++); \ | 1160 DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ |
1161 DEBUG_STATEMENT (num_regs_pushed++); \ | |
1161 \ | 1162 \ |
1162 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ | 1163 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ |
1163 PUSH_FAILURE_POINTER (regstart[this_reg]); \ | 1164 PUSH_FAILURE_POINTER (regstart[this_reg]); \ |
1164 \ | |
1165 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ | |
1166 PUSH_FAILURE_POINTER (regend[this_reg]); \ | |
1167 \ | 1165 \ |
1168 DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ | 1166 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ |
1169 DEBUG_PRINT2 (" match_null=%d", \ | 1167 PUSH_FAILURE_POINTER (regend[this_reg]); \ |
1170 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ | 1168 \ |
1171 DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ | 1169 DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ |
1172 DEBUG_PRINT2 (" matched_something=%d", \ | 1170 DEBUG_PRINT2 (" match_null=%d", \ |
1173 MATCHED_SOMETHING (reg_info[this_reg])); \ | 1171 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ |
1174 DEBUG_PRINT2 (" ever_matched=%d", \ | 1172 DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ |
1175 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ | 1173 DEBUG_PRINT2 (" matched_something=%d", \ |
1176 DEBUG_PRINT1 ("\n"); \ | 1174 MATCHED_SOMETHING (reg_info[this_reg])); \ |
1177 PUSH_FAILURE_ELT (reg_info[this_reg].word); \ | 1175 DEBUG_PRINT2 (" ever_matched=%d", \ |
1178 } \ | 1176 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ |
1177 DEBUG_PRINT1 ("\n"); \ | |
1178 PUSH_FAILURE_ELT (reg_info[this_reg].word); \ | |
1179 } \ | |
1179 \ | 1180 \ |
1180 DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ | 1181 DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ |
1181 PUSH_FAILURE_INT (lowest_active_reg); \ | 1182 PUSH_FAILURE_INT (lowest_active_reg); \ |
1182 \ | 1183 \ |
1183 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ | 1184 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ |
1210 | 1211 |
1211 /* We push at most this many items on the stack. */ | 1212 /* We push at most this many items on the stack. */ |
1212 #define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | 1213 #define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) |
1213 | 1214 |
1214 /* We actually push this many items. */ | 1215 /* We actually push this many items. */ |
1215 #define NUM_FAILURE_ITEMS \ | 1216 #define NUM_FAILURE_ITEMS \ |
1216 ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | 1217 (((RE_NO_POSIX_BACKTRACKING & bufp->syntax \ |
1217 + NUM_NONREG_ITEMS) | 1218 ? 0 : highest_active_reg - lowest_active_reg + 1) \ |
1219 * NUM_REG_ITEMS) \ | |
1220 + NUM_NONREG_ITEMS) | |
1218 | 1221 |
1219 /* How many items can still be added to the stack without overflowing it. */ | 1222 /* How many items can still be added to the stack without overflowing it. */ |
1220 #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | 1223 #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) |
1221 | 1224 |
1222 | 1225 |
1270 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | 1273 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ |
1271 \ | 1274 \ |
1272 low_reg = (unsigned) POP_FAILURE_INT (); \ | 1275 low_reg = (unsigned) POP_FAILURE_INT (); \ |
1273 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | 1276 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ |
1274 \ | 1277 \ |
1275 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | 1278 if (!RE_NO_POSIX_BACKTRACKING & bufp->syntax) \ |
1276 { \ | 1279 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ |
1277 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ | 1280 { \ |
1281 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ | |
1278 \ | 1282 \ |
1279 reg_info[this_reg].word = POP_FAILURE_ELT (); \ | 1283 reg_info[this_reg].word = POP_FAILURE_ELT (); \ |
1280 DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ | 1284 DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ |
1281 \ | 1285 \ |
1282 regend[this_reg] = (const char *) POP_FAILURE_POINTER (); \ | 1286 regend[this_reg] = (const char *) POP_FAILURE_POINTER (); \ |
1283 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ | 1287 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ |
1284 \ | 1288 \ |
1285 regstart[this_reg] = (const char *) POP_FAILURE_POINTER (); \ | 1289 regstart[this_reg] = (const char *) POP_FAILURE_POINTER (); \ |
1286 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ | 1290 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ |
1287 } \ | 1291 } \ |
1288 \ | 1292 \ |
1289 set_regs_matched_done = 0; \ | 1293 set_regs_matched_done = 0; \ |
1290 DEBUG_STATEMENT (nfailure_points_popped++); \ | 1294 DEBUG_STATEMENT (nfailure_points_popped++); \ |
1291 } /* POP_FAILURE_POINT */ | 1295 } /* POP_FAILURE_POINT */ |
1292 | 1296 |