[gnu.emacs.bug] Possible Bug in store-match-data

munson%elm.Berkeley.EDU@BERKELEY.EDU (Ethan V. Munson) (12/30/88)

I believe I have found a bug in GNU Emacs 18.59.9 in "store-match-data".
When you store a match list of the form (nil nil marker1 marker2),
a subsequent call to "match-data" returns (nil nil nil nil marker1 marker2).
I have inspected the code in search.c and believe that the bug is the
result of a missing call to Fcdr.  A proposed fixed version of the function
definition follows.

Ethan Munson
munson@renoir.Berkeley.EDU
...ucbvax!renoir!munson
---------------------------------


DEFUN ("store-match-data", Fstore_match_data, Sstore_match_data, 1, 1, 0,
  "Set internal data on last search match from elements of LIST.\n\
LIST should have been created by calling match-data previously.")
  (list)
     register Lisp_Object list;
{
  register int i;
  register Lisp_Object marker;

  if (!CONSP (list) && !NULL (list))
    list = wrong_type_argument (Qconsp, list, 0);

  for (i = 0; i < RE_NREGS; i++)
    {
      marker = Fcar (list);
      if (NULL (marker)) 
	{
	  search_regs.start[i] = -1;
	  list = Fcdr (list);		/* added statement */
        }
      else
	{
	  CHECK_MARKER (marker, 0);
	  search_regs.start[i] = marker_position (marker);
	  list = Fcdr (list);

	  marker = Fcar (list);
	  CHECK_MARKER (marker, 0);
	  search_regs.end[i] = marker_position (marker);
	}
      list = Fcdr (list);
    }

  return Qnil;  
}