changeset 20824:97df0c6e753d

(search_buffer): New args pos_byte and lim_byte. (search_command): Pass new args.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 Feb 1998 06:15:42 +0000
parents 146647357199
children 1b98a0ab1bee
files src/search.c
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c	Tue Feb 03 06:14:39 1998 +0000
+++ b/src/search.c	Tue Feb 03 06:15:42 1998 +0000
@@ -857,7 +857,7 @@
      int posix;
 {
   register int np;
-  int lim;
+  int lim, lim_byte;
   int n = direction;
 
   if (!NILP (count))
@@ -868,20 +868,26 @@
 
   CHECK_STRING (string, 0);
   if (NILP (bound))
-    lim = n > 0 ? ZV : BEGV;
+    {
+      if (n > 0)
+	lim = ZV, lim_byte = ZV_BYTE;
+      else
+	lim = BEGV, lim_byte = BEGV_BYTE;
+    }
   else
     {
       CHECK_NUMBER_COERCE_MARKER (bound, 1);
       lim = XINT (bound);
+      lim_byte = CHAR_TO_BYTE (lim);
       if (n > 0 ? lim < PT : lim > PT)
 	error ("Invalid search bound (wrong side of point)");
       if (lim > ZV)
-	lim = ZV;
+	lim = ZV, lim_byte = ZV_BYTE;
       if (lim < BEGV)
-	lim = BEGV;
+	lim = BEGV, lim_byte = BEGV_BYTE;
     }
 
-  np = search_buffer (string, PT, lim, n, RE,
+  np = search_buffer (string, PT, PT_BYTE, lim, lim_byte, n, RE,
 		      (!NILP (current_buffer->case_fold_search)
 		       ? XCHAR_TABLE (current_buffer->case_canon_table)->contents
 		       : 0),
@@ -897,7 +903,7 @@
 	{
 	  if (lim < BEGV || lim > ZV)
 	    abort ();
-	  SET_PT (lim);
+	  SET_PT_BOTH (lim, lim_byte);
 	  return Qnil;
 #if 0 /* This would be clean, but maybe programs depend on
 	 a value of nil here.  */
@@ -965,10 +971,13 @@
    for this pattern.  0 means backtrack only enough to get a valid match.  */
 
 static int
-search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
+search_buffer (string, pos, pos_byte, lim, lim_byte, n,
+	       RE, trt, inverse_trt, posix)
      Lisp_Object string;
      int pos;
+     int pos_byte;
      int lim;
+     int lim_byte;
      int n;
      int RE;
      Lisp_Object *trt;
@@ -1005,8 +1014,6 @@
   if (RE && !trivial_regexp_p (string))
     {
       struct re_pattern_buffer *bufp;
-      int pos_byte = CHAR_TO_BYTE (pos);
-      int lim_byte = CHAR_TO_BYTE (lim);
 
       bufp = compile_pattern (string, &search_regs, trt, posix,
 			      !NILP (current_buffer->enable_multibyte_characters));
@@ -1105,8 +1112,6 @@
     }
   else				/* non-RE case */
     {
-      int pos_byte = CHAR_TO_BYTE (pos);
-      int lim_byte = CHAR_TO_BYTE (lim);
 #ifdef C_ALLOCA
       int BM_tab_space[0400];
       BM_tab = &BM_tab_space[0];