/* String search routines for GNU Emacs.
Copyright (C) 1985, 1986, 1987, 1993, 1994, 1997, 1998, 1999, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
cp->posix = posix;
cp->buf.multibyte = STRING_MULTIBYTE (pattern);
cp->buf.charset_unibyte = charset_unibyte;
- cp->whitespace_regexp = Vsearch_spaces_regexp;
+ if (STRINGP (Vsearch_spaces_regexp))
+ cp->whitespace_regexp = Vsearch_spaces_regexp;
+ else
+ cp->whitespace_regexp = Qnil;
+
/* rms: I think BLOCK_INPUT is not needed here any more,
because regex.c defines malloc to call xmalloc.
Using BLOCK_INPUT here means the debugger won't run if an error occurs.
/* BLOCK_INPUT; */
old = re_set_syntax (RE_SYNTAX_EMACS
| (posix ? 0 : RE_NO_POSIX_BACKTRACKING));
- re_set_whitespace_regexp (NILP (Vsearch_spaces_regexp) ? NULL
- : SDATA (Vsearch_spaces_regexp));
+
+ if (STRINGP (Vsearch_spaces_regexp))
+ re_set_whitespace_regexp (SDATA (Vsearch_spaces_regexp));
+ else
+ re_set_whitespace_regexp (NULL);
val = (char *) re_compile_pattern ((char *) SDATA (pattern),
SBYTES (pattern), &cp->buf);
ch = -1;
}
- if (ch >= 0400)
+ if (ch >= 0200)
j = (ch & 0x3F) | 0200;
else
j = *ptr;
while (1)
{
TRANSLATE (ch, inverse_trt, ch);
- if (ch >= 0400)
+ if (ch >= 0200)
j = (ch & 0x3F) | 0200;
else
j = ch;
return reuse;
}
-/* Internal usage only:
- If RESEAT is `evaporate', put the markers back on the free list
- immediately. No other references to the markers must exist in this case,
- so it is used only internally on the unwind stack and save-match-data from
- Lisp. */
+/* We used to have an internal use variant of `reseat' described as:
+
+ If RESEAT is `evaporate', put the markers back on the free list
+ immediately. No other references to the markers must exist in this
+ case, so it is used only internally on the unwind stack and
+ save-match-data from Lisp.
+
+ But it was ill-conceived: those supposedly-internal markers get exposed via
+ the undo-list, so freeing them here is unsafe. */
DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 2, 0,
doc: /* Set internal data on last search match from elements of LIST.
if (!NILP (reseat) && MARKERP (m))
{
- if (EQ (reseat, Qevaporate))
- free_marker (m);
- else
- unchain_marker (XMARKER (m));
+ unchain_marker (XMARKER (m));
XSETCAR (list, Qnil);
}
if (!NILP (reseat) && MARKERP (m))
{
- if (EQ (reseat, Qevaporate))
- free_marker (m);
- else
- unchain_marker (XMARKER (m));
+ unchain_marker (XMARKER (m));
XSETCAR (list, Qnil);
}
}
unwind_set_match_data (list)
Lisp_Object list;
{
- /* It is safe to free (evaporate) the markers immediately. */
- return Fset_match_data (list, Qevaporate);
+ /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */
+ return Fset_match_data (list, Qt);
}
/* Called to unwind protect the match data. */
DEFVAR_LISP ("inhibit-changing-match-data", &Vinhibit_changing_match_data,
doc: /* Internal use only.
-If non-nil, the match data will not be changed during call to searching or
-matching functions, such as `looking-at', `string-match', `re-search-forward'
-etc. */);
+If non-nil, the primitive searching and matching functions
+such as `looking-at', `string-match', `re-search-forward', etc.,
+do not set the match data. The proper way to use this variable
+is to bind it with `let' around a small expression. */);
Vinhibit_changing_match_data = Qnil;
defsubr (&Slooking_at);