Merge from emacs-23
[bpt/emacs.git] / src / regex.c
index 85ff9b9..46065dd 100644 (file)
@@ -290,7 +290,6 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
 #  define SWITCH_ENUM_CAST(x) (x)
 
 /* Dummy macros for non-Emacs environments.  */
-# define BASE_LEADING_CODE_P(c) (0)
 # define CHAR_CHARSET(c) 0
 # define CHARSET_LEADING_CODE_BASE(c) 0
 # define MAX_MULTIBYTE_LENGTH 1
@@ -300,7 +299,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
 # define CHAR_HEAD_P(p) (1)
 # define SINGLE_BYTE_CHAR_P(c) (1)
 # define SAME_CHARSET_P(c1, c2) (1)
-# define MULTIBYTE_FORM_LENGTH(p, s) (1)
+# define BYTES_BY_CHAR_HEAD(p) (1)
 # define PREV_CHAR_BOUNDARY(p, limit) ((p)--)
 # define STRING_CHAR(p) (*(p))
 # define RE_STRING_CHAR(p, multibyte) STRING_CHAR (p)
@@ -3070,7 +3069,7 @@ regex_compile (pattern, size, syntax, bufp)
                           syntax-table for ASCII chars, while the other chars
                           will obey syntax-table properties.  It's not ideal,
                           but it's the way it's been done until now.  */
-                       SETUP_SYNTAX_TABLE (BEGV, 0);
+                       SETUP_BUFFER_SYNTAX_TABLE ();
 
                        for (ch = 0; ch < 256; ++ch)
                          {
@@ -4496,7 +4495,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
   anchored_start = (bufp->buffer[0] == begline);
 
 #ifdef emacs
-  gl_state.object = re_match_object;
+  gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
   {
     int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos));
 
@@ -4643,7 +4642,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
            {
              re_char *p = POS_ADDR_VSTRING (startpos);
              re_char *pend = STOP_ADDR_VSTRING (startpos);
-             int len = MULTIBYTE_FORM_LENGTH (p, pend - p);
+             int len = BYTES_BY_CHAR_HEAD (*p);
 
              range -= len;
              if (range < 0)
@@ -5099,7 +5098,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
 
 #ifdef emacs
   int charpos;
-  gl_state.object = re_match_object;
+  gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
   charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos));
   SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1);
 #endif
@@ -6504,10 +6503,6 @@ re_compile_pattern (pattern, length, bufp)
 {
   reg_errcode_t ret;
 
-#ifdef emacs
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-#endif
-
   /* GNU code is written to assume at least RE_NREGS registers will be set
      (and at least one extra will be -1).  */
   bufp->regs_allocated = REGS_UNALLOCATED;