Mercurial > hg > xemacs-beta
changeset 469:ccaeb2a3c329
[xemacs-hg @ 2001-04-13 15:04:38 by michaels]
2001-03-31 Mike Sperber <mike@xemacs.org>
* search.c (Freplace_match): [Again] support FSF-style
specification of match subexpression when applied to a buffer.
author | michaels |
---|---|
date | Fri, 13 Apr 2001 15:04:40 +0000 |
parents | 20ae8821c23d |
children | 8a548306e08d |
files | src/ChangeLog src/search.c |
diffstat | 2 files changed, 25 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Fri Apr 13 09:11:46 2001 +0000 +++ b/src/ChangeLog Fri Apr 13 15:04:40 2001 +0000 @@ -1,3 +1,8 @@ +2001-03-31 Mike Sperber <mike@xemacs.org> + + * search.c (Freplace_match): [Again] support FSF-style + specification of match subexpression when applied to a buffer. + 2001-04-07 Hrvoje Niksic <hniksic@arsdigita.com> * extents.c (Fset_extent_endpoints): Force creation of extent info
--- a/src/search.c Fri Apr 13 09:11:46 2001 +0000 +++ b/src/search.c Fri Apr 13 15:04:40 2001 +0000 @@ -2245,6 +2245,11 @@ defaults to the current buffer. When fourth argument is not a string, the buffer that the match occurred in has automatically been remembered and you do not need to specify it. + +When fourth argument is nil, STRBUFFER specifies a subexpression of +the match. It says to replace just that subexpression instead of the +whole match. This is useful only after a regular expression search or +match since only regular expressions have distinguished subexpressions. */ (replacement, fixedcase, literal, string, strbuffer)) { @@ -2264,6 +2269,7 @@ Lisp_Object buffer; int_dynarr *ul_action_dynarr = 0; int_dynarr *ul_pos_dynarr = 0; + int sub; int speccount; CHECK_STRING (replacement); @@ -2284,6 +2290,15 @@ } else { + if (NILP (strbuffer)) + sub = 0; + else + { + CHECK_INT (strbuffer); + sub = XINT (strbuffer); + if (sub < 0 || sub >= (int) search_regs.num_regs) + args_out_of_range (strbuffer, make_int (search_regs.num_regs)); + } if (!BUFFERP (last_thing_searched)) error ("last thing matched was not a buffer"); buffer = last_thing_searched; @@ -2300,11 +2315,11 @@ if (NILP (string)) { - if (search_regs.start[0] < BUF_BEGV (buf) - || search_regs.start[0] > search_regs.end[0] - || search_regs.end[0] > BUF_ZV (buf)) - args_out_of_range (make_int (search_regs.start[0]), - make_int (search_regs.end[0])); + if (search_regs.start[sub] < BUF_BEGV (buf) + || search_regs.start[sub] > search_regs.end[sub] + || search_regs.end[sub] > BUF_ZV (buf)) + args_out_of_range (make_int (search_regs.start[sub]), + make_int (search_regs.end[sub])); } else {