Mercurial > hg > xemacs-beta
comparison src/regex.c @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | 6240c7796c7a |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
1282 this_reg++) \ | 1282 this_reg++) \ |
1283 { \ | 1283 { \ |
1284 DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ | 1284 DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ |
1285 DEBUG_STATEMENT (num_regs_pushed++); \ | 1285 DEBUG_STATEMENT (num_regs_pushed++); \ |
1286 \ | 1286 \ |
1287 DEBUG_PRINT2 (" start: 0x%p\n", regstart[this_reg]); \ | 1287 DEBUG_PRINT2 (" start: 0x%lx\n", (long) regstart[this_reg]); \ |
1288 PUSH_FAILURE_POINTER (regstart[this_reg]); \ | 1288 PUSH_FAILURE_POINTER (regstart[this_reg]); \ |
1289 \ | 1289 \ |
1290 DEBUG_PRINT2 (" end: 0x%p\n", regend[this_reg]); \ | 1290 DEBUG_PRINT2 (" end: 0x%lx\n", (long) regend[this_reg]); \ |
1291 PUSH_FAILURE_POINTER (regend[this_reg]); \ | 1291 PUSH_FAILURE_POINTER (regend[this_reg]); \ |
1292 \ | 1292 \ |
1293 DEBUG_PRINT2 (" info: 0x%lx\n ", \ | 1293 DEBUG_PRINT2 (" info: 0x%lx\n ", \ |
1294 * (unsigned long *) (®_info[this_reg])); \ | 1294 * (long *) (®_info[this_reg])); \ |
1295 DEBUG_PRINT2 (" match_null=%d", \ | 1295 DEBUG_PRINT2 (" match_null=%d", \ |
1296 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ | 1296 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ |
1297 DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ | 1297 DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ |
1298 DEBUG_PRINT2 (" matched_something=%d", \ | 1298 DEBUG_PRINT2 (" matched_something=%d", \ |
1299 MATCHED_SOMETHING (reg_info[this_reg])); \ | 1299 MATCHED_SOMETHING (reg_info[this_reg])); \ |
1307 PUSH_FAILURE_INT (lowest_active_reg); \ | 1307 PUSH_FAILURE_INT (lowest_active_reg); \ |
1308 \ | 1308 \ |
1309 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ | 1309 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ |
1310 PUSH_FAILURE_INT (highest_active_reg); \ | 1310 PUSH_FAILURE_INT (highest_active_reg); \ |
1311 \ | 1311 \ |
1312 DEBUG_PRINT2 (" Pushing pattern 0x%p: ", pattern_place); \ | 1312 DEBUG_PRINT2 (" Pushing pattern 0x%lx: ", (long) pattern_place); \ |
1313 DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | 1313 DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ |
1314 PUSH_FAILURE_POINTER (pattern_place); \ | 1314 PUSH_FAILURE_POINTER (pattern_place); \ |
1315 \ | 1315 \ |
1316 DEBUG_PRINT2 (" Pushing string 0x%p: `", string_place); \ | 1316 DEBUG_PRINT2 (" Pushing string 0x%lx: `", (long) string_place); \ |
1317 DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ | 1317 DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ |
1318 size2); \ | 1318 size2); \ |
1319 DEBUG_PRINT1 ("'\n"); \ | 1319 DEBUG_PRINT1 ("'\n"); \ |
1320 PUSH_FAILURE_POINTER (string_place); \ | 1320 PUSH_FAILURE_POINTER (string_place); \ |
1321 \ | 1321 \ |
1385 saved NULL, thus retaining our current position in the string. */ \ | 1385 saved NULL, thus retaining our current position in the string. */ \ |
1386 string_temp = POP_FAILURE_POINTER (); \ | 1386 string_temp = POP_FAILURE_POINTER (); \ |
1387 if (string_temp != NULL) \ | 1387 if (string_temp != NULL) \ |
1388 str = (CONST char *) string_temp; \ | 1388 str = (CONST char *) string_temp; \ |
1389 \ | 1389 \ |
1390 DEBUG_PRINT2 (" Popping string 0x%p: `", str); \ | 1390 DEBUG_PRINT2 (" Popping string 0x%lx: `", (long) str); \ |
1391 DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ | 1391 DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ |
1392 DEBUG_PRINT1 ("'\n"); \ | 1392 DEBUG_PRINT1 ("'\n"); \ |
1393 \ | 1393 \ |
1394 pat = (unsigned char *) POP_FAILURE_POINTER (); \ | 1394 pat = (unsigned char *) POP_FAILURE_POINTER (); \ |
1395 DEBUG_PRINT2 (" Popping pattern 0x%p: ", pat); \ | 1395 DEBUG_PRINT2 (" Popping pattern 0x%lx: ", (long) pat); \ |
1396 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | 1396 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ |
1397 \ | 1397 \ |
1398 /* Restore register info. */ \ | 1398 /* Restore register info. */ \ |
1399 high_reg = (unsigned) POP_FAILURE_INT (); \ | 1399 high_reg = (unsigned) POP_FAILURE_INT (); \ |
1400 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | 1400 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ |
1406 { \ | 1406 { \ |
1407 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ | 1407 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ |
1408 \ | 1408 \ |
1409 reg_info[this_reg].word = POP_FAILURE_ELT (); \ | 1409 reg_info[this_reg].word = POP_FAILURE_ELT (); \ |
1410 DEBUG_PRINT2 (" info: 0x%lx\n", \ | 1410 DEBUG_PRINT2 (" info: 0x%lx\n", \ |
1411 * (unsigned long *) ®_info[this_reg]); \ | 1411 * (long *) ®_info[this_reg]); \ |
1412 \ | 1412 \ |
1413 regend[this_reg] = (CONST char *) POP_FAILURE_POINTER (); \ | 1413 regend[this_reg] = (CONST char *) POP_FAILURE_POINTER (); \ |
1414 DEBUG_PRINT2 (" end: 0x%p\n", regend[this_reg]); \ | 1414 DEBUG_PRINT2 (" end: 0x%lx\n", (long) regend[this_reg]); \ |
1415 \ | 1415 \ |
1416 regstart[this_reg] = (CONST char *) POP_FAILURE_POINTER (); \ | 1416 regstart[this_reg] = (CONST char *) POP_FAILURE_POINTER (); \ |
1417 DEBUG_PRINT2 (" start: 0x%p\n", regstart[this_reg]); \ | 1417 DEBUG_PRINT2 (" start: 0x%lx\n", (long) regstart[this_reg]); \ |
1418 } \ | 1418 } \ |
1419 \ | 1419 \ |
1420 set_regs_matched_done = 0; \ | 1420 set_regs_matched_done = 0; \ |
1421 DEBUG_STATEMENT (nfailure_points_popped++); \ | 1421 DEBUG_STATEMENT (nfailure_points_popped++); \ |
1422 } /* POP_FAILURE_POINT */ | 1422 } /* POP_FAILURE_POINT */ |
3313 /* If the start is after the end, the range is empty. */ | 3313 /* If the start is after the end, the range is empty. */ |
3314 if (range_start > range_end) | 3314 if (range_start > range_end) |
3315 return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | 3315 return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; |
3316 | 3316 |
3317 /* Can't have ranges spanning different charsets, except maybe for | 3317 /* Can't have ranges spanning different charsets, except maybe for |
3318 ranges entirely witin the first 256 chars. */ | 3318 ranges entirely within the first 256 chars. */ |
3319 | 3319 |
3320 if ((range_start >= 0x100 || range_end >= 0x100) | 3320 if ((range_start >= 0x100 || range_end >= 0x100) |
3321 && CHAR_LEADING_BYTE (range_start) != | 3321 && CHAR_LEADING_BYTE (range_start) != |
3322 CHAR_LEADING_BYTE (range_end)) | 3322 CHAR_LEADING_BYTE (range_end)) |
3323 return REG_ERANGESPAN; | 3323 return REG_ERANGESPAN; |
4471 /* This loops over pattern commands. It exits by returning from the | 4471 /* This loops over pattern commands. It exits by returning from the |
4472 function if the match is complete, or it drops through if the match | 4472 function if the match is complete, or it drops through if the match |
4473 fails at this starting point in the input data. */ | 4473 fails at this starting point in the input data. */ |
4474 for (;;) | 4474 for (;;) |
4475 { | 4475 { |
4476 DEBUG_PRINT2 ("\n0x%p: ", p); | 4476 DEBUG_PRINT2 ("\n0x%lx: ", (long) p); |
4477 #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | 4477 #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ |
4478 if (!no_quit_in_re_search) | 4478 if (!no_quit_in_re_search) |
4479 QUIT; | 4479 QUIT; |
4480 #endif | 4480 #endif |
4481 | 4481 |
5082 case; that seems worse than this. */ | 5082 case; that seems worse than this. */ |
5083 case on_failure_keep_string_jump: | 5083 case on_failure_keep_string_jump: |
5084 DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | 5084 DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); |
5085 | 5085 |
5086 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5086 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5087 DEBUG_PRINT3 (" %d (to 0x%p):\n", mcnt, p + mcnt); | 5087 DEBUG_PRINT3 (" %d (to 0x%lx):\n", mcnt, (long) (p + mcnt)); |
5088 | 5088 |
5089 PUSH_FAILURE_POINT (p + mcnt, (char *) 0, -2); | 5089 PUSH_FAILURE_POINT (p + mcnt, (char *) 0, -2); |
5090 break; | 5090 break; |
5091 | 5091 |
5092 | 5092 |
5105 case on_failure_jump: | 5105 case on_failure_jump: |
5106 on_failure: | 5106 on_failure: |
5107 DEBUG_PRINT1 ("EXECUTING on_failure_jump"); | 5107 DEBUG_PRINT1 ("EXECUTING on_failure_jump"); |
5108 | 5108 |
5109 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5109 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5110 DEBUG_PRINT3 (" %d (to 0x%p)", mcnt, p + mcnt); | 5110 DEBUG_PRINT3 (" %d (to 0x%lx)", mcnt, (long) (p + mcnt)); |
5111 | 5111 |
5112 /* If this on_failure_jump comes right before a group (i.e., | 5112 /* If this on_failure_jump comes right before a group (i.e., |
5113 the original * applied to a group), save the information | 5113 the original * applied to a group), save the information |
5114 for that group and all inner ones, so that if we fail back | 5114 for that group and all inner ones, so that if we fail back |
5115 to this point, the group's information will be correct. | 5115 to this point, the group's information will be correct. |
5320 case jump: | 5320 case jump: |
5321 unconditional_jump: | 5321 unconditional_jump: |
5322 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | 5322 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ |
5323 DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); | 5323 DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); |
5324 p += mcnt; /* Do the jump. */ | 5324 p += mcnt; /* Do the jump. */ |
5325 DEBUG_PRINT2 ("(to 0x%p).\n", p); | 5325 DEBUG_PRINT2 ("(to 0x%lx).\n", (long) p); |
5326 break; | 5326 break; |
5327 | 5327 |
5328 | 5328 |
5329 /* We need this opcode so we can detect where alternatives end | 5329 /* We need this opcode so we can detect where alternatives end |
5330 in `group_match_null_string_p' et al. */ | 5330 in `group_match_null_string_p' et al. */ |
5369 if (mcnt > 0) | 5369 if (mcnt > 0) |
5370 { | 5370 { |
5371 mcnt--; | 5371 mcnt--; |
5372 p += 2; | 5372 p += 2; |
5373 STORE_NUMBER_AND_INCR (p, mcnt); | 5373 STORE_NUMBER_AND_INCR (p, mcnt); |
5374 DEBUG_PRINT3 (" Setting 0x%p to %d.\n", p, mcnt); | 5374 DEBUG_PRINT3 (" Setting 0x%lx to %d.\n", (long) p, mcnt); |
5375 } | 5375 } |
5376 else if (mcnt == 0) | 5376 else if (mcnt == 0) |
5377 { | 5377 { |
5378 DEBUG_PRINT2 (" Setting two bytes from 0x%p to no_op.\n", p+2); | 5378 DEBUG_PRINT2 (" Setting two bytes from 0x%lx to no_op.\n", |
5379 (long) (p+2)); | |
5379 p[2] = (unsigned char) no_op; | 5380 p[2] = (unsigned char) no_op; |
5380 p[3] = (unsigned char) no_op; | 5381 p[3] = (unsigned char) no_op; |
5381 goto on_failure; | 5382 goto on_failure; |
5382 } | 5383 } |
5383 break; | 5384 break; |
5403 DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); | 5404 DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); |
5404 | 5405 |
5405 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5406 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5406 p1 = p + mcnt; | 5407 p1 = p + mcnt; |
5407 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5408 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5408 DEBUG_PRINT3 (" Setting 0x%p to %d.\n", p1, mcnt); | 5409 DEBUG_PRINT3 (" Setting 0x%lx to %d.\n", (long) p1, mcnt); |
5409 STORE_NUMBER (p1, mcnt); | 5410 STORE_NUMBER (p1, mcnt); |
5410 break; | 5411 break; |
5411 } | 5412 } |
5412 | 5413 |
5413 case wordbound: | 5414 case wordbound: |