Mercurial > hg > xemacs-beta
comparison src/regex.c @ 5041:efaa6cd845e5
add regexp-debugging
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-15 Ben Wing <ben@xemacs.org>
* regex.c:
* regex.c (DEBUG_FAIL_PRINT1):
* regex.c (PUSH_FAILURE_POINT):
* regex.c (POP_FAILURE_POINT):
* regex.c (regex_compile):
* regex.c (re_match_2_internal):
* regex.h:
* search.c:
* search.c (search_buffer):
* search.c (debug_regexps_changed):
* search.c (vars_of_search):
Add an internal variable debug_regexps and a corresponding Lisp
variable `debug-regexps' that takes a list of areas in which to
display debugging info about regex compilation and matching
(currently three areas exist). Use existing debugging code
already in regex.c and modify it so that it recognizes the
debug_regexps variable and the flags in it.
Rename variable `debug-xemacs-searches' to just `debug-searches',
consistent with other debug vars.
tests/ChangeLog addition:
2010-02-15 Ben Wing <ben@xemacs.org>
* automated/search-tests.el (let):
* automated/search-tests.el (boundp):
debug-xemacs-searches renamed to debug-searches.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 15 Feb 2010 21:51:22 -0600 |
parents | 16112448d484 |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
5027:22179cd0fe15 | 5041:efaa6cd845e5 |
---|---|
3 (Implements POSIX draft P10003.2/D11.2, except for | 3 (Implements POSIX draft P10003.2/D11.2, except for |
4 internationalization features.) | 4 internationalization features.) |
5 | 5 |
6 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. | 6 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
7 Copyright (C) 1995 Sun Microsystems, Inc. | 7 Copyright (C) 1995 Sun Microsystems, Inc. |
8 Copyright (C) 1995, 2001, 2002, 2003 Ben Wing. | 8 Copyright (C) 1995, 2001, 2002, 2003, 2010 Ben Wing. |
9 | 9 |
10 This program is free software; you can redistribute it and/or modify | 10 This program is free software; you can redistribute it and/or modify |
11 it under the terms of the GNU General Public License as published by | 11 it under the terms of the GNU General Public License as published by |
12 the Free Software Foundation; either version 2, or (at your option) | 12 the Free Software Foundation; either version 2, or (at your option) |
13 any later version. | 13 any later version. |
732 /* XEmacs provides its own version of assert() */ | 732 /* XEmacs provides its own version of assert() */ |
733 /* It is useful to test things that ``must'' be true when debugging. */ | 733 /* It is useful to test things that ``must'' be true when debugging. */ |
734 #include <assert.h> | 734 #include <assert.h> |
735 #endif | 735 #endif |
736 | 736 |
737 static int debug = 0; | 737 extern int debug_regexps; |
738 | 738 |
739 #define DEBUG_STATEMENT(e) e | 739 #define DEBUG_STATEMENT(e) e |
740 #define DEBUG_PRINT1(x) if (debug) printf (x) | 740 |
741 #define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) | 741 #define DEBUG_PRINT1(x) if (debug_regexps) printf (x) |
742 #define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) | 742 #define DEBUG_PRINT2(x1, x2) if (debug_regexps) printf (x1, x2) |
743 #define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) | 743 #define DEBUG_PRINT3(x1, x2, x3) if (debug_regexps) printf (x1, x2, x3) |
744 #define DEBUG_PRINT4(x1, x2, x3, x4) if (debug_regexps) printf (x1, x2, x3, x4) | |
744 #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ | 745 #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ |
745 if (debug) print_partial_compiled_pattern (s, e) | 746 if (debug_regexps) print_partial_compiled_pattern (s, e) |
746 #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ | 747 #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ |
747 if (debug) print_double_string (w, s1, sz1, s2, sz2) | 748 if (debug_regexps) print_double_string (w, s1, sz1, s2, sz2) |
749 | |
750 #define DEBUG_FAIL_PRINT1(x) \ | |
751 if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x) | |
752 #define DEBUG_FAIL_PRINT2(x1, x2) \ | |
753 if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | |
754 #define DEBUG_FAIL_PRINT3(x1, x2, x3) \ | |
755 if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2, x3) | |
756 #define DEBUG_FAIL_PRINT4(x1, x2, x3, x4) \ | |
757 if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2, x3, x4) | |
758 #define DEBUG_FAIL_PRINT_COMPILED_PATTERN(p, s, e) \ | |
759 if (debug_regexps & RE_DEBUG_FAILURE_POINT) \ | |
760 print_partial_compiled_pattern (s, e) | |
761 #define DEBUG_FAIL_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ | |
762 if (debug_regexps & RE_DEBUG_FAILURE_POINT) \ | |
763 print_double_string (w, s1, sz1, s2, sz2) | |
764 | |
765 #define DEBUG_MATCH_PRINT1(x) \ | |
766 if (debug_regexps & RE_DEBUG_MATCHING) printf (x) | |
767 #define DEBUG_MATCH_PRINT2(x1, x2) \ | |
768 if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | |
769 #define DEBUG_MATCH_PRINT3(x1, x2, x3) \ | |
770 if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2, x3) | |
771 #define DEBUG_MATCH_PRINT4(x1, x2, x3, x4) \ | |
772 if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2, x3, x4) | |
773 #define DEBUG_MATCH_PRINT_COMPILED_PATTERN(p, s, e) \ | |
774 if (debug_regexps & RE_DEBUG_MATCHING) \ | |
775 print_partial_compiled_pattern (s, e) | |
776 #define DEBUG_MATCH_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ | |
777 if (debug_regexps & RE_DEBUG_MATCHING) \ | |
778 print_double_string (w, s1, sz1, s2, sz2) | |
748 | 779 |
749 | 780 |
750 /* Print the fastmap in human-readable form. */ | 781 /* Print the fastmap in human-readable form. */ |
751 | 782 |
752 static void | 783 static void |
1131 #undef assert | 1162 #undef assert |
1132 #define assert(e) ((void) (1)) | 1163 #define assert(e) ((void) (1)) |
1133 #endif | 1164 #endif |
1134 | 1165 |
1135 #define DEBUG_STATEMENT(e) | 1166 #define DEBUG_STATEMENT(e) |
1167 | |
1136 #define DEBUG_PRINT1(x) | 1168 #define DEBUG_PRINT1(x) |
1137 #define DEBUG_PRINT2(x1, x2) | 1169 #define DEBUG_PRINT2(x1, x2) |
1138 #define DEBUG_PRINT3(x1, x2, x3) | 1170 #define DEBUG_PRINT3(x1, x2, x3) |
1139 #define DEBUG_PRINT4(x1, x2, x3, x4) | 1171 #define DEBUG_PRINT4(x1, x2, x3, x4) |
1140 #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) | 1172 #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) |
1141 #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) | 1173 #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) |
1174 | |
1175 #define DEBUG_FAIL_PRINT1(x) | |
1176 #define DEBUG_FAIL_PRINT2(x1, x2) | |
1177 #define DEBUG_FAIL_PRINT3(x1, x2, x3) | |
1178 #define DEBUG_FAIL_PRINT4(x1, x2, x3, x4) | |
1179 #define DEBUG_FAIL_PRINT_COMPILED_PATTERN(p, s, e) | |
1180 #define DEBUG_FAIL_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) | |
1181 | |
1182 #define DEBUG_MATCH_PRINT1(x) | |
1183 #define DEBUG_MATCH_PRINT2(x1, x2) | |
1184 #define DEBUG_MATCH_PRINT3(x1, x2, x3) | |
1185 #define DEBUG_MATCH_PRINT4(x1, x2, x3, x4) | |
1186 #define DEBUG_MATCH_PRINT_COMPILED_PATTERN(p, s, e) | |
1187 #define DEBUG_MATCH_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) | |
1142 | 1188 |
1143 #endif /* DEBUG */ | 1189 #endif /* DEBUG */ |
1144 | 1190 |
1145 /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can | 1191 /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can |
1146 also be assigned to arbitrarily: each pattern buffer stores its own | 1192 also be assigned to arbitrarily: each pattern buffer stores its own |
1521 of 0 + -1 isn't done as unsigned. */ \ | 1567 of 0 + -1 isn't done as unsigned. */ \ |
1522 int this_reg; \ | 1568 int this_reg; \ |
1523 \ | 1569 \ |
1524 DEBUG_STATEMENT (failure_id++); \ | 1570 DEBUG_STATEMENT (failure_id++); \ |
1525 DEBUG_STATEMENT (nfailure_points_pushed++); \ | 1571 DEBUG_STATEMENT (nfailure_points_pushed++); \ |
1526 DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%d:\n", failure_id); \ | 1572 DEBUG_FAIL_PRINT2 ("\nPUSH_FAILURE_POINT #%d:\n", failure_id); \ |
1527 DEBUG_PRINT2 (" Before push, next avail: %ld\n", \ | 1573 DEBUG_FAIL_PRINT2 (" Before push, next avail: %ld\n", \ |
1528 (long) (fail_stack).avail); \ | 1574 (long) (fail_stack).avail); \ |
1529 DEBUG_PRINT2 (" size: %ld\n", \ | 1575 DEBUG_FAIL_PRINT2 (" size: %ld\n", \ |
1530 (long) (fail_stack).size); \ | 1576 (long) (fail_stack).size); \ |
1531 \ | 1577 \ |
1532 DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ | 1578 DEBUG_FAIL_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ |
1533 DEBUG_PRINT2 (" available: %ld\n", \ | 1579 DEBUG_FAIL_PRINT2 (" available: %ld\n", \ |
1534 (long) REMAINING_AVAIL_SLOTS); \ | 1580 (long) REMAINING_AVAIL_SLOTS); \ |
1535 \ | 1581 \ |
1536 /* Ensure we have enough space allocated for what we will push. */ \ | 1582 /* Ensure we have enough space allocated for what we will push. */ \ |
1537 while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ | 1583 while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ |
1538 { \ | 1584 { \ |
1542 END_REGEX_MALLOC_OK (); \ | 1588 END_REGEX_MALLOC_OK (); \ |
1543 UNBIND_REGEX_MALLOC_CHECK (); \ | 1589 UNBIND_REGEX_MALLOC_CHECK (); \ |
1544 return failure_code; \ | 1590 return failure_code; \ |
1545 } \ | 1591 } \ |
1546 END_REGEX_MALLOC_OK (); \ | 1592 END_REGEX_MALLOC_OK (); \ |
1547 DEBUG_PRINT2 ("\n Doubled stack; size now: %ld\n", \ | 1593 DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %ld\n", \ |
1548 (long) (fail_stack).size); \ | 1594 (long) (fail_stack).size); \ |
1549 DEBUG_PRINT2 (" slots available: %ld\n", \ | 1595 DEBUG_FAIL_PRINT2 (" slots available: %ld\n", \ |
1550 (long) REMAINING_AVAIL_SLOTS); \ | 1596 (long) REMAINING_AVAIL_SLOTS); \ |
1551 \ | 1597 \ |
1552 RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); \ | 1598 RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); \ |
1553 } \ | 1599 } \ |
1554 \ | 1600 \ |
1555 /* Push the info, starting with the registers. */ \ | 1601 /* Push the info, starting with the registers. */ \ |
1556 DEBUG_PRINT1 ("\n"); \ | 1602 DEBUG_FAIL_PRINT1 ("\n"); \ |
1557 \ | 1603 \ |
1558 for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ | 1604 for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ |
1559 this_reg++) \ | 1605 this_reg++) \ |
1560 { \ | 1606 { \ |
1561 DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ | 1607 DEBUG_FAIL_PRINT2 (" Pushing reg: %d\n", this_reg); \ |
1562 DEBUG_STATEMENT (num_regs_pushed++); \ | 1608 DEBUG_STATEMENT (num_regs_pushed++); \ |
1563 \ | 1609 \ |
1564 DEBUG_PRINT2 (" start: 0x%lx\n", (long) regstart[this_reg]); \ | 1610 DEBUG_FAIL_PRINT2 (" start: 0x%lx\n", (long) regstart[this_reg]); \ |
1565 PUSH_FAILURE_POINTER (regstart[this_reg]); \ | 1611 PUSH_FAILURE_POINTER (regstart[this_reg]); \ |
1566 \ | 1612 \ |
1567 DEBUG_PRINT2 (" end: 0x%lx\n", (long) regend[this_reg]); \ | 1613 DEBUG_FAIL_PRINT2 (" end: 0x%lx\n", (long) regend[this_reg]); \ |
1568 PUSH_FAILURE_POINTER (regend[this_reg]); \ | 1614 PUSH_FAILURE_POINTER (regend[this_reg]); \ |
1569 \ | 1615 \ |
1570 DEBUG_PRINT2 (" info: 0x%lx\n ", \ | 1616 DEBUG_FAIL_PRINT2 (" info: 0x%lx\n ", \ |
1571 * (long *) (®_info[this_reg])); \ | 1617 * (long *) (®_info[this_reg])); \ |
1572 DEBUG_PRINT2 (" match_null=%d", \ | 1618 DEBUG_FAIL_PRINT2 (" match_null=%d", \ |
1573 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ | 1619 REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ |
1574 DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ | 1620 DEBUG_FAIL_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ |
1575 DEBUG_PRINT2 (" matched_something=%d", \ | 1621 DEBUG_FAIL_PRINT2 (" matched_something=%d", \ |
1576 MATCHED_SOMETHING (reg_info[this_reg])); \ | 1622 MATCHED_SOMETHING (reg_info[this_reg])); \ |
1577 DEBUG_PRINT2 (" ever_matched_something=%d", \ | 1623 DEBUG_FAIL_PRINT2 (" ever_matched_something=%d", \ |
1578 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ | 1624 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ |
1579 DEBUG_PRINT1 ("\n"); \ | 1625 DEBUG_FAIL_PRINT1 ("\n"); \ |
1580 PUSH_FAILURE_ELT (reg_info[this_reg].word); \ | 1626 PUSH_FAILURE_ELT (reg_info[this_reg].word); \ |
1581 } \ | 1627 } \ |
1582 \ | 1628 \ |
1583 DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg); \ | 1629 DEBUG_FAIL_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg); \ |
1584 PUSH_FAILURE_INT (lowest_active_reg); \ | 1630 PUSH_FAILURE_INT (lowest_active_reg); \ |
1585 \ | 1631 \ |
1586 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg); \ | 1632 DEBUG_FAIL_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg); \ |
1587 PUSH_FAILURE_INT (highest_active_reg); \ | 1633 PUSH_FAILURE_INT (highest_active_reg); \ |
1588 \ | 1634 \ |
1589 DEBUG_PRINT2 (" Pushing pattern 0x%lx: \n", (long) pattern_place); \ | 1635 DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%lx: \n", (long) pattern_place); \ |
1590 DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | 1636 DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ |
1591 PUSH_FAILURE_POINTER (pattern_place); \ | 1637 PUSH_FAILURE_POINTER (pattern_place); \ |
1592 \ | 1638 \ |
1593 DEBUG_PRINT2 (" Pushing string 0x%lx: `", (long) string_place); \ | 1639 DEBUG_FAIL_PRINT2 (" Pushing string 0x%lx: `", (long) string_place); \ |
1594 DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ | 1640 DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ |
1595 size2); \ | 1641 size2); \ |
1596 DEBUG_PRINT1 ("'\n"); \ | 1642 DEBUG_FAIL_PRINT1 ("'\n"); \ |
1597 PUSH_FAILURE_POINTER (string_place); \ | 1643 PUSH_FAILURE_POINTER (string_place); \ |
1598 \ | 1644 \ |
1599 DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | 1645 DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ |
1600 DEBUG_PUSH (failure_id); \ | 1646 DEBUG_PUSH (failure_id); \ |
1601 } while (0) | 1647 } while (0) |
1602 | 1648 |
1603 /* This is the number of items that are pushed and popped on the stack | 1649 /* This is the number of items that are pushed and popped on the stack |
1604 for each register. */ | 1650 for each register. */ |
1646 const unsigned char *string_temp; \ | 1692 const unsigned char *string_temp; \ |
1647 \ | 1693 \ |
1648 assert (!FAIL_STACK_EMPTY ()); \ | 1694 assert (!FAIL_STACK_EMPTY ()); \ |
1649 \ | 1695 \ |
1650 /* Remove failure points and point to how many regs pushed. */ \ | 1696 /* Remove failure points and point to how many regs pushed. */ \ |
1651 DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ | 1697 DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ |
1652 DEBUG_PRINT2 (" Before pop, next avail: %ld\n", \ | 1698 DEBUG_FAIL_PRINT2 (" Before pop, next avail: %ld\n", \ |
1653 (long) fail_stack.avail); \ | 1699 (long) fail_stack.avail); \ |
1654 DEBUG_PRINT2 (" size: %ld\n", \ | 1700 DEBUG_FAIL_PRINT2 (" size: %ld\n", \ |
1655 (long) fail_stack.size); \ | 1701 (long) fail_stack.size); \ |
1656 \ | 1702 \ |
1657 assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | 1703 assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ |
1658 \ | 1704 \ |
1659 DEBUG_POP (&ffailure_id.integer); \ | 1705 DEBUG_POP (&ffailure_id.integer); \ |
1660 DEBUG_PRINT2 (" Popping failure id: %d\n", \ | 1706 DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", \ |
1661 * (int *) &ffailure_id); \ | 1707 * (int *) &ffailure_id); \ |
1662 \ | 1708 \ |
1663 /* If the saved string location is NULL, it came from an \ | 1709 /* If the saved string location is NULL, it came from an \ |
1664 on_failure_keep_string_jump opcode, and we want to throw away the \ | 1710 on_failure_keep_string_jump opcode, and we want to throw away the \ |
1665 saved NULL, thus retaining our current position in the string. */ \ | 1711 saved NULL, thus retaining our current position in the string. */ \ |
1666 string_temp = POP_FAILURE_POINTER (); \ | 1712 string_temp = POP_FAILURE_POINTER (); \ |
1667 if (string_temp != NULL) \ | 1713 if (string_temp != NULL) \ |
1668 str = string_temp; \ | 1714 str = string_temp; \ |
1669 \ | 1715 \ |
1670 DEBUG_PRINT2 (" Popping string 0x%lx: `", (long) str); \ | 1716 DEBUG_FAIL_PRINT2 (" Popping string 0x%lx: `", (long) str); \ |
1671 DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ | 1717 DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ |
1672 DEBUG_PRINT1 ("'\n"); \ | 1718 DEBUG_FAIL_PRINT1 ("'\n"); \ |
1673 \ | 1719 \ |
1674 pat = (unsigned char *) POP_FAILURE_POINTER (); \ | 1720 pat = (unsigned char *) POP_FAILURE_POINTER (); \ |
1675 DEBUG_PRINT2 (" Popping pattern 0x%lx: ", (long) pat); \ | 1721 DEBUG_FAIL_PRINT2 (" Popping pattern 0x%lx: ", (long) pat); \ |
1676 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | 1722 DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ |
1677 \ | 1723 \ |
1678 /* Restore register info. */ \ | 1724 /* Restore register info. */ \ |
1679 high_reg = POP_FAILURE_INT (); \ | 1725 high_reg = POP_FAILURE_INT (); \ |
1680 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | 1726 DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ |
1681 \ | 1727 \ |
1682 low_reg = POP_FAILURE_INT (); \ | 1728 low_reg = POP_FAILURE_INT (); \ |
1683 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | 1729 DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ |
1684 \ | 1730 \ |
1685 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | 1731 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ |
1686 { \ | 1732 { \ |
1687 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ | 1733 DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ |
1688 \ | 1734 \ |
1689 reg_info[this_reg].word = POP_FAILURE_ELT (); \ | 1735 reg_info[this_reg].word = POP_FAILURE_ELT (); \ |
1690 DEBUG_PRINT2 (" info: 0x%lx\n", \ | 1736 DEBUG_FAIL_PRINT2 (" info: 0x%lx\n", \ |
1691 * (long *) ®_info[this_reg]); \ | 1737 * (long *) ®_info[this_reg]); \ |
1692 \ | 1738 \ |
1693 regend[this_reg] = POP_FAILURE_POINTER (); \ | 1739 regend[this_reg] = POP_FAILURE_POINTER (); \ |
1694 DEBUG_PRINT2 (" end: 0x%lx\n", (long) regend[this_reg]); \ | 1740 DEBUG_FAIL_PRINT2 (" end: 0x%lx\n", (long) regend[this_reg]); \ |
1695 \ | 1741 \ |
1696 regstart[this_reg] = POP_FAILURE_POINTER (); \ | 1742 regstart[this_reg] = POP_FAILURE_POINTER (); \ |
1697 DEBUG_PRINT2 (" start: 0x%lx\n", (long) regstart[this_reg]); \ | 1743 DEBUG_FAIL_PRINT2 (" start: 0x%lx\n", (long) regstart[this_reg]); \ |
1698 } \ | 1744 } \ |
1699 \ | 1745 \ |
1700 set_regs_matched_done = 0; \ | 1746 set_regs_matched_done = 0; \ |
1701 DEBUG_STATEMENT (nfailure_points_popped++); \ | 1747 DEBUG_STATEMENT (nfailure_points_popped++); \ |
1702 } while (0) /* POP_FAILURE_POINT */ | 1748 } while (0) /* POP_FAILURE_POINT */ |
2155 matching close-group on the compile stack, so the same register | 2201 matching close-group on the compile stack, so the same register |
2156 number is put in the stop_memory as the start_memory. */ | 2202 number is put in the stop_memory as the start_memory. */ |
2157 regnum_t regnum = 0; | 2203 regnum_t regnum = 0; |
2158 | 2204 |
2159 #ifdef DEBUG | 2205 #ifdef DEBUG |
2160 DEBUG_PRINT1 ("\nCompiling pattern: "); | 2206 if (debug_regexps & RE_DEBUG_COMPILATION) |
2161 if (debug) | |
2162 { | 2207 { |
2163 int debug_count; | 2208 int debug_count; |
2164 | 2209 |
2210 DEBUG_PRINT1 ("\nCompiling pattern: "); | |
2165 for (debug_count = 0; debug_count < size; debug_count++) | 2211 for (debug_count = 0; debug_count < size; debug_count++) |
2166 putchar (pattern[debug_count]); | 2212 putchar (pattern[debug_count]); |
2167 putchar ('\n'); | 2213 putchar ('\n'); |
2168 } | 2214 } |
2169 #endif /* DEBUG */ | 2215 #endif /* DEBUG */ |
3403 | 3449 |
3404 /* We have succeeded; set the length of the buffer. */ | 3450 /* We have succeeded; set the length of the buffer. */ |
3405 bufp->used = buf_end - bufp->buffer; | 3451 bufp->used = buf_end - bufp->buffer; |
3406 | 3452 |
3407 #ifdef DEBUG | 3453 #ifdef DEBUG |
3408 if (debug) | 3454 if (debug_regexps & RE_DEBUG_COMPILATION) |
3409 { | 3455 { |
3410 DEBUG_PRINT1 ("\nCompiled pattern: \n"); | 3456 DEBUG_PRINT1 ("\nCompiled pattern: \n"); |
3411 print_compiled_pattern (bufp); | 3457 print_compiled_pattern (bufp); |
3412 } | 3458 } |
3413 #endif /* DEBUG */ | 3459 #endif /* DEBUG */ |
4904 #ifdef ERROR_CHECK_MALLOC | 4950 #ifdef ERROR_CHECK_MALLOC |
4905 int depth = bind_regex_malloc_disallowed (1); | 4951 int depth = bind_regex_malloc_disallowed (1); |
4906 #endif | 4952 #endif |
4907 #endif /* emacs */ | 4953 #endif /* emacs */ |
4908 | 4954 |
4909 DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); | 4955 DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); |
4910 | 4956 |
4911 BEGIN_REGEX_MALLOC_OK (); | 4957 BEGIN_REGEX_MALLOC_OK (); |
4912 INIT_FAIL_STACK (); | 4958 INIT_FAIL_STACK (); |
4913 END_REGEX_MALLOC_OK (); | 4959 END_REGEX_MALLOC_OK (); |
4914 | 4960 |
5022 { | 5068 { |
5023 d = string2 + pos - size1; | 5069 d = string2 + pos - size1; |
5024 dend = end_match_2; | 5070 dend = end_match_2; |
5025 } | 5071 } |
5026 | 5072 |
5027 DEBUG_PRINT1 ("The compiled pattern is: \n"); | 5073 DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); |
5028 DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); | 5074 DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); |
5029 DEBUG_PRINT1 ("The string to match is: `"); | 5075 DEBUG_MATCH_PRINT1 ("The string to match is: `"); |
5030 DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | 5076 DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); |
5031 DEBUG_PRINT1 ("'\n"); | 5077 DEBUG_MATCH_PRINT1 ("'\n"); |
5032 | 5078 |
5033 /* This loops over pattern commands. It exits by returning from the | 5079 /* This loops over pattern commands. It exits by returning from the |
5034 function if the match is complete, or it drops through if the match | 5080 function if the match is complete, or it drops through if the match |
5035 fails at this starting point in the input data. */ | 5081 fails at this starting point in the input data. */ |
5036 for (;;) | 5082 for (;;) |
5037 { | 5083 { |
5038 DEBUG_PRINT2 ("\n0x%lx: ", (long) p); | 5084 DEBUG_MATCH_PRINT2 ("\n0x%lx: ", (long) p); |
5039 #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | 5085 #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ |
5040 if (!no_quit_in_re_search) | 5086 if (!no_quit_in_re_search) |
5041 { | 5087 { |
5042 BEGIN_REGEX_MALLOC_OK (); | 5088 BEGIN_REGEX_MALLOC_OK (); |
5043 QUIT; | 5089 QUIT; |
5046 } | 5092 } |
5047 #endif | 5093 #endif |
5048 | 5094 |
5049 if (p == pend) | 5095 if (p == pend) |
5050 { /* End of pattern means we might have succeeded. */ | 5096 { /* End of pattern means we might have succeeded. */ |
5051 DEBUG_PRINT1 ("end of pattern ... "); | 5097 DEBUG_MATCH_PRINT1 ("end of pattern ... "); |
5052 | 5098 |
5053 /* If we haven't matched the entire string, and we want the | 5099 /* If we haven't matched the entire string, and we want the |
5054 longest match, try backtracking. */ | 5100 longest match, try backtracking. */ |
5055 if (d != end_match_2) | 5101 if (d != end_match_2) |
5056 { | 5102 { |
5062 if (same_str_p) | 5108 if (same_str_p) |
5063 best_match_p = d > match_end; | 5109 best_match_p = d > match_end; |
5064 else | 5110 else |
5065 best_match_p = !MATCHING_IN_FIRST_STRING; | 5111 best_match_p = !MATCHING_IN_FIRST_STRING; |
5066 | 5112 |
5067 DEBUG_PRINT1 ("backtracking.\n"); | 5113 DEBUG_MATCH_PRINT1 ("backtracking.\n"); |
5068 | 5114 |
5069 if (!FAIL_STACK_EMPTY ()) | 5115 if (!FAIL_STACK_EMPTY ()) |
5070 { /* More failure points to try. */ | 5116 { /* More failure points to try. */ |
5071 | 5117 |
5072 /* If exceeds best match so far, save it. */ | 5118 /* If exceeds best match so far, save it. */ |
5073 if (!best_regs_set || best_match_p) | 5119 if (!best_regs_set || best_match_p) |
5074 { | 5120 { |
5075 best_regs_set = true; | 5121 best_regs_set = true; |
5076 match_end = d; | 5122 match_end = d; |
5077 | 5123 |
5078 DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); | 5124 DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); |
5079 | 5125 |
5080 for (mcnt = 1; mcnt < num_regs; mcnt++) | 5126 for (mcnt = 1; mcnt < num_regs; mcnt++) |
5081 { | 5127 { |
5082 best_regstart[mcnt] = regstart[mcnt]; | 5128 best_regstart[mcnt] = regstart[mcnt]; |
5083 best_regend[mcnt] = regend[mcnt]; | 5129 best_regend[mcnt] = regend[mcnt]; |
5095 /* Restore best match. It may happen that `dend == | 5141 /* Restore best match. It may happen that `dend == |
5096 end_match_1' while the restored d is in string2. | 5142 end_match_1' while the restored d is in string2. |
5097 For example, the pattern `x.*y.*z' against the | 5143 For example, the pattern `x.*y.*z' against the |
5098 strings `x-' and `y-z-', if the two strings are | 5144 strings `x-' and `y-z-', if the two strings are |
5099 not consecutive in memory. */ | 5145 not consecutive in memory. */ |
5100 DEBUG_PRINT1 ("Restoring best registers.\n"); | 5146 DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); |
5101 | 5147 |
5102 d = match_end; | 5148 d = match_end; |
5103 dend = ((d >= string1 && d <= end1) | 5149 dend = ((d >= string1 && d <= end1) |
5104 ? end_match_1 : end_match_2); | 5150 ? end_match_1 : end_match_2); |
5105 | 5151 |
5110 } | 5156 } |
5111 } | 5157 } |
5112 } /* d != end_match_2 */ | 5158 } /* d != end_match_2 */ |
5113 | 5159 |
5114 succeed_label: | 5160 succeed_label: |
5115 DEBUG_PRINT1 ("Accepting match.\n"); | 5161 DEBUG_MATCH_PRINT1 ("Accepting match.\n"); |
5116 | 5162 |
5117 /* If caller wants register contents data back, do it. */ | 5163 /* If caller wants register contents data back, do it. */ |
5118 { | 5164 { |
5119 int num_nonshy_regs = bufp->re_nsub + 1; | 5165 int num_nonshy_regs = bufp->re_nsub + 1; |
5120 if (regs && !bufp->no_sub) | 5166 if (regs && !bufp->no_sub) |
5212 */ | 5258 */ |
5213 if (regs && regs->num_regs > 0) | 5259 if (regs && regs->num_regs > 0) |
5214 for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | 5260 for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) |
5215 regs->start[mcnt] = regs->end[mcnt] = -1; | 5261 regs->start[mcnt] = regs->end[mcnt] = -1; |
5216 } | 5262 } |
5217 DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | 5263 DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", |
5218 nfailure_points_pushed, nfailure_points_popped, | 5264 nfailure_points_pushed, nfailure_points_popped, |
5219 nfailure_points_pushed - nfailure_points_popped); | 5265 nfailure_points_pushed - nfailure_points_popped); |
5220 DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | 5266 DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); |
5221 | 5267 |
5222 mcnt = d - pos - (MATCHING_IN_FIRST_STRING | 5268 mcnt = d - pos - (MATCHING_IN_FIRST_STRING |
5223 ? string1 | 5269 ? string1 |
5224 : string2 - size1); | 5270 : string2 - size1); |
5225 | 5271 |
5226 DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | 5272 DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); |
5227 | 5273 |
5228 FREE_VARIABLES (); | 5274 FREE_VARIABLES (); |
5229 return mcnt; | 5275 return mcnt; |
5230 } | 5276 } |
5231 | 5277 |
5233 switch ((re_opcode_t) *p++) | 5279 switch ((re_opcode_t) *p++) |
5234 { | 5280 { |
5235 /* Ignore these. Used to ignore the n of succeed_n's which | 5281 /* Ignore these. Used to ignore the n of succeed_n's which |
5236 currently have n == 0. */ | 5282 currently have n == 0. */ |
5237 case no_op: | 5283 case no_op: |
5238 DEBUG_PRINT1 ("EXECUTING no_op.\n"); | 5284 DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); |
5239 break; | 5285 break; |
5240 | 5286 |
5241 case succeed: | 5287 case succeed: |
5242 DEBUG_PRINT1 ("EXECUTING succeed.\n"); | 5288 DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); |
5243 goto succeed_label; | 5289 goto succeed_label; |
5244 | 5290 |
5245 /* Match exactly a string of length n in the pattern. The | 5291 /* Match exactly a string of length n in the pattern. The |
5246 following byte in the pattern defines n, and the n bytes after | 5292 following byte in the pattern defines n, and the n bytes after |
5247 that make up the string to match. (Under Mule, this will be in | 5293 that make up the string to match. (Under Mule, this will be in |
5248 the default internal format.) */ | 5294 the default internal format.) */ |
5249 case exactn: | 5295 case exactn: |
5250 mcnt = *p++; | 5296 mcnt = *p++; |
5251 DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | 5297 DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); |
5252 | 5298 |
5253 /* This is written out as an if-else so we don't waste time | 5299 /* This is written out as an if-else so we don't waste time |
5254 testing `translate' inside the loop. */ | 5300 testing `translate' inside the loop. */ |
5255 if (TRANSLATE_P (translate)) | 5301 if (TRANSLATE_P (translate)) |
5256 { | 5302 { |
5319 break; | 5365 break; |
5320 | 5366 |
5321 | 5367 |
5322 /* Match any character except possibly a newline or a null. */ | 5368 /* Match any character except possibly a newline or a null. */ |
5323 case anychar: | 5369 case anychar: |
5324 DEBUG_PRINT1 ("EXECUTING anychar.\n"); | 5370 DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); |
5325 | 5371 |
5326 REGEX_PREFETCH (); | 5372 REGEX_PREFETCH (); |
5327 | 5373 |
5328 if ((!(bufp->syntax & RE_DOT_NEWLINE) && | 5374 if ((!(bufp->syntax & RE_DOT_NEWLINE) && |
5329 RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | 5375 RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') |
5331 RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | 5377 RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == |
5332 '\000')) | 5378 '\000')) |
5333 goto fail; | 5379 goto fail; |
5334 | 5380 |
5335 SET_REGS_MATCHED (); | 5381 SET_REGS_MATCHED (); |
5336 DEBUG_PRINT2 (" Matched `%d'.\n", *d); | 5382 DEBUG_MATCH_PRINT2 (" Matched `%d'.\n", *d); |
5337 INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | 5383 INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ |
5338 break; | 5384 break; |
5339 | 5385 |
5340 | 5386 |
5341 case charset: | 5387 case charset: |
5342 case charset_not: | 5388 case charset_not: |
5343 { | 5389 { |
5344 REGISTER Ichar c; | 5390 REGISTER Ichar c; |
5345 re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | 5391 re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; |
5346 | 5392 |
5347 DEBUG_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | 5393 DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); |
5348 | 5394 |
5349 REGEX_PREFETCH (); | 5395 REGEX_PREFETCH (); |
5350 c = itext_ichar_fmt (d, fmt, lispobj); | 5396 c = itext_ichar_fmt (d, fmt, lispobj); |
5351 c = RE_TRANSLATE (c); /* The character to match. */ | 5397 c = RE_TRANSLATE (c); /* The character to match. */ |
5352 | 5398 |
5370 case charset_mule_not: | 5416 case charset_mule_not: |
5371 { | 5417 { |
5372 REGISTER Ichar c; | 5418 REGISTER Ichar c; |
5373 re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | 5419 re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; |
5374 | 5420 |
5375 DEBUG_PRINT2 ("EXECUTING charset_mule%s.\n", not_p ? "_not" : ""); | 5421 DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", not_p ? "_not" : ""); |
5376 | 5422 |
5377 REGEX_PREFETCH (); | 5423 REGEX_PREFETCH (); |
5378 c = itext_ichar_fmt (d, fmt, lispobj); | 5424 c = itext_ichar_fmt (d, fmt, lispobj); |
5379 c = RE_TRANSLATE (c); /* The character to match. */ | 5425 c = RE_TRANSLATE (c); /* The character to match. */ |
5380 | 5426 |
5396 The arguments are the register number in the next byte, and the | 5442 The arguments are the register number in the next byte, and the |
5397 number of groups inner to this one in the next. The text | 5443 number of groups inner to this one in the next. The text |
5398 matched within the group is recorded (in the internal | 5444 matched within the group is recorded (in the internal |
5399 registers data structure) under the register number. */ | 5445 registers data structure) under the register number. */ |
5400 case start_memory: | 5446 case start_memory: |
5401 DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); | 5447 DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); |
5402 | 5448 |
5403 /* Find out if this group can match the empty string. */ | 5449 /* Find out if this group can match the empty string. */ |
5404 p1 = p; /* To send to group_match_null_string_p. */ | 5450 p1 = p; /* To send to group_match_null_string_p. */ |
5405 | 5451 |
5406 if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) | 5452 if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) |
5407 REG_MATCH_NULL_STRING_P (reg_info[*p]) | 5453 REG_MATCH_NULL_STRING_P (reg_info[*p]) |
5408 = group_match_null_string_p (&p1, pend, reg_info); | 5454 = group_match_null_string_p (&p1, pend, reg_info); |
5409 | 5455 |
5410 DEBUG_PRINT2 (" group CAN%s match null string\n", | 5456 DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", |
5411 REG_MATCH_NULL_STRING_P (reg_info[*p]) ? "NOT" : ""); | 5457 REG_MATCH_NULL_STRING_P (reg_info[*p]) ? "NOT" : ""); |
5412 | 5458 |
5413 /* Save the position in the string where we were the last time | 5459 /* Save the position in the string where we were the last time |
5414 we were at this open-group operator in case the group is | 5460 we were at this open-group operator in case the group is |
5415 operated upon by a repetition operator, e.g., with `(a*)*b' | 5461 operated upon by a repetition operator, e.g., with `(a*)*b' |
5416 against `ab'; then we want to ignore where we are now in | 5462 against `ab'; then we want to ignore where we are now in |
5417 the string in case this attempt to match fails. */ | 5463 the string in case this attempt to match fails. */ |
5418 old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) | 5464 old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) |
5419 ? REG_UNSET (regstart[*p]) ? d : regstart[*p] | 5465 ? REG_UNSET (regstart[*p]) ? d : regstart[*p] |
5420 : regstart[*p]; | 5466 : regstart[*p]; |
5421 DEBUG_PRINT2 (" old_regstart: %d\n", | 5467 DEBUG_MATCH_PRINT2 (" old_regstart: %d\n", |
5422 POINTER_TO_OFFSET (old_regstart[*p])); | 5468 POINTER_TO_OFFSET (old_regstart[*p])); |
5423 | 5469 |
5424 regstart[*p] = d; | 5470 regstart[*p] = d; |
5425 DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); | 5471 DEBUG_MATCH_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); |
5426 | 5472 |
5427 IS_ACTIVE (reg_info[*p]) = 1; | 5473 IS_ACTIVE (reg_info[*p]) = 1; |
5428 MATCHED_SOMETHING (reg_info[*p]) = 0; | 5474 MATCHED_SOMETHING (reg_info[*p]) = 0; |
5429 | 5475 |
5430 /* Clear this whenever we change the register activity status. */ | 5476 /* Clear this whenever we change the register activity status. */ |
5447 | 5493 |
5448 /* The stop_memory opcode represents the end of a group. Its | 5494 /* The stop_memory opcode represents the end of a group. Its |
5449 arguments are the same as start_memory's: the register | 5495 arguments are the same as start_memory's: the register |
5450 number, and the number of inner groups. */ | 5496 number, and the number of inner groups. */ |
5451 case stop_memory: | 5497 case stop_memory: |
5452 DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); | 5498 DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); |
5453 | 5499 |
5454 /* We need to save the string position the last time we were at | 5500 /* We need to save the string position the last time we were at |
5455 this close-group operator in case the group is operated | 5501 this close-group operator in case the group is operated |
5456 upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | 5502 upon by a repetition operator, e.g., with `((a*)*(b*)*)*' |
5457 against `aba'; then we want to ignore where we are now in | 5503 against `aba'; then we want to ignore where we are now in |
5458 the string in case this attempt to match fails. */ | 5504 the string in case this attempt to match fails. */ |
5459 old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) | 5505 old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) |
5460 ? REG_UNSET (regend[*p]) ? d : regend[*p] | 5506 ? REG_UNSET (regend[*p]) ? d : regend[*p] |
5461 : regend[*p]; | 5507 : regend[*p]; |
5462 DEBUG_PRINT2 (" old_regend: %d\n", | 5508 DEBUG_MATCH_PRINT2 (" old_regend: %d\n", |
5463 POINTER_TO_OFFSET (old_regend[*p])); | 5509 POINTER_TO_OFFSET (old_regend[*p])); |
5464 | 5510 |
5465 regend[*p] = d; | 5511 regend[*p] = d; |
5466 DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); | 5512 DEBUG_MATCH_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); |
5467 | 5513 |
5468 /* This register isn't active anymore. */ | 5514 /* This register isn't active anymore. */ |
5469 IS_ACTIVE (reg_info[*p]) = 0; | 5515 IS_ACTIVE (reg_info[*p]) = 0; |
5470 | 5516 |
5471 /* Clear this whenever we change the register activity status. */ | 5517 /* Clear this whenever we change the register activity status. */ |
5597 case duplicate: | 5643 case duplicate: |
5598 { | 5644 { |
5599 REGISTER re_char *d2, *dend2; | 5645 REGISTER re_char *d2, *dend2; |
5600 /* Get which register to match against. */ | 5646 /* Get which register to match against. */ |
5601 int regno = *p++; | 5647 int regno = *p++; |
5602 DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); | 5648 DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); |
5603 | 5649 |
5604 /* Can't back reference a group which we've never matched. */ | 5650 /* Can't back reference a group which we've never matched. */ |
5605 if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | 5651 if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) |
5606 goto fail; | 5652 goto fail; |
5607 | 5653 |
5664 | 5710 |
5665 /* begline matches the empty string at the beginning of the string | 5711 /* begline matches the empty string at the beginning of the string |
5666 (unless `not_bol' is set in `bufp'), and, if | 5712 (unless `not_bol' is set in `bufp'), and, if |
5667 `newline_anchor' is set, after newlines. */ | 5713 `newline_anchor' is set, after newlines. */ |
5668 case begline: | 5714 case begline: |
5669 DEBUG_PRINT1 ("EXECUTING begline.\n"); | 5715 DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); |
5670 | 5716 |
5671 if (AT_STRINGS_BEG (d)) | 5717 if (AT_STRINGS_BEG (d)) |
5672 { | 5718 { |
5673 if (!bufp->not_bol) break; | 5719 if (!bufp->not_bol) break; |
5674 } | 5720 } |
5684 goto fail; | 5730 goto fail; |
5685 | 5731 |
5686 | 5732 |
5687 /* endline is the dual of begline. */ | 5733 /* endline is the dual of begline. */ |
5688 case endline: | 5734 case endline: |
5689 DEBUG_PRINT1 ("EXECUTING endline.\n"); | 5735 DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); |
5690 | 5736 |
5691 if (AT_STRINGS_END (d)) | 5737 if (AT_STRINGS_END (d)) |
5692 { | 5738 { |
5693 if (!bufp->not_eol) break; | 5739 if (!bufp->not_eol) break; |
5694 } | 5740 } |
5704 goto fail; | 5750 goto fail; |
5705 | 5751 |
5706 | 5752 |
5707 /* Match at the very beginning of the data. */ | 5753 /* Match at the very beginning of the data. */ |
5708 case begbuf: | 5754 case begbuf: |
5709 DEBUG_PRINT1 ("EXECUTING begbuf.\n"); | 5755 DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); |
5710 if (AT_STRINGS_BEG (d)) | 5756 if (AT_STRINGS_BEG (d)) |
5711 break; | 5757 break; |
5712 goto fail; | 5758 goto fail; |
5713 | 5759 |
5714 | 5760 |
5715 /* Match at the very end of the data. */ | 5761 /* Match at the very end of the data. */ |
5716 case endbuf: | 5762 case endbuf: |
5717 DEBUG_PRINT1 ("EXECUTING endbuf.\n"); | 5763 DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); |
5718 if (AT_STRINGS_END (d)) | 5764 if (AT_STRINGS_END (d)) |
5719 break; | 5765 break; |
5720 goto fail; | 5766 goto fail; |
5721 | 5767 |
5722 | 5768 |
5735 share its code. The only reason to push anything on the | 5781 share its code. The only reason to push anything on the |
5736 stack at all is that otherwise we would have to change | 5782 stack at all is that otherwise we would have to change |
5737 `anychar's code to do something besides goto fail in this | 5783 `anychar's code to do something besides goto fail in this |
5738 case; that seems worse than this. */ | 5784 case; that seems worse than this. */ |
5739 case on_failure_keep_string_jump: | 5785 case on_failure_keep_string_jump: |
5740 DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | 5786 DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); |
5741 | 5787 |
5742 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5788 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5743 DEBUG_PRINT3 (" %d (to 0x%lx):\n", mcnt, (long) (p + mcnt)); | 5789 DEBUG_MATCH_PRINT3 (" %d (to 0x%lx):\n", mcnt, (long) (p + mcnt)); |
5744 | 5790 |
5745 PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | 5791 PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); |
5746 break; | 5792 break; |
5747 | 5793 |
5748 | 5794 |
5758 Repeats start with an on_failure_jump that points past both | 5804 Repeats start with an on_failure_jump that points past both |
5759 the repetition text and either the following jump or | 5805 the repetition text and either the following jump or |
5760 pop_failure_jump back to this on_failure_jump. */ | 5806 pop_failure_jump back to this on_failure_jump. */ |
5761 case on_failure_jump: | 5807 case on_failure_jump: |
5762 on_failure: | 5808 on_failure: |
5763 DEBUG_PRINT1 ("EXECUTING on_failure_jump"); | 5809 DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); |
5764 | 5810 |
5765 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5811 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5766 DEBUG_PRINT3 (" %d (to 0x%lx)", mcnt, (long) (p + mcnt)); | 5812 DEBUG_MATCH_PRINT3 (" %d (to 0x%lx)", mcnt, (long) (p + mcnt)); |
5767 | 5813 |
5768 /* If this on_failure_jump comes right before a group (i.e., | 5814 /* If this on_failure_jump comes right before a group (i.e., |
5769 the original * applied to a group), save the information | 5815 the original * applied to a group), save the information |
5770 for that group and all inner ones, so that if we fail back | 5816 for that group and all inner ones, so that if we fail back |
5771 to this point, the group's information will be correct. | 5817 to this point, the group's information will be correct. |
5792 highest_active_reg = *(p1 + 1) + *(p1 + 2); | 5838 highest_active_reg = *(p1 + 1) + *(p1 + 2); |
5793 if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | 5839 if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) |
5794 lowest_active_reg = *(p1 + 1); | 5840 lowest_active_reg = *(p1 + 1); |
5795 } | 5841 } |
5796 | 5842 |
5797 DEBUG_PRINT1 (":\n"); | 5843 DEBUG_MATCH_PRINT1 (":\n"); |
5798 PUSH_FAILURE_POINT (p + mcnt, d, -2); | 5844 PUSH_FAILURE_POINT (p + mcnt, d, -2); |
5799 break; | 5845 break; |
5800 | 5846 |
5801 | 5847 |
5802 /* A smart repeat ends with `maybe_pop_jump'. | 5848 /* A smart repeat ends with `maybe_pop_jump'. |
5803 We change it to either `pop_failure_jump' or `jump'. */ | 5849 We change it to either `pop_failure_jump' or `jump'. */ |
5804 case maybe_pop_jump: | 5850 case maybe_pop_jump: |
5805 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 5851 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
5806 DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | 5852 DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); |
5807 { | 5853 { |
5808 REGISTER unsigned char *p2 = p; | 5854 REGISTER unsigned char *p2 = p; |
5809 | 5855 |
5810 /* Compare the beginning of the repeat with what in the | 5856 /* Compare the beginning of the repeat with what in the |
5811 pattern follows its end. If we can establish that there | 5857 pattern follows its end. If we can establish that there |
5847 { | 5893 { |
5848 /* Consider what happens when matching ":\(.*\)" | 5894 /* Consider what happens when matching ":\(.*\)" |
5849 against ":/". I don't really understand this code | 5895 against ":/". I don't really understand this code |
5850 yet. */ | 5896 yet. */ |
5851 p[-3] = (unsigned char) pop_failure_jump; | 5897 p[-3] = (unsigned char) pop_failure_jump; |
5852 DEBUG_PRINT1 | 5898 DEBUG_MATCH_PRINT1 |
5853 (" End of pattern: change to `pop_failure_jump'.\n"); | 5899 (" End of pattern: change to `pop_failure_jump'.\n"); |
5854 } | 5900 } |
5855 | 5901 |
5856 else if ((re_opcode_t) *p2 == exactn | 5902 else if ((re_opcode_t) *p2 == exactn |
5857 || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | 5903 || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) |
5860 = *p2 == (unsigned char) endline ? '\n' : p2[2]; | 5906 = *p2 == (unsigned char) endline ? '\n' : p2[2]; |
5861 | 5907 |
5862 if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | 5908 if ((re_opcode_t) p1[3] == exactn && p1[5] != c) |
5863 { | 5909 { |
5864 p[-3] = (unsigned char) pop_failure_jump; | 5910 p[-3] = (unsigned char) pop_failure_jump; |
5865 DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", | 5911 DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", |
5866 c, p1[5]); | 5912 c, p1[5]); |
5867 } | 5913 } |
5868 | 5914 |
5869 else if ((re_opcode_t) p1[3] == charset | 5915 else if ((re_opcode_t) p1[3] == charset |
5870 || (re_opcode_t) p1[3] == charset_not) | 5916 || (re_opcode_t) p1[3] == charset_not) |
5878 /* `not_p' is equal to 1 if c would match, which means | 5924 /* `not_p' is equal to 1 if c would match, which means |
5879 that we can't change to pop_failure_jump. */ | 5925 that we can't change to pop_failure_jump. */ |
5880 if (!not_p) | 5926 if (!not_p) |
5881 { | 5927 { |
5882 p[-3] = (unsigned char) pop_failure_jump; | 5928 p[-3] = (unsigned char) pop_failure_jump; |
5883 DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); | 5929 DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); |
5884 } | 5930 } |
5885 } | 5931 } |
5886 } | 5932 } |
5887 else if ((re_opcode_t) *p2 == charset) | 5933 else if ((re_opcode_t) *p2 == charset) |
5888 { | 5934 { |
5895 && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | 5941 && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] |
5896 && (p2[2 + p1[5] / BYTEWIDTH] | 5942 && (p2[2 + p1[5] / BYTEWIDTH] |
5897 & (1 << (p1[5] % BYTEWIDTH))))) | 5943 & (1 << (p1[5] % BYTEWIDTH))))) |
5898 { | 5944 { |
5899 p[-3] = (unsigned char) pop_failure_jump; | 5945 p[-3] = (unsigned char) pop_failure_jump; |
5900 DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", | 5946 DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", |
5901 c, p1[5]); | 5947 c, p1[5]); |
5902 } | 5948 } |
5903 | 5949 |
5904 else if ((re_opcode_t) p1[3] == charset_not) | 5950 else if ((re_opcode_t) p1[3] == charset_not) |
5905 { | 5951 { |
5913 break; | 5959 break; |
5914 | 5960 |
5915 if (idx == p2[1]) | 5961 if (idx == p2[1]) |
5916 { | 5962 { |
5917 p[-3] = (unsigned char) pop_failure_jump; | 5963 p[-3] = (unsigned char) pop_failure_jump; |
5918 DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); | 5964 DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); |
5919 } | 5965 } |
5920 } | 5966 } |
5921 else if ((re_opcode_t) p1[3] == charset) | 5967 else if ((re_opcode_t) p1[3] == charset) |
5922 { | 5968 { |
5923 int idx; | 5969 int idx; |
5930 break; | 5976 break; |
5931 | 5977 |
5932 if (idx == p2[1] || idx == p1[4]) | 5978 if (idx == p2[1] || idx == p1[4]) |
5933 { | 5979 { |
5934 p[-3] = (unsigned char) pop_failure_jump; | 5980 p[-3] = (unsigned char) pop_failure_jump; |
5935 DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); | 5981 DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); |
5936 } | 5982 } |
5937 } | 5983 } |
5938 } | 5984 } |
5939 } | 5985 } |
5940 p -= 2; /* Point at relative address again. */ | 5986 p -= 2; /* Point at relative address again. */ |
5941 if ((re_opcode_t) p[-1] != pop_failure_jump) | 5987 if ((re_opcode_t) p[-1] != pop_failure_jump) |
5942 { | 5988 { |
5943 p[-1] = (unsigned char) jump; | 5989 p[-1] = (unsigned char) jump; |
5944 DEBUG_PRINT1 (" Match => jump.\n"); | 5990 DEBUG_MATCH_PRINT1 (" Match => jump.\n"); |
5945 goto unconditional_jump; | 5991 goto unconditional_jump; |
5946 } | 5992 } |
5947 /* Note fall through. */ | 5993 /* Note fall through. */ |
5948 | 5994 |
5949 | 5995 |
5962 `pop_failure_point'. */ | 6008 `pop_failure_point'. */ |
5963 int dummy_low_reg, dummy_high_reg; | 6009 int dummy_low_reg, dummy_high_reg; |
5964 unsigned char *pdummy; | 6010 unsigned char *pdummy; |
5965 re_char *sdummy = NULL; | 6011 re_char *sdummy = NULL; |
5966 | 6012 |
5967 DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); | 6013 DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); |
5968 POP_FAILURE_POINT (sdummy, pdummy, | 6014 POP_FAILURE_POINT (sdummy, pdummy, |
5969 dummy_low_reg, dummy_high_reg, | 6015 dummy_low_reg, dummy_high_reg, |
5970 reg_dummy, reg_dummy, reg_info_dummy); | 6016 reg_dummy, reg_dummy, reg_info_dummy); |
5971 } | 6017 } |
5972 /* Note fall through. */ | 6018 /* Note fall through. */ |
5974 | 6020 |
5975 /* Unconditionally jump (without popping any failure points). */ | 6021 /* Unconditionally jump (without popping any failure points). */ |
5976 case jump: | 6022 case jump: |
5977 unconditional_jump: | 6023 unconditional_jump: |
5978 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | 6024 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ |
5979 DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); | 6025 DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); |
5980 p += mcnt; /* Do the jump. */ | 6026 p += mcnt; /* Do the jump. */ |
5981 DEBUG_PRINT2 ("(to 0x%lx).\n", (long) p); | 6027 DEBUG_MATCH_PRINT2 ("(to 0x%lx).\n", (long) p); |
5982 break; | 6028 break; |
5983 | 6029 |
5984 | 6030 |
5985 /* We need this opcode so we can detect where alternatives end | 6031 /* We need this opcode so we can detect where alternatives end |
5986 in `group_match_null_string_p' et al. */ | 6032 in `group_match_null_string_p' et al. */ |
5987 case jump_past_alt: | 6033 case jump_past_alt: |
5988 DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); | 6034 DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); |
5989 goto unconditional_jump; | 6035 goto unconditional_jump; |
5990 | 6036 |
5991 | 6037 |
5992 /* Normally, the on_failure_jump pushes a failure point, which | 6038 /* Normally, the on_failure_jump pushes a failure point, which |
5993 then gets popped at pop_failure_jump. We will end up at | 6039 then gets popped at pop_failure_jump. We will end up at |
5994 pop_failure_jump, also, and with a pattern of, say, `a+', we | 6040 pop_failure_jump, also, and with a pattern of, say, `a+', we |
5995 are skipping over the on_failure_jump, so we have to push | 6041 are skipping over the on_failure_jump, so we have to push |
5996 something meaningless for pop_failure_jump to pop. */ | 6042 something meaningless for pop_failure_jump to pop. */ |
5997 case dummy_failure_jump: | 6043 case dummy_failure_jump: |
5998 DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | 6044 DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); |
5999 /* It doesn't matter what we push for the string here. What | 6045 /* It doesn't matter what we push for the string here. What |
6000 the code at `fail' tests is the value for the pattern. */ | 6046 the code at `fail' tests is the value for the pattern. */ |
6001 PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | 6047 PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); |
6002 goto unconditional_jump; | 6048 goto unconditional_jump; |
6003 | 6049 |
6006 point in case we are followed by a `pop_failure_jump', because | 6052 point in case we are followed by a `pop_failure_jump', because |
6007 we don't want the failure point for the alternative to be | 6053 we don't want the failure point for the alternative to be |
6008 popped. For example, matching `(a|ab)*' against `aab' | 6054 popped. For example, matching `(a|ab)*' against `aab' |
6009 requires that we match the `ab' alternative. */ | 6055 requires that we match the `ab' alternative. */ |
6010 case push_dummy_failure: | 6056 case push_dummy_failure: |
6011 DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); | 6057 DEBUG_MATCH_PRINT1 ("EXECUTING push_dummy_failure.\n"); |
6012 /* See comments just above at `dummy_failure_jump' about the | 6058 /* See comments just above at `dummy_failure_jump' about the |
6013 two zeroes. */ | 6059 two zeroes. */ |
6014 PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | 6060 PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); |
6015 break; | 6061 break; |
6016 | 6062 |
6017 /* Have to succeed matching what follows at least n times. | 6063 /* Have to succeed matching what follows at least n times. |
6018 After that, handle like `on_failure_jump'. */ | 6064 After that, handle like `on_failure_jump'. */ |
6019 case succeed_n: | 6065 case succeed_n: |
6020 EXTRACT_NUMBER (mcnt, p + 2); | 6066 EXTRACT_NUMBER (mcnt, p + 2); |
6021 DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); | 6067 DEBUG_MATCH_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); |
6022 | 6068 |
6023 assert (mcnt >= 0); | 6069 assert (mcnt >= 0); |
6024 /* Originally, this is how many times we HAVE to succeed. */ | 6070 /* Originally, this is how many times we HAVE to succeed. */ |
6025 if (mcnt > 0) | 6071 if (mcnt > 0) |
6026 { | 6072 { |
6027 mcnt--; | 6073 mcnt--; |
6028 p += 2; | 6074 p += 2; |
6029 STORE_NUMBER_AND_INCR (p, mcnt); | 6075 STORE_NUMBER_AND_INCR (p, mcnt); |
6030 DEBUG_PRINT3 (" Setting 0x%lx to %d.\n", (long) p, mcnt); | 6076 DEBUG_MATCH_PRINT3 (" Setting 0x%lx to %d.\n", (long) p, mcnt); |
6031 } | 6077 } |
6032 else if (mcnt == 0) | 6078 else if (mcnt == 0) |
6033 { | 6079 { |
6034 DEBUG_PRINT2 (" Setting two bytes from 0x%lx to no_op.\n", | 6080 DEBUG_MATCH_PRINT2 (" Setting two bytes from 0x%lx to no_op.\n", |
6035 (long) (p+2)); | 6081 (long) (p+2)); |
6036 p[2] = (unsigned char) no_op; | 6082 p[2] = (unsigned char) no_op; |
6037 p[3] = (unsigned char) no_op; | 6083 p[3] = (unsigned char) no_op; |
6038 goto on_failure; | 6084 goto on_failure; |
6039 } | 6085 } |
6040 break; | 6086 break; |
6041 | 6087 |
6042 case jump_n: | 6088 case jump_n: |
6043 EXTRACT_NUMBER (mcnt, p + 2); | 6089 EXTRACT_NUMBER (mcnt, p + 2); |
6044 DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); | 6090 DEBUG_MATCH_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); |
6045 | 6091 |
6046 /* Originally, this is how many times we CAN jump. */ | 6092 /* Originally, this is how many times we CAN jump. */ |
6047 if (mcnt) | 6093 if (mcnt) |
6048 { | 6094 { |
6049 mcnt--; | 6095 mcnt--; |
6055 p += 4; | 6101 p += 4; |
6056 break; | 6102 break; |
6057 | 6103 |
6058 case set_number_at: | 6104 case set_number_at: |
6059 { | 6105 { |
6060 DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); | 6106 DEBUG_MATCH_PRINT1 ("EXECUTING set_number_at.\n"); |
6061 | 6107 |
6062 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 6108 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
6063 p1 = p + mcnt; | 6109 p1 = p + mcnt; |
6064 EXTRACT_NUMBER_AND_INCR (mcnt, p); | 6110 EXTRACT_NUMBER_AND_INCR (mcnt, p); |
6065 DEBUG_PRINT3 (" Setting 0x%lx to %d.\n", (long) p1, mcnt); | 6111 DEBUG_MATCH_PRINT3 (" Setting 0x%lx to %d.\n", (long) p1, mcnt); |
6066 STORE_NUMBER (p1, mcnt); | 6112 STORE_NUMBER (p1, mcnt); |
6067 break; | 6113 break; |
6068 } | 6114 } |
6069 | 6115 |
6070 case wordbound: | 6116 case wordbound: |
6071 DEBUG_PRINT1 ("EXECUTING wordbound.\n"); | 6117 DEBUG_MATCH_PRINT1 ("EXECUTING wordbound.\n"); |
6072 should_succeed = 1; | 6118 should_succeed = 1; |
6073 matchwordbound: | 6119 matchwordbound: |
6074 { | 6120 { |
6075 /* XEmacs change */ | 6121 /* XEmacs change */ |
6076 /* Straightforward and (I hope) correct implementation. | 6122 /* Straightforward and (I hope) correct implementation. |
6136 break; | 6182 break; |
6137 goto fail; | 6183 goto fail; |
6138 } | 6184 } |
6139 | 6185 |
6140 case notwordbound: | 6186 case notwordbound: |
6141 DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); | 6187 DEBUG_MATCH_PRINT1 ("EXECUTING notwordbound.\n"); |
6142 should_succeed = 0; | 6188 should_succeed = 0; |
6143 goto matchwordbound; | 6189 goto matchwordbound; |
6144 | 6190 |
6145 case wordbeg: | 6191 case wordbeg: |
6146 DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); | 6192 DEBUG_MATCH_PRINT1 ("EXECUTING wordbeg.\n"); |
6147 if (AT_STRINGS_END (d)) | 6193 if (AT_STRINGS_END (d)) |
6148 goto fail; | 6194 goto fail; |
6149 { | 6195 { |
6150 /* XEmacs: this originally read: | 6196 /* XEmacs: this originally read: |
6151 | 6197 |
6184 break; | 6230 break; |
6185 goto fail; | 6231 goto fail; |
6186 } | 6232 } |
6187 | 6233 |
6188 case wordend: | 6234 case wordend: |
6189 DEBUG_PRINT1 ("EXECUTING wordend.\n"); | 6235 DEBUG_MATCH_PRINT1 ("EXECUTING wordend.\n"); |
6190 if (AT_STRINGS_BEG (d)) | 6236 if (AT_STRINGS_BEG (d)) |
6191 goto fail; | 6237 goto fail; |
6192 { | 6238 { |
6193 /* XEmacs: this originally read: | 6239 /* XEmacs: this originally read: |
6194 | 6240 |
6233 goto fail; | 6279 goto fail; |
6234 } | 6280 } |
6235 | 6281 |
6236 #ifdef emacs | 6282 #ifdef emacs |
6237 case before_dot: | 6283 case before_dot: |
6238 DEBUG_PRINT1 ("EXECUTING before_dot.\n"); | 6284 DEBUG_MATCH_PRINT1 ("EXECUTING before_dot.\n"); |
6239 if (!BUFFERP (lispobj) | 6285 if (!BUFFERP (lispobj) |
6240 || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | 6286 || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) |
6241 >= BUF_PT (XBUFFER (lispobj)))) | 6287 >= BUF_PT (XBUFFER (lispobj)))) |
6242 goto fail; | 6288 goto fail; |
6243 break; | 6289 break; |
6244 | 6290 |
6245 case at_dot: | 6291 case at_dot: |
6246 DEBUG_PRINT1 ("EXECUTING at_dot.\n"); | 6292 DEBUG_MATCH_PRINT1 ("EXECUTING at_dot.\n"); |
6247 if (!BUFFERP (lispobj) | 6293 if (!BUFFERP (lispobj) |
6248 || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | 6294 || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) |
6249 != BUF_PT (XBUFFER (lispobj)))) | 6295 != BUF_PT (XBUFFER (lispobj)))) |
6250 goto fail; | 6296 goto fail; |
6251 break; | 6297 break; |
6252 | 6298 |
6253 case after_dot: | 6299 case after_dot: |
6254 DEBUG_PRINT1 ("EXECUTING after_dot.\n"); | 6300 DEBUG_MATCH_PRINT1 ("EXECUTING after_dot.\n"); |
6255 if (!BUFFERP (lispobj) | 6301 if (!BUFFERP (lispobj) |
6256 || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | 6302 || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) |
6257 <= BUF_PT (XBUFFER (lispobj)))) | 6303 <= BUF_PT (XBUFFER (lispobj)))) |
6258 goto fail; | 6304 goto fail; |
6259 break; | 6305 break; |
6260 | 6306 |
6261 case syntaxspec: | 6307 case syntaxspec: |
6262 DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); | 6308 DEBUG_MATCH_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); |
6263 mcnt = *p++; | 6309 mcnt = *p++; |
6264 goto matchsyntax; | 6310 goto matchsyntax; |
6265 | 6311 |
6266 case wordchar: | 6312 case wordchar: |
6267 DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); | 6313 DEBUG_MATCH_PRINT1 ("EXECUTING Emacs wordchar.\n"); |
6268 mcnt = (int) Sword; | 6314 mcnt = (int) Sword; |
6269 matchsyntax: | 6315 matchsyntax: |
6270 should_succeed = 1; | 6316 should_succeed = 1; |
6271 matchornotsyntax: | 6317 matchornotsyntax: |
6272 { | 6318 { |
6292 SET_REGS_MATCHED (); | 6338 SET_REGS_MATCHED (); |
6293 } | 6339 } |
6294 break; | 6340 break; |
6295 | 6341 |
6296 case notsyntaxspec: | 6342 case notsyntaxspec: |
6297 DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); | 6343 DEBUG_MATCH_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); |
6298 mcnt = *p++; | 6344 mcnt = *p++; |
6299 goto matchnotsyntax; | 6345 goto matchnotsyntax; |
6300 | 6346 |
6301 case notwordchar: | 6347 case notwordchar: |
6302 DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); | 6348 DEBUG_MATCH_PRINT1 ("EXECUTING Emacs notwordchar.\n"); |
6303 mcnt = (int) Sword; | 6349 mcnt = (int) Sword; |
6304 matchnotsyntax: | 6350 matchnotsyntax: |
6305 should_succeed = 0; | 6351 should_succeed = 0; |
6306 goto matchornotsyntax; | 6352 goto matchornotsyntax; |
6307 | 6353 |
6329 goto matchornotcategory; | 6375 goto matchornotcategory; |
6330 /* end of category patch */ | 6376 /* end of category patch */ |
6331 #endif /* MULE */ | 6377 #endif /* MULE */ |
6332 #else /* not emacs */ | 6378 #else /* not emacs */ |
6333 case wordchar: | 6379 case wordchar: |
6334 DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); | 6380 DEBUG_MATCH_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); |
6335 REGEX_PREFETCH (); | 6381 REGEX_PREFETCH (); |
6336 if (!WORDCHAR_P ((int) (*d))) | 6382 if (!WORDCHAR_P ((int) (*d))) |
6337 goto fail; | 6383 goto fail; |
6338 SET_REGS_MATCHED (); | 6384 SET_REGS_MATCHED (); |
6339 d++; | 6385 d++; |
6340 break; | 6386 break; |
6341 | 6387 |
6342 case notwordchar: | 6388 case notwordchar: |
6343 DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); | 6389 DEBUG_MATCH_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); |
6344 REGEX_PREFETCH (); | 6390 REGEX_PREFETCH (); |
6345 if (!WORDCHAR_P ((int) (*d))) | 6391 if (!WORDCHAR_P ((int) (*d))) |
6346 goto fail; | 6392 goto fail; |
6347 SET_REGS_MATCHED (); | 6393 SET_REGS_MATCHED (); |
6348 d++; | 6394 d++; |
6357 | 6403 |
6358 /* We goto here if a matching operation fails. */ | 6404 /* We goto here if a matching operation fails. */ |
6359 fail: | 6405 fail: |
6360 if (!FAIL_STACK_EMPTY ()) | 6406 if (!FAIL_STACK_EMPTY ()) |
6361 { /* A restart point is known. Restore to that state. */ | 6407 { /* A restart point is known. Restore to that state. */ |
6362 DEBUG_PRINT1 ("\nFAIL:\n"); | 6408 DEBUG_MATCH_PRINT1 ("\nFAIL:\n"); |
6363 POP_FAILURE_POINT (d, p, | 6409 POP_FAILURE_POINT (d, p, |
6364 lowest_active_reg, highest_active_reg, | 6410 lowest_active_reg, highest_active_reg, |
6365 regstart, regend, reg_info); | 6411 regstart, regend, reg_info); |
6366 | 6412 |
6367 /* If this failure point is a dummy, try the next one. */ | 6413 /* If this failure point is a dummy, try the next one. */ |