unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Discrepancy in definition/use of match-data?
@ 2004-06-09 15:37 David Kastrup
  2004-06-10 23:01 ` Richard Stallman
  0 siblings, 1 reply; 16+ messages in thread
From: David Kastrup @ 2004-06-09 15:37 UTC (permalink / raw)



We have the following excerpt here:

static Lisp_Object
match_limit (num, beginningp)
     Lisp_Object num;
     int beginningp;
{
  register int n;

  CHECK_NUMBER (num);
  n = XINT (num);
  if (n < 0 || n >= search_regs.num_regs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    args_out_of_range (num, make_number (search_regs.num_regs));
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  if (search_regs.num_regs <= 0
      || search_regs.start[n] < 0)
    return Qnil;
  return (make_number ((beginningp) ? search_regs.start[n]
		                    : search_regs.end[n]));
}

DEFUN ("match-beginning", Fmatch_beginning, Smatch_beginning, 1, 1, 0,
       doc: /* Return position of start of text matched by last search.
SUBEXP, a number, specifies which parenthesized expression in the last
  regexp.
Value is nil if SUBEXPth pair didn't match, or there were less than
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  SUBEXP pairs.
  ^^^^^^^^^^^^^

Same for match-end and probably match-string.  But if there was no
previous match with at least the same number of SUBEXPs in the
history of the Emacs session, we will get an args_out_of_range error.

I think the fix would be to have match-limit return Qnil instead of
flagging an error for the condition

  n >= search_regs.num_regs

Correct?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-06-23  9:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-09 15:37 Discrepancy in definition/use of match-data? David Kastrup
2004-06-10 23:01 ` Richard Stallman
2004-06-10 23:56   ` David Kastrup
2004-06-11  8:34     ` Stephen J. Turnbull
2004-06-11  8:54       ` David Kastrup
2004-06-12  6:45         ` Stephen J. Turnbull
2004-06-12  9:03           ` David Kastrup
2004-06-13  0:01           ` Richard Stallman
2004-06-14  5:06             ` Stephen J. Turnbull
2004-06-14  9:05               ` David Kastrup
2004-06-14 10:05                 ` Stephen J. Turnbull
2004-06-16  7:13               ` Stephen J. Turnbull
2004-06-19  3:19                 ` Richard Stallman
2004-06-23  9:53                   ` Stephen J. Turnbull
2004-06-19  3:19                 ` Richard Stallman
2004-06-12  1:51     ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).