(Finsert_file_contents): If enable-multibyte-characters
[bpt/emacs.git] / src / search.c
index 720012d..790f35f 100644 (file)
@@ -394,7 +394,7 @@ fast_string_match (regexp, string)
 extern Lisp_Object Vascii_downcase_table;
 
 int
-fast_string_match_ignore_case (regexp, string)
+fast_c_string_match_ignore_case (regexp, string)
      Lisp_Object regexp;
      char *string;
 {
@@ -402,6 +402,7 @@ fast_string_match_ignore_case (regexp, string)
   struct re_pattern_buffer *bufp;
   int len = strlen (string);
 
+  re_match_object = Qt;
   bufp = compile_pattern (regexp, 0,
                          XCHAR_TABLE (Vascii_downcase_table)->contents, 0);
   immediate_quit = 1;
@@ -944,7 +945,7 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
                len--;
                base_pat++;
              }
-           *pat++ = (trt ? trt[*base_pat++] : *base_pat++);
+           *pat++ = (trt ? XINT (trt[*base_pat++]) : *base_pat++);
          }
        len = pat - patbuf;
        pat = base_pat = patbuf;
@@ -999,13 +1000,13 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
          if (i == dirlen) i = infinity;
          if (trt != 0)
            {
-             k = (j = trt[j]);
+             k = (j = XINT (trt[j]));
              if (i == infinity)
                stride_for_teases = BM_tab[j];
              BM_tab[j] = dirlen - i;
              /* A translation table is accompanied by its inverse -- see */
              /* comment following downcase_table for details */ 
-             while ((j = (unsigned char) inverse_trt[j]) != k)
+             while ((j = (unsigned char) XINT (inverse_trt[j])) != k)
                BM_tab[j] = dirlen - i;
            }
          else
@@ -1088,7 +1089,7 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
                  if (trt != 0)
                    {
                      while ((i -= direction) + direction != 0)
-                       if (pat[i] != trt[*(cursor -= direction)])
+                       if (pat[i] != XINT (trt[*(cursor -= direction)]))
                          break;
                    }
                  else
@@ -1149,7 +1150,7 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
                    {
                      pos -= direction;
                      if (pat[i] != (trt != 0
-                                    ? trt[FETCH_BYTE (pos)]
+                                    ? XINT (trt[FETCH_BYTE (pos)])
                                     : FETCH_BYTE (pos)))
                        break;
                    }
@@ -1422,7 +1423,7 @@ since only regular expressions have distinguished subexpressions.")
   register int c, prevc;
   int inslen;
   int sub;
-  int opoint;
+  int opoint, newpoint;
 
   CHECK_STRING (newtext, 0);
 
@@ -1675,14 +1676,16 @@ since only regular expressions have distinguished subexpressions.")
   else if (case_action == cap_initial)
     Fupcase_initials_region (make_number (PT - inslen), make_number (PT));
 
+  newpoint = PT;
+
   /* Put point back where it was in the text.  */
-  if (opoint < 0)
+  if (opoint <= 0)
     temp_set_point (opoint + ZV, current_buffer);
   else
     temp_set_point (opoint, current_buffer);
 
   /* Now move point "officially" to the start of the inserted replacement.  */
-  move_if_not_intangible (search_regs.start[sub]);
+  move_if_not_intangible (newpoint);
   
   return Qnil;
 }