diff options
| author | Paul Eggert | 2018-08-05 18:41:21 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-05 19:36:10 -0700 |
| commit | e097826f8972c78577d1d5a14389ec8e888be1b7 (patch) | |
| tree | 61ddf66159991825518d1af5d5ed33a50256008b /src | |
| parent | 03dfb6061bfd78d74564d678213ef95728a5f9eb (diff) | |
| download | emacs-e097826f8972c78577d1d5a14389ec8e888be1b7.tar.gz emacs-e097826f8972c78577d1d5a14389ec8e888be1b7.zip | |
Remove always-0 struct re_pattern_buffer members
* src/regex-emacs.h (struct re_pattern_buffer):
Remove no_sub, not_bol, not_eol. They are always zero.
All uses removed, and code simplified.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex-emacs.c | 42 | ||||
| -rw-r--r-- | src/regex-emacs.h | 15 |
2 files changed, 13 insertions, 44 deletions
diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 1ceb67ad297..b944fe0c5a7 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c | |||
| @@ -762,9 +762,6 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) | |||
| 762 | printf ("re_nsub: %zu\t", bufp->re_nsub); | 762 | printf ("re_nsub: %zu\t", bufp->re_nsub); |
| 763 | printf ("regs_alloc: %d\t", bufp->regs_allocated); | 763 | printf ("regs_alloc: %d\t", bufp->regs_allocated); |
| 764 | printf ("can_be_null: %d\t", bufp->can_be_null); | 764 | printf ("can_be_null: %d\t", bufp->can_be_null); |
| 765 | printf ("no_sub: %d\t", bufp->no_sub); | ||
| 766 | printf ("not_bol: %d\t", bufp->not_bol); | ||
| 767 | printf ("not_eol: %d\t", bufp->not_eol); | ||
| 768 | #ifndef emacs | 765 | #ifndef emacs |
| 769 | printf ("syntax: %lx\n", bufp->syntax); | 766 | printf ("syntax: %lx\n", bufp->syntax); |
| 770 | #endif | 767 | #endif |
| @@ -1683,7 +1680,6 @@ static bool group_in_compile_stack (compile_stack_type, regnum_t); | |||
| 1683 | `used' is set to the length of the compiled pattern; | 1680 | `used' is set to the length of the compiled pattern; |
| 1684 | `fastmap_accurate' is zero; | 1681 | `fastmap_accurate' is zero; |
| 1685 | `re_nsub' is the number of subexpressions in PATTERN; | 1682 | `re_nsub' is the number of subexpressions in PATTERN; |
| 1686 | `not_bol' and `not_eol' are zero; | ||
| 1687 | 1683 | ||
| 1688 | The `fastmap' field is neither examined nor set. */ | 1684 | The `fastmap' field is neither examined nor set. */ |
| 1689 | 1685 | ||
| @@ -1787,7 +1783,6 @@ regex_compile (re_char *pattern, size_t size, | |||
| 1787 | 1783 | ||
| 1788 | /* Initialize the pattern buffer. */ | 1784 | /* Initialize the pattern buffer. */ |
| 1789 | bufp->fastmap_accurate = 0; | 1785 | bufp->fastmap_accurate = 0; |
| 1790 | bufp->not_bol = bufp->not_eol = 0; | ||
| 1791 | bufp->used_syntax = 0; | 1786 | bufp->used_syntax = 0; |
| 1792 | 1787 | ||
| 1793 | /* Set `used' to zero, so that if we return an error, the pattern | 1788 | /* Set `used' to zero, so that if we return an error, the pattern |
| @@ -1795,7 +1790,6 @@ regex_compile (re_char *pattern, size_t size, | |||
| 1795 | at the end. */ | 1790 | at the end. */ |
| 1796 | bufp->used = 0; | 1791 | bufp->used = 0; |
| 1797 | 1792 | ||
| 1798 | /* Always count groups, whether or not bufp->no_sub is set. */ | ||
| 1799 | bufp->re_nsub = 0; | 1793 | bufp->re_nsub = 0; |
| 1800 | 1794 | ||
| 1801 | if (bufp->allocated == 0) | 1795 | if (bufp->allocated == 0) |
| @@ -3841,9 +3835,8 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, | |||
| 3841 | and SIZE2, respectively). We start matching at POS, and stop | 3835 | and SIZE2, respectively). We start matching at POS, and stop |
| 3842 | matching at STOP. | 3836 | matching at STOP. |
| 3843 | 3837 | ||
| 3844 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | 3838 | If REGS is non-null, store offsets for the substring each group |
| 3845 | store offsets for the substring each group matched in REGS. See the | 3839 | matched in REGS. |
| 3846 | documentation for exactly how many groups we fill. | ||
| 3847 | 3840 | ||
| 3848 | We return -1 if no match, -2 if an internal error (such as the | 3841 | We return -1 if no match, -2 if an internal error (such as the |
| 3849 | failure stack overflowing). Otherwise, we return the length of the | 3842 | failure stack overflowing). Otherwise, we return the length of the |
| @@ -4130,7 +4123,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | |||
| 4130 | DEBUG_PRINT ("Accepting match.\n"); | 4123 | DEBUG_PRINT ("Accepting match.\n"); |
| 4131 | 4124 | ||
| 4132 | /* If caller wants register contents data back, do it. */ | 4125 | /* If caller wants register contents data back, do it. */ |
| 4133 | if (regs && !bufp->no_sub) | 4126 | if (regs) |
| 4134 | { | 4127 | { |
| 4135 | /* Have the register data arrays been allocated? */ | 4128 | /* Have the register data arrays been allocated? */ |
| 4136 | if (bufp->regs_allocated == REGS_UNALLOCATED) | 4129 | if (bufp->regs_allocated == REGS_UNALLOCATED) |
| @@ -4185,7 +4178,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | |||
| 4185 | -1 at the end. */ | 4178 | -1 at the end. */ |
| 4186 | for (reg = num_regs; reg < regs->num_regs; reg++) | 4179 | for (reg = num_regs; reg < regs->num_regs; reg++) |
| 4187 | regs->start[reg] = regs->end[reg] = -1; | 4180 | regs->start[reg] = regs->end[reg] = -1; |
| 4188 | } /* regs && !bufp->no_sub */ | 4181 | } |
| 4189 | 4182 | ||
| 4190 | DEBUG_PRINT ("%u failure points pushed, %u popped (%u remain).\n", | 4183 | DEBUG_PRINT ("%u failure points pushed, %u popped (%u remain).\n", |
| 4191 | nfailure_points_pushed, nfailure_points_popped, | 4184 | nfailure_points_pushed, nfailure_points_popped, |
| @@ -4482,15 +4475,13 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | |||
| 4482 | break; | 4475 | break; |
| 4483 | 4476 | ||
| 4484 | 4477 | ||
| 4485 | /* begline matches the empty string at the beginning of the string | 4478 | /* begline matches the empty string at the beginning of the string, |
| 4486 | (unless `not_bol' is set in `bufp'), and after newlines. */ | 4479 | and after newlines. */ |
| 4487 | case begline: | 4480 | case begline: |
| 4488 | DEBUG_PRINT ("EXECUTING begline.\n"); | 4481 | DEBUG_PRINT ("EXECUTING begline.\n"); |
| 4489 | 4482 | ||
| 4490 | if (AT_STRINGS_BEG (d)) | 4483 | if (AT_STRINGS_BEG (d)) |
| 4491 | { | 4484 | break; |
| 4492 | if (!bufp->not_bol) break; | ||
| 4493 | } | ||
| 4494 | else | 4485 | else |
| 4495 | { | 4486 | { |
| 4496 | unsigned c; | 4487 | unsigned c; |
| @@ -4498,7 +4489,6 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | |||
| 4498 | if (c == '\n') | 4489 | if (c == '\n') |
| 4499 | break; | 4490 | break; |
| 4500 | } | 4491 | } |
| 4501 | /* In all other cases, we fail. */ | ||
| 4502 | goto fail; | 4492 | goto fail; |
| 4503 | 4493 | ||
| 4504 | 4494 | ||
| @@ -4507,15 +4497,10 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | |||
| 4507 | DEBUG_PRINT ("EXECUTING endline.\n"); | 4497 | DEBUG_PRINT ("EXECUTING endline.\n"); |
| 4508 | 4498 | ||
| 4509 | if (AT_STRINGS_END (d)) | 4499 | if (AT_STRINGS_END (d)) |
| 4510 | { | 4500 | break; |
| 4511 | if (!bufp->not_eol) break; | 4501 | PREFETCH_NOLIMIT (); |
| 4512 | } | 4502 | if (*d == '\n') |
| 4513 | else | 4503 | break; |
| 4514 | { | ||
| 4515 | PREFETCH_NOLIMIT (); | ||
| 4516 | if (*d == '\n') | ||
| 4517 | break; | ||
| 4518 | } | ||
| 4519 | goto fail; | 4504 | goto fail; |
| 4520 | 4505 | ||
| 4521 | 4506 | ||
| @@ -5113,11 +5098,6 @@ re_compile_pattern (const char *pattern, size_t length, | |||
| 5113 | (and at least one extra will be -1). */ | 5098 | (and at least one extra will be -1). */ |
| 5114 | bufp->regs_allocated = REGS_UNALLOCATED; | 5099 | bufp->regs_allocated = REGS_UNALLOCATED; |
| 5115 | 5100 | ||
| 5116 | /* And GNU code determines whether or not to get register information | ||
| 5117 | by passing null for the REGS argument to re_search, etc., not by | ||
| 5118 | setting no_sub. */ | ||
| 5119 | bufp->no_sub = 0; | ||
| 5120 | |||
| 5121 | ret = regex_compile ((re_char *) pattern, length, | 5101 | ret = regex_compile ((re_char *) pattern, length, |
| 5122 | posix_backtracking, | 5102 | posix_backtracking, |
| 5123 | whitespace_regexp, | 5103 | whitespace_regexp, |
diff --git a/src/regex-emacs.h b/src/regex-emacs.h index 159c7dcb9b8..b6dd26b2f4d 100644 --- a/src/regex-emacs.h +++ b/src/regex-emacs.h | |||
| @@ -59,7 +59,7 @@ extern ptrdiff_t emacs_re_safe_alloca; | |||
| 59 | 59 | ||
| 60 | /* This data structure represents a compiled pattern. Before calling | 60 | /* This data structure represents a compiled pattern. Before calling |
| 61 | the pattern compiler, the fields `buffer', `allocated', `fastmap', | 61 | the pattern compiler, the fields `buffer', `allocated', `fastmap', |
| 62 | `translate', and `no_sub' can be set. After the pattern has been | 62 | and `translate' can be set. After the pattern has been |
| 63 | compiled, the `re_nsub' field is available. All other fields are | 63 | compiled, the `re_nsub' field is available. All other fields are |
| 64 | private to the regex routines. */ | 64 | private to the regex routines. */ |
| 65 | 65 | ||
| @@ -109,17 +109,6 @@ struct re_pattern_buffer | |||
| 109 | by `re_compile_fastmap' if it updates the fastmap. */ | 109 | by `re_compile_fastmap' if it updates the fastmap. */ |
| 110 | unsigned fastmap_accurate : 1; | 110 | unsigned fastmap_accurate : 1; |
| 111 | 111 | ||
| 112 | /* If set, `re_match_2' does not return information about | ||
| 113 | subexpressions. */ | ||
| 114 | unsigned no_sub : 1; | ||
| 115 | |||
| 116 | /* If set, a beginning-of-line anchor doesn't match at the | ||
| 117 | beginning of the string. */ | ||
| 118 | unsigned not_bol : 1; | ||
| 119 | |||
| 120 | /* Similarly for an end-of-line anchor. */ | ||
| 121 | unsigned not_eol : 1; | ||
| 122 | |||
| 123 | /* If true, the compilation of the pattern had to look up the syntax table, | 112 | /* If true, the compilation of the pattern had to look up the syntax table, |
| 124 | so the compiled pattern is only valid for the current syntax table. */ | 113 | so the compiled pattern is only valid for the current syntax table. */ |
| 125 | unsigned used_syntax : 1; | 114 | unsigned used_syntax : 1; |
| @@ -148,7 +137,7 @@ extern const char *re_compile_pattern (const char *pattern, size_t length, | |||
| 148 | compiled into BUFFER. Start searching at position START, for RANGE | 137 | compiled into BUFFER. Start searching at position START, for RANGE |
| 149 | characters. Return the starting position of the match, -1 for no | 138 | characters. Return the starting position of the match, -1 for no |
| 150 | match, or -2 for an internal error. Also return register | 139 | match, or -2 for an internal error. Also return register |
| 151 | information in REGS (if REGS and BUFFER->no_sub are nonzero). */ | 140 | information in REGS (if REGS is nonzero). */ |
| 152 | extern ptrdiff_t re_search (struct re_pattern_buffer *buffer, | 141 | extern ptrdiff_t re_search (struct re_pattern_buffer *buffer, |
| 153 | const char *string, size_t length, | 142 | const char *string, size_t length, |
| 154 | ptrdiff_t start, ptrdiff_t range, | 143 | ptrdiff_t start, ptrdiff_t range, |