Mercurial > emacs
diff src/regex.c @ 83548:c71725faff1a
Merged from emacs@sv.gnu.org. Last-minute emacsclient rewrites be damned!
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-490
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-491
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-492
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-493
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-494
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-495
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-496
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-497
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-498
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-499
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-500
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-501
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-502
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-503
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-504
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-505
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-506
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-507
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-508
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-509
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-510
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-511
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-512
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-513
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-514
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-515
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-516
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-517
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-518
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-519
Update from CVS: etc/TUTORIAL.cn: Updated.
* emacs@sv.gnu.org/emacs--devo--0--patch-520
Merge from erc--emacs--22
* emacs@sv.gnu.org/emacs--devo--0--patch-521
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-522
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-523
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-524
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-525
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-526
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-527
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-528
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-529
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-530
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-531
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-532
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-533
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-534
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-535
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-161
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-162
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-163
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-164
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-165
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-166
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-167
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-168
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-169
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-170
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-588
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 03 Dec 2006 15:03:30 +0000 |
parents | 2d56e13fd23d ad2b5e25b8f0 |
children | 17e0dd217877 |
line wrap: on
line diff
--- a/src/regex.c Sun Dec 03 12:36:08 2006 +0000 +++ b/src/regex.c Sun Dec 03 15:03:30 2006 +0000 @@ -12,13 +12,13 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ + USA. */ /* TODO: - structure the opcode space into opcode+flag. @@ -139,7 +139,7 @@ # endif # define free xfree -/* Converts the pointer to the char to BEG-based offset from the start. */ +/* Converts the pointer to the char to BEG-based offset from the start. */ # define PTR_TO_OFFSET(d) POS_AS_IN_BUFFER (POINTER_TO_OFFSET (d)) # define POS_AS_IN_BUFFER(p) ((p) + (NILP (re_match_object) || BUFFERP (re_match_object))) @@ -540,7 +540,7 @@ # define REGEX_REALLOCATE_STACK(source, osize, nsize) \ REGEX_REALLOCATE (source, osize, nsize) -/* No need to explicitly free anything. */ +/* No need to explicitly free anything. */ # define REGEX_FREE_STACK(arg) ((void)0) # endif /* not REGEX_MALLOC */ @@ -654,7 +654,7 @@ jump, /* Followed by two-byte relative address of place to resume at - in case of failure. */ + in case of failure. */ on_failure_jump, /* Like on_failure_jump, but pushes a placeholder instead of the @@ -691,7 +691,7 @@ jump_n, /* Set the following two-byte relative address to the - subsequent two-byte number. The address *includes* the two + subsequent two-byte number. The address *includes* the two bytes of number. */ set_number_at, @@ -699,7 +699,7 @@ wordend, /* Succeeds if at word end. */ wordbound, /* Succeeds if at a word boundary. */ - notwordbound, /* Succeeds if not at a word boundary. */ + notwordbound, /* Succeeds if not at a word boundary. */ symbeg, /* Succeeds if at symbol beginning. */ symend, /* Succeeds if at symbol end. */ @@ -717,8 +717,8 @@ after_dot, /* Succeeds if after point. */ /* Matches any character whose category-set contains the specified - category. The operator is followed by a byte which contains a - category code (mnemonic ASCII character). */ + category. The operator is followed by a byte which contains a + category code (mnemonic ASCII character). */ categoryspec, /* Matches any character whose category-set does not contain the @@ -807,7 +807,7 @@ /* Store a multibyte character in three contiguous bytes starting DESTINATION, and increment DESTINATION to the byte after where the - character is stored. Therefore, DESTINATION must be an lvalue. */ + character is stored. Therefore, DESTINATION must be an lvalue. */ #define STORE_CHARACTER_AND_INCR(destination, character) \ do { \ @@ -818,7 +818,7 @@ } while (0) /* Put into DESTINATION a character stored in three contiguous bytes - starting at SOURCE. */ + starting at SOURCE. */ #define EXTRACT_CHARACTER(destination, source) \ do { \ @@ -854,13 +854,13 @@ && (p)[2 + (c) / BYTEWIDTH] & (1 << ((c) % BYTEWIDTH))) /* Return the address of end of RANGE_TABLE. COUNT is number of - ranges (which is a pair of (start, end)) in the RANGE_TABLE. `* 2' - is start of range and end of range. `* 3' is size of each start + ranges (which is a pair of (start, end)) in the RANGE_TABLE. `* 2' + is start of range and end of range. `* 3' is size of each start and end. */ #define CHARSET_RANGE_TABLE_END(range_table, count) \ ((range_table) + (count) * 2 * 3) -/* Test if C is in RANGE_TABLE. A flag NOT is negated if C is in. +/* Test if C is in RANGE_TABLE. A flag NOT is negated if C is in. COUNT is number of ranges in RANGE_TABLE. */ #define CHARSET_LOOKUP_RANGE_TABLE_RAW(not, c, range_table, count) \ do \ @@ -1667,7 +1667,7 @@ REGSTART, REGEND -- arrays of string positions. Also assumes the variables `fail_stack' and (if debugging), `bufp', - `pend', `string1', `size1', `string2', and `size2'. */ + `pend', `string1', `size1', `string2', and `size2'. */ #define POP_FAILURE_POINT(str, pat) \ do { \ @@ -1936,7 +1936,7 @@ { int *table; /* actual work area. */ int allocated; /* allocated size for work area in bytes. */ - int used; /* actually used size in words. */ + int used; /* actually used size in words. */ int bits; /* flag to record character classes */ }; @@ -1978,7 +1978,7 @@ FREE_STACK_RETURN (tem); \ } while (0) -/* Free allocated memory for WORK_AREA. */ +/* Free allocated memory for WORK_AREA. */ #define FREE_RANGE_TABLE_WORK_AREA(work_area) \ do { \ if ((work_area).table) \ @@ -2478,7 +2478,7 @@ re_char *beg_interval; /* Address of the place where a forward jump should go to the end of - the containing expression. Each alternative of an `or' -- except the + the containing expression. Each alternative of an `or' -- except the last -- ends with a forward jump of this sort. */ unsigned char *fixup_alt_jump = 0; @@ -2550,11 +2550,11 @@ if (bufp->buffer) { /* If zero allocated, but buffer is non-null, try to realloc enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. */ + that is the user's responsibility. */ RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); } else - { /* Caller did not allocate a buffer. Do it for them. */ + { /* Caller did not allocate a buffer. Do it for them. */ bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); @@ -2618,15 +2618,15 @@ p = pattern = whitespace_regexp; pend = p + strlen (p); break; - } + } case '^': { - if ( /* If at start of pattern, it's an operator. */ + if ( /* If at start of pattern, it's an operator. */ p == pattern + 1 - /* If context independent, it's an operator. */ + /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's come before. */ + /* Otherwise, depends on what's come before. */ || at_begline_loc_p (pattern, p, syntax)) BUF_PUSH ((syntax & RE_NO_NEWLINE_ANCHOR) ? begbuf : begline); else @@ -2639,7 +2639,7 @@ { if ( /* If at end of pattern, it's an operator. */ p == pend - /* If context independent, it's an operator. */ + /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's next. */ || at_endline_loc_p (p, pend, syntax)) @@ -2667,14 +2667,14 @@ } { - /* 1 means zero (many) matches is allowed. */ + /* 1 means zero (many) matches is allowed. */ boolean zero_times_ok = 0, many_times_ok = 0; boolean greedy = 1; /* If there is a sequence of repetition chars, collapse it down to just one (the right one). We can't combine interval operators with these because of, e.g., `a{2}*', - which should only match an even number of `a's. */ + which should only match an even number of `a's. */ for (;;) { @@ -2714,7 +2714,7 @@ break; /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ + and also whether or not two or more matches is allowed. */ if (greedy) { if (many_times_ok) @@ -2821,7 +2821,7 @@ laststart = b; /* We test `*p == '^' twice, instead of using an if - statement, so we only need one BUF_PUSH. */ + statement, so we only need one BUF_PUSH. */ BUF_PUSH (*p == '^' ? charset_not : charset); if (*p == '^') p++; @@ -2829,7 +2829,7 @@ /* Remember the first position in the bracket expression. */ p1 = p; - /* Push the number of bytes in the bitmap. */ + /* Push the number of bytes in the bitmap. */ BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ @@ -2840,7 +2840,7 @@ && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) SET_LIST_BIT ('\n'); - /* Read in characters and ranges, setting map bits. */ + /* Read in characters and ranges, setting map bits. */ for (;;) { boolean escaped_char = false; @@ -2864,7 +2864,7 @@ } else { - /* Could be the end of the bracket expression. If it's + /* Could be the end of the bracket expression. If it's not (i.e., when the bracket expression is `[]' so far), the ']' character bit gets set way below. */ if (c == ']' && p2 != p1) @@ -2881,7 +2881,7 @@ if (!escaped_char && syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { - /* Leave room for the null. */ + /* Leave room for the null. */ unsigned char str[CHAR_CLASS_MAX_LENGTH + 1]; const unsigned char *class_beg; @@ -2939,7 +2939,8 @@ for (ch = 0; ch < 1 << BYTEWIDTH; ++ch) { int translated = TRANSLATE (ch); - if (re_iswctype (btowc (ch), cc)) + if (translated < (1 << BYTEWIDTH) + && re_iswctype (btowc (ch), cc)) SET_LIST_BIT (translated); } @@ -2962,7 +2963,7 @@ /* Because the `:' may starts the range, we can't simply set bit and repeat the loop. - Instead, just set it to C and handle below. */ + Instead, just set it to C and handle below. */ c = ':'; } } @@ -3020,7 +3021,14 @@ { for (this_char = range_start; this_char <= range_end; this_char++) - SET_LIST_BIT (TRANSLATE (this_char)); + { + int translated = TRANSLATE (this_char); + if (translated < (1 << BYTEWIDTH)) + SET_LIST_BIT (translated); + else + SET_RANGE_TABLE_WORK_AREA + (range_table_work, translated, translated); + } } } else @@ -3029,7 +3037,7 @@ } /* Discard any (non)matching list bytes that are all 0 at the - end of the map. Decrease the map-length byte too. */ + end of the map. Decrease the map-length byte too. */ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) b[-1]--; b += b[-1]; @@ -3148,7 +3156,7 @@ } /* These are the values to restore when we hit end of this - group. They are all relative offsets, so that if the + group. They are all relative offsets, so that if the whole pattern moves because of realloc, they will still be valid. */ COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; @@ -3204,7 +3212,7 @@ { /* We don't just want to restore into `regnum', because later groups should continue to be numbered higher, - as in `(ab)c(de)' -- the second group is #2. */ + as in `(ab)c(de)' -- the second group is #2. */ regnum_t this_group_regnum; compile_stack.avail--; @@ -3221,7 +3229,7 @@ pending_exact = 0; /* We're at the end of the group, so now we know how many - groups were inside this one. */ + groups were inside this one. */ if (this_group_regnum <= MAX_REGNUM && this_group_regnum > 0) BUF_PUSH_2 (stop_memory, this_group_regnum); } @@ -3236,7 +3244,7 @@ goto normal_char; /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ + jumps to this alternative if the former fails. */ GET_BUFFER_SPACE (3); INSERT_JUMP (on_failure_jump, begalt, b + 6); pending_exact = 0; @@ -3373,7 +3381,7 @@ b += 5; /* Code to initialize the lower bound. Insert - before the `succeed_n'. The `5' is the last two + before the `succeed_n'. The `5' is the last two bytes of this `set_number_at', plus 3 bytes of the following `succeed_n'. */ insert_op2 (set_number_at, laststart, 5, lower_bound, b); @@ -3443,7 +3451,7 @@ #ifdef emacs /* There is no way to specify the before_dot and after_dot - operators. rms says this is ok. --karl */ + operators. rms says this is ok. --karl */ case '=': BUF_PUSH (at_dot); break; @@ -3588,7 +3596,7 @@ /* We have only one byte following the exactn for the count. */ || *pending_exact >= (1 << BYTEWIDTH) - MAX_MULTIBYTE_LENGTH - /* If followed by a repetition operator. */ + /* If followed by a repetition operator. */ || (p != pend && (*p == '*' || *p == '^')) || ((syntax & RE_BK_PLUS_QM) ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') @@ -3680,7 +3688,7 @@ /* Subroutines for `regex_compile'. */ -/* Store OP at LOC followed by two-byte integer parameter ARG. */ +/* Store OP at LOC followed by two-byte integer parameter ARG. */ static void store_op1 (op, loc, arg) @@ -3832,7 +3840,7 @@ boolean not; /* If all elements for base leading-codes in fastmap is set, this - flag is set true. */ + flag is set true. */ boolean match_any_multibyte_characters = false; assert (p); @@ -3880,7 +3888,7 @@ /* Following are the cases which match a character. These end - with `break'. */ + with `break'. */ case exactn: if (fastmap) @@ -4102,7 +4110,7 @@ /* Getting here means we have found the possible starting characters for one path of the pattern -- and that the empty - string does not match. We need not follow this path further. */ + string does not match. We need not follow this path further. */ return 0; } /* while p */ @@ -4137,7 +4145,7 @@ assert (fastmap && bufp->buffer); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ + bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ analysis = analyse_first (bufp->buffer, bufp->buffer + bufp->used, @@ -4182,7 +4190,7 @@ } WEAK_ALIAS (__re_set_registers, re_set_registers) -/* Searching routines. */ +/* Searching routines. */ /* Like re_search_2, below, but only one string is specified, and doesn't let you say where to stop matching. */ @@ -4251,7 +4259,7 @@ int endpos = startpos + range; boolean anchored_start; - /* Nonzero if we have to concern multibyte character. */ + /* Nonzero if we have to concern multibyte character. */ const boolean multibyte = RE_MULTIBYTE_P (bufp); /* Check for out-of-range STARTPOS. */ @@ -4321,7 +4329,7 @@ /* If a fastmap is supplied, skip quickly over characters that cannot be the start of a match. If the pattern can match the null string, however, we don't need to skip characters; we want - the first null string. */ + the first null string. */ if (fastmap && startpos < total_size && !bufp->can_be_null) { register re_char *d; @@ -4329,7 +4337,7 @@ d = POS_ADDR_VSTRING (startpos); - if (range > 0) /* Searching forwards. */ + if (range > 0) /* Searching forwards. */ { register int lim = 0; int irange = range; @@ -4403,7 +4411,7 @@ startpos += irange - range; } - else /* Searching backwards. */ + else /* Searching backwards. */ { int room = (startpos >= size1 ? size2 + size1 - startpos @@ -4526,7 +4534,7 @@ } \ /* Test if at very beginning or at very end of the virtual concatenation - of `string1' and `string2'. If only one string, it's `string2'. */ + of `string1' and `string2'. If only one string, it's `string2'. */ #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) #define AT_STRINGS_END(d) ((d) == end2) @@ -4547,7 +4555,7 @@ The DEC Alpha C compiler 3.x generates incorrect code for the test WORDCHAR_P (d - 1) != WORDCHAR_P (d) in the expansion of - AT_WORD_BOUNDARY, so this code is disabled. Expanding the + AT_WORD_BOUNDARY, so this code is disabled. Expanding the macro and introducing temporary variables works around the bug. */ #if 0 @@ -4749,7 +4757,7 @@ { /* Now, we are sure that P2 has no range table. So, for the size of bitmap in P2, `p2[1]' is - enough. But P1 may have range table, so the + enough. But P1 may have range table, so the size of bitmap table of P1 is extracted by using macro `CHARSET_BITMAP_SIZE'. @@ -4780,7 +4788,7 @@ { int idx; /* We win if the charset_not inside the loop lists - every character listed in the charset after. */ + every character listed in the charset after. */ for (idx = 0; idx < (int) p2[1]; idx++) if (! (p2[2 + idx] == 0 || (idx < CHARSET_BITMAP_SIZE (p1) @@ -4874,7 +4882,7 @@ #ifdef emacs /* In Emacs, this is the string or buffer in which we - are matching. It is used for looking up syntax properties. */ + are matching. It is used for looking up syntax properties. */ Lisp_Object re_match_object; #endif @@ -4884,11 +4892,11 @@ matching at STOP. If REGS is non-null and the `no_sub' field of BUFP is nonzero, we - store offsets for the substring each group matched in REGS. See the + store offsets for the substring each group matched in REGS. See the documentation for exactly how many groups we fill. We return -1 if no match, -2 if an internal error (such as the - failure stack overflowing). Otherwise, we return the length of the + failure stack overflowing). Otherwise, we return the length of the matched substring. */ int @@ -4920,7 +4928,7 @@ WEAK_ALIAS (__re_match_2, re_match_2) /* This is a separate function so that we can force an alloca cleanup - afterwards. */ + afterwards. */ static int re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) struct re_pattern_buffer *bufp; @@ -4939,7 +4947,7 @@ re_char *end1, *end2; /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ + each to consider matching. */ re_char *end_match_1, *end_match_2; /* Where we are in the data, and the end of the current string. */ @@ -4955,10 +4963,10 @@ re_char *p = bufp->buffer; re_char *pend = p + bufp->used; - /* We use this to map every character in the string. */ + /* We use this to map every character in the string. */ RE_TRANSLATE_TYPE translate = bufp->translate; - /* Nonzero if we have to concern multibyte character. */ + /* Nonzero if we have to concern multibyte character. */ const boolean multibyte = RE_MULTIBYTE_P (bufp); /* Failure point stack. Each place that can handle a failure further @@ -4967,8 +4975,8 @@ the subexpressions we're currently inside, plus the number of such registers, and, finally, two char *'s. The first char * is where to resume scanning the pattern; the second one is where to resume - scanning the strings. */ -#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ + scanning the strings. */ +#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ fail_stack_type fail_stack; #endif #ifdef DEBUG @@ -4982,7 +4990,7 @@ #endif /* We fill all the registers internally, independent of what we - return, for use in backreferences. The number here includes + return, for use in backreferences. The number here includes an element for register zero. */ size_t num_regs = bufp->re_nsub + 1; @@ -5008,7 +5016,7 @@ /* Logically, this is `best_regend[0]'. But we don't want to have to allocate space for that if we're not allocating space for anything - else (see below). Also, we never need info about register 0 for + else (see below). Also, we never need info about register 0 for any of the other register vectors, and it seems rather a kludge to treat `best_regend' differently than the rest. So we keep track of the end of the best match so far in a separate variable. We @@ -5066,7 +5074,7 @@ regstart[reg] = regend[reg] = NULL; /* We move `string1' into `string2' if the latter's empty -- but not if - `string1' is null. */ + `string1' is null. */ if (size2 == 0 && string1 != NULL) { string2 = string1; @@ -5123,7 +5131,7 @@ DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); DEBUG_PRINT1 ("'\n"); - /* This loops over pattern commands. It exits by returning from the + /* This loops over pattern commands. It exits by returning from the function if the match is complete, or it drops through if the match fails at this starting point in the input data. */ for (;;) @@ -5146,7 +5154,7 @@ boolean best_match_p; /* AIX compiler got confused when this was combined - with the previous declaration. */ + with the previous declaration. */ if (same_str_p) best_match_p = d > match_end; else @@ -5184,7 +5192,7 @@ end_match_1' while the restored d is in string2. For example, the pattern `x.*y.*z' against the strings `x-' and `y-z-', if the two strings are - not consecutive in memory. */ + not consecutive in memory. */ DEBUG_PRINT1 ("Restoring best registers.\n"); d = match_end; @@ -5207,7 +5215,7 @@ { /* Have the register data arrays been allocated? */ if (bufp->regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. We need one + { /* No. So allocate them with malloc. We need one extra element beyond `num_regs' for the `-1' marker GNU code uses. */ regs->num_regs = MAX (RE_NREGS, num_regs + 1); @@ -5239,7 +5247,7 @@ else { /* These braces fend off a "empty body in an else-statement" - warning under GCC when assert expands to nothing. */ + warning under GCC when assert expands to nothing. */ assert (bufp->regs_allocated == REGS_FIXED); } @@ -5271,7 +5279,7 @@ were in the pattern, set the extra elements to -1. If we (re)allocated the registers, this is the case, because we always allocate enough to have at least one - -1 at the end. */ + -1 at the end. */ for (reg = num_regs; reg < regs->num_regs; reg++) regs->start[reg] = regs->end[reg] = -1; } /* regs && !bufp->no_sub */ @@ -5289,7 +5297,7 @@ return mcnt; } - /* Otherwise match next pattern command. */ + /* Otherwise match next pattern command. */ switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++)) { /* Ignore these. Used to ignore the n of succeed_n's which @@ -5302,9 +5310,9 @@ DEBUG_PRINT1 ("EXECUTING succeed.\n"); goto succeed_label; - /* Match the next n pattern characters exactly. The following + /* Match the next n pattern characters exactly. The following byte in the pattern defines n, and the n bytes after that - are the characters to match. */ + are the characters to match. */ case exactn: mcnt = *p++; DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); @@ -5468,7 +5476,7 @@ /* The beginning of a group is represented by start_memory. The argument is the register number. The text matched within the group is recorded (in the internal - registers data structure) under the register number. */ + registers data structure) under the register number. */ case start_memory: DEBUG_PRINT2 ("EXECUTING start_memory %d:\n", *p); @@ -5517,14 +5525,14 @@ case duplicate: { register re_char *d2, *dend2; - int regno = *p++; /* Get which register to match against. */ + int regno = *p++; /* Get which register to match against. */ DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); - /* Can't back reference a group which we've never matched. */ + /* Can't back reference a group which we've never matched. */ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) goto fail; - /* Where in input to try to start matching. */ + /* Where in input to try to start matching. */ d2 = regstart[regno]; /* Remember the start point to rollback upon failure. */ @@ -5637,7 +5645,7 @@ pushes NULL as the value for the string on the stack. Then `POP_FAILURE_POINT' will keep the current value for the string, instead of restoring it. To see why, consider - matching `foo\nbar' against `.*\n'. The .* matches the foo; + matching `foo\nbar' against `.*\n'. The .* matches the foo; then the . fails against the \n. But the next thing we want to do is match the \n against the \n; if we restored the string value, we would be back at the foo. @@ -5782,7 +5790,7 @@ IMMEDIATE_QUIT_CHECK; EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); - p += mcnt; /* Do the jump. */ + p += mcnt; /* Do the jump. */ DEBUG_PRINT2 ("(to %p).\n", p); break; @@ -5875,7 +5883,7 @@ if (/* Case 2: Only one of S1 and S2 is Sword. */ ((s1 == Sword) != (s2 == Sword)) /* Case 3: Both of S1 and S2 are Sword, and macro - WORD_BOUNDARY_P (C1, C2) returns nonzero. */ + WORD_BOUNDARY_P (C1, C2) returns nonzero. */ || ((s1 == Sword) && WORD_BOUNDARY_P (c1, c2))) not = !not; } @@ -5889,7 +5897,7 @@ /* We FAIL in one of the following cases: */ - /* Case 1: D is at the end of string. */ + /* Case 1: D is at the end of string. */ if (AT_STRINGS_END (d)) goto fail; else @@ -5921,7 +5929,7 @@ s1 = SYNTAX (c1); /* ... and S1 is Sword, and WORD_BOUNDARY_P (C1, C2) - returns 0. */ + returns 0. */ if ((s1 == Sword) && !WORD_BOUNDARY_P (c1, c2)) goto fail; } @@ -5965,7 +5973,7 @@ s2 = SYNTAX (c2); /* ... and S2 is Sword, and WORD_BOUNDARY_P (C1, C2) - returns 0. */ + returns 0. */ if ((s2 == Sword) && !WORD_BOUNDARY_P (c1, c2)) goto fail; } @@ -5977,7 +5985,7 @@ /* We FAIL in one of the following cases: */ - /* Case 1: D is at the end of string. */ + /* Case 1: D is at the end of string. */ if (AT_STRINGS_END (d)) goto fail; else @@ -5994,7 +6002,7 @@ PREFETCH (); c2 = RE_STRING_CHAR (d, dend - d); s2 = SYNTAX (c2); - + /* Case 2: S2 is neither Sword nor Ssymbol. */ if (s2 != Sword && s2 != Ssymbol) goto fail;