Mercurial > hg > xemacs-beta
diff src/regex.c @ 1024:ccaf90c5a53a
[xemacs-hg @ 2002-10-02 09:29:37 by stephent]
21.4 -> R21.5 stuff
manual improvements <87k7l1p6su.fsf@tleepslib.sk.tsukuba.ac.jp>
regexp tests <87fzvpp6mf.fsf@tleepslib.sk.tsukuba.ac.jp>
add-to-list doc Ville Skyttä <87bs6dp6io.fsf@tleepslib.sk.tsukuba.ac.jp>
Move filename associations Ville Skyttä <877kh1p6ee.fsf@tleepslib.sk.tsukuba.ac.jp>
lookup-syntax-properties <87admil2e0.fsf_-_@tleepslib.sk.tsukuba.ac.jp>
fix stale submatches <873crpp50v.fsf_-_@tleepslib.sk.tsukuba.ac.jp>
info for developers <87y99hnqc4.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Wed, 02 Oct 2002 09:31:40 +0000 |
parents | 804517e16990 |
children | b03923afd851 |
line wrap: on
line diff
--- a/src/regex.c Tue Oct 01 21:55:21 2002 +0000 +++ b/src/regex.c Wed Oct 02 09:31:40 2002 +0000 @@ -4916,16 +4916,24 @@ (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); } } - - /* If the regs structure we return has more elements than - 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. */ - for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; } /* regs && !bufp->no_sub */ + /* If we have regs and the regs structure has more elements than + 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. + + We do this even when no_sub is set because some applications + (XEmacs) reuse register structures which may contain stale + information, and permit attempts to access those registers. + + It would be possible to require the caller to do this, but we'd + have to change the API for this function to reflect that, and + audit all callers. */ + if (regs && regs->num_regs > 0) + for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) + regs->start[mcnt] = regs->end[mcnt] = -1; + DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", nfailure_points_pushed, nfailure_points_popped, nfailure_points_pushed - nfailure_points_popped);