diff options
author | Yuan Fu <casouri@gmail.com> | 2022-11-21 12:54:35 -0800 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-11-21 12:54:35 -0800 |
commit | aaeaa310f0391f5a5193e1a3d6e026986c4f2c0c (patch) | |
tree | 67765b95359bfc462e95606043e6b0cea3bb7c49 /src/search.c | |
parent | b2ea38ab03e801859163b74a292aa75008e36541 (diff) | |
parent | f176a36f4629b56c9fd9e3fc15aebd04a168c4f5 (diff) | |
download | emacs-aaeaa310f0391f5a5193e1a3d6e026986c4f2c0c.tar.gz |
Merge remote-tracking branch 'savannah/master' into feature/tree-sitter
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/search.c b/src/search.c index bd1adbbe099..242681bbba0 100644 --- a/src/search.c +++ b/src/search.c @@ -1566,7 +1566,6 @@ simple_search (EMACS_INT n, unsigned char *pat, while (1) { /* Try matching at position POS. */ - ptrdiff_t this_pos = pos; ptrdiff_t this_pos_byte = pos_byte; ptrdiff_t this_len = len; unsigned char *p = pat; @@ -1588,7 +1587,6 @@ simple_search (EMACS_INT n, unsigned char *pat, p += charlen; this_pos_byte += buf_charlen; - this_pos++; } if (this_len == 0) @@ -2832,11 +2830,21 @@ Return value is undefined if the last search failed. */) } DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 3, 0, - doc: /* Return a list describing what the last search matched. -Element 2N is `(match-beginning N)'; element 2N + 1 is `(match-end N)'. -All the elements are markers or nil (nil if the Nth pair didn't match) -if the last match was on a buffer; integers or nil if a string was matched. -Use `set-match-data' to reinstate the data in this list. + doc: /* Return a list of positions that record text matched by the last search. +Element 2N of the returned list is the position of the beginning of the +match of the Nth subexpression; it corresponds to `(match-beginning N)'; +element 2N + 1 is the position of the end of the match of the Nth +subexpression; it corresponds to `(match-end N)'. See `match-beginning' +and `match-end'. +If the last search was on a buffer, all the elements are by default +markers or nil (nil when the Nth pair didn't match); they are integers +or nil if the search was on a string. But if the optional argument +INTEGERS is non-nil, the elements that represent buffer positions are +always integers, not markers, and (if the search was on a buffer) the +buffer itself is appended to the list as one additional element. + +Use `set-match-data' to reinstate the match data from the elements of +this list. Note that non-matching optional groups at the end of the regexp are elided instead of being represented with two `nil's each. For instance: @@ -2846,16 +2854,13 @@ elided instead of being represented with two `nil's each. For instance: (match-data)) => (0 1 nil nil 0 1) -If INTEGERS (the optional first argument) is non-nil, always use -integers (rather than markers) to represent buffer positions. In -this case, and if the last match was in a buffer, the buffer will get -stored as one additional element at the end of the list. - -If REUSE is a list, reuse it as part of the value. If REUSE is long -enough to hold all the values, and if INTEGERS is non-nil, no consing -is done. +If REUSE is a list, store the value in REUSE by destructively modifying it. +If REUSE is long enough to hold all the values, its length remains the +same, and any unused elements are set to nil. If REUSE is not long +enough, it is extended. Note that if REUSE is long enough and INTEGERS +is non-nil, no consing is done to make the return value; this minimizes GC. -If optional third arg RESEAT is non-nil, any previous markers on the +If optional third argument RESEAT is non-nil, any previous markers on the REUSE list will be modified to point to nowhere. Return value is undefined if the last search failed. */) |