(Qfont_spec, Qfont_entity, Qfont_object): Extern them.
[bpt/emacs.git] / src / search.c
index aff998b..96daecb 100644 (file)
@@ -1,6 +1,7 @@
 /* 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.
 
@@ -140,7 +141,11 @@ compile_pattern_1 (cp, pattern, translate, regp, posix)
   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.
@@ -148,8 +153,11 @@ compile_pattern_1 (cp, pattern, translate, regp, posix)
   /*  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);
@@ -1784,7 +1792,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
                ch = -1;
            }
 
-         if (ch >= 0400)
+         if (ch >= 0200)
            j = (ch & 0x3F) | 0200;
          else
            j = *ptr;
@@ -1803,7 +1811,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
              while (1)
                {
                  TRANSLATE (ch, inverse_trt, ch);
-                 if (ch >= 0400)
+                 if (ch >= 0200)
                    j = (ch & 0x3F) | 0200;
                  else
                    j = ch;
@@ -2942,11 +2950,15 @@ Return value is undefined if the last search failed.  */)
   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.
@@ -3031,10 +3043,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere.  */)
 
            if (!NILP (reseat) && MARKERP (m))
              {
-               if (EQ (reseat, Qevaporate))
-                 free_marker (m);
-               else
-                 unchain_marker (XMARKER (m));
+               unchain_marker (XMARKER (m));
                XSETCAR (list, Qnil);
              }
 
@@ -3052,10 +3061,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere.  */)
 
            if (!NILP (reseat) && MARKERP (m))
              {
-               if (EQ (reseat, Qevaporate))
-                 free_marker (m);
-               else
-                 unchain_marker (XMARKER (m));
+               unchain_marker (XMARKER (m));
                XSETCAR (list, Qnil);
              }
          }
@@ -3119,8 +3125,8 @@ static Lisp_Object
 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.  */
@@ -3219,9 +3225,10 @@ A value of nil (which is the normal value) means treat spaces literally.  */);
 
   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);