]> code.delx.au - gnu-emacs/blobdiff - src/search.c
Merge from emacs--rel--22
[gnu-emacs] / src / search.c
index 154f6c80e2d3db9ae2d25b82620818b41d30ffde..7761448f0d9a2f189ce8f256425b29b70b3bf59a 100644 (file)
@@ -1,12 +1,13 @@
 /* String search routines for GNU Emacs.
    Copyright (C) 1985, 1986, 1987, 1993, 1994, 1997, 1998, 1999, 2001, 2002,
 /* 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.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -1662,7 +1663,7 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
    have nontrivial translation are the same aside from the last byte.
    This makes it possible to translate just the last byte of a
    character, and do so after just a simple test of the context.
    have nontrivial translation are the same aside from the last byte.
    This makes it possible to translate just the last byte of a
    character, and do so after just a simple test of the context.
-   CHARSET_BASE is nonzero iff there is such a non-ASCII character.
+   CHARSET_BASE is nonzero if there is such a non-ASCII character.
 
    If that criterion is not satisfied, do not call this function.  */
 
 
    If that criterion is not satisfied, do not call this function.  */
 
@@ -1697,12 +1698,8 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
   int translate_prev_byte2 = 0;
   int translate_prev_byte3 = 0;
 
   int translate_prev_byte2 = 0;
   int translate_prev_byte3 = 0;
 
-#ifdef C_ALLOCA
-  int BM_tab_space[0400];
-  BM_tab = &BM_tab_space[0];
-#else
   BM_tab = (int *) alloca (0400 * sizeof (int));
   BM_tab = (int *) alloca (0400 * sizeof (int));
-#endif
+
   /* The general approach is that we are going to maintain that we know */
   /* the first (closest to the present position, in whatever direction */
   /* we're searching) character that could possibly be the last */
   /* The general approach is that we are going to maintain that we know */
   /* the first (closest to the present position, in whatever direction */
   /* we're searching) character that could possibly be the last */
@@ -2968,11 +2965,15 @@ Return value is undefined if the last search failed.  */)
   return reuse;
 }
 
   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.
 
 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.
@@ -3057,10 +3058,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere.  */)
 
            if (!NILP (reseat) && MARKERP (m))
              {
 
            if (!NILP (reseat) && MARKERP (m))
              {
-               if (EQ (reseat, Qevaporate))
-                 free_marker (m);
-               else
-                 unchain_marker (XMARKER (m));
+               unchain_marker (XMARKER (m));
                XSETCAR (list, Qnil);
              }
 
                XSETCAR (list, Qnil);
              }
 
@@ -3078,10 +3076,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere.  */)
 
            if (!NILP (reseat) && MARKERP (m))
              {
 
            if (!NILP (reseat) && MARKERP (m))
              {
-               if (EQ (reseat, Qevaporate))
-                 free_marker (m);
-               else
-                 unchain_marker (XMARKER (m));
+               unchain_marker (XMARKER (m));
                XSETCAR (list, Qnil);
              }
          }
                XSETCAR (list, Qnil);
              }
          }
@@ -3145,8 +3140,8 @@ static Lisp_Object
 unwind_set_match_data (list)
      Lisp_Object list;
 {
 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.  */
 }
 
 /* Called to unwind protect the match data.  */
@@ -3245,9 +3240,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.
 
   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);
   Vinhibit_changing_match_data = Qnil;
 
   defsubr (&Slooking_at);