]> code.delx.au - gnu-emacs/commitdiff
Cleanup setup of gl_state in various parts of the code.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 10 Mar 2010 14:45:21 +0000 (09:45 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 10 Mar 2010 14:45:21 +0000 (09:45 -0500)
* syntax.h (SETUP_BUFFER_SYNTAX_TABLE): New macro.
(SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
* syntax.c (find_defun_start, Fchar_syntax, Fmatching_paren, skip_chars):
* regex.c (regex_compile): Use it.
(re_compile_pattern): Don't set gl_state.current_syntax_table since
it's now set in regex_compile when/if we need it.

src/ChangeLog
src/keyboard.c
src/regex.c
src/syntax.c
src/syntax.h

index ce4fe1cd7b4e9bccfc99a57433cf4c9aa705e932..96c6c66f1fc27a8487a113defd2b4c9770faf3ca 100644 (file)
@@ -1,3 +1,14 @@
+2010-03-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       Cleanup setup of gl_state in various parts of the code.
+       * syntax.h (SETUP_BUFFER_SYNTAX_TABLE): New macro.
+       (SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
+       * syntax.c (find_defun_start, Fchar_syntax, Fmatching_paren)
+       (skip_chars):
+       * regex.c (regex_compile): Use it.
+       (re_compile_pattern): Don't set gl_state.current_syntax_table since
+       it's now set in regex_compile when/if we need it.
+
 2010-03-05  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        Make it possible to C-g in a tight bytecode loop again (bug#5680).
index 1e331d078cef23ad3b908ec049bc789c361445b8..48d39235e3f5e36ff120c0167030a9471042c897 100644 (file)
@@ -11235,6 +11235,7 @@ handle_interrupt ()
          GCPRO4 (saved.object, saved.global_code,
                  saved.current_syntax_table, saved.old_prop);
          Fsignal (Qquit, Qnil);
+         /* FIXME: AFAIK, `quit' can never return, so this code is dead!  */
          gl_state = saved;
          UNGCPRO;
        }
index f242446796d7518b7bfef57accfba6a47b19312b..e59c48aad742699ecadca5fb1d0952ccb7f75b0a 100644 (file)
@@ -3070,7 +3070,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 +4496,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));
 
@@ -5099,7 +5099,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 +6504,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;
index 47b4caf5ade15c6c619d062218562d6124d5cf2e..a80f047e43c5d39a1a95d79dda3f0b4d0fc765b1 100644 (file)
@@ -385,8 +385,7 @@ find_defun_start (pos, pos_byte)
   /* We optimize syntax-table lookup for rare updates.  Thus we accept
      only those `^\s(' which are good in global _and_ text-property
      syntax-tables.  */
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-  gl_state.use_global = 0;
+  SETUP_BUFFER_SYNTAX_TABLE ();
   while (PT > BEGV)
     {
       int c;
@@ -401,8 +400,7 @@ find_defun_start (pos, pos_byte)
          if (SYNTAX (c) == Sopen)
            break;
          /* Now fallback to the default value.  */
-         gl_state.current_syntax_table = current_buffer->syntax_table;
-         gl_state.use_global = 0;
+         SETUP_BUFFER_SYNTAX_TABLE ();
        }
       /* Move to beg of previous line.  */
       scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1);
@@ -860,11 +858,9 @@ are listed in the documentation of `modify-syntax-entry'.  */)
      Lisp_Object character;
 {
   int char_int;
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-
-  gl_state.use_global = 0;
   CHECK_NUMBER (character);
   char_int = XINT (character);
+  SETUP_BUFFER_SYNTAX_TABLE ();
   return make_number (syntax_code_spec[(int) SYNTAX (char_int)]);
 }
 
@@ -874,10 +870,9 @@ DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0,
      Lisp_Object character;
 {
   int char_int, code;
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-  gl_state.use_global = 0;
   CHECK_NUMBER (character);
   char_int = XINT (character);
+  SETUP_BUFFER_SYNTAX_TABLE ();
   code = SYNTAX (char_int);
   if (code == Sopen || code == Sclose)
     return SYNTAX_MATCH (char_int);
@@ -1752,7 +1747,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
        let's initialize it manually.
        We ignore syntax-table text-properties for now, since that's
        what we've done in the past.  */
-    SETUP_SYNTAX_TABLE (BEGV, 0);
+    SETUP_BUFFER_SYNTAX_TABLE ();
     if (forwardp)
       {
        if (multibyte)
index c36b1eb28f6d881507f7a919506c0d947f9c1410..ec8fab0166c04facd29fb87daab37ef46968c620 100644 (file)
@@ -245,6 +245,14 @@ extern char syntax_code_spec[16];
         1)                                                     \
       : 0))
 
+/* This macro sets up the buffer-global syntax table.  */
+#define SETUP_BUFFER_SYNTAX_TABLE()                                    \
+do                                                                     \
+  {                                                                    \
+    gl_state.use_global = 0;                                           \
+    gl_state.current_syntax_table = current_buffer->syntax_table;      \
+  } while (0)
+
 /* This macro should be called with FROM at the start of forward
    search, or after the last position of the backward search.  It
    makes sure that the first char is picked up with correct table, so
@@ -256,12 +264,11 @@ extern char syntax_code_spec[16];
 #define SETUP_SYNTAX_TABLE(FROM, COUNT)                                        \
 do                                                                     \
   {                                                                    \
+    SETUP_BUFFER_SYNTAX_TABLE ();                                      \
     gl_state.b_property = BEGV;                                                \
     gl_state.e_property = ZV + 1;                                      \
     gl_state.object = Qnil;                                            \
-    gl_state.use_global = 0;                                           \
     gl_state.offset = 0;                                               \
-    gl_state.current_syntax_table = current_buffer->syntax_table;      \
     if (parse_sexp_lookup_properties)                                  \
       if ((COUNT) > 0 || (FROM) > BEGV)                                        \
         update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\
@@ -279,6 +286,7 @@ while (0)
 #define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT)             \
 do                                                                     \
   {                                                                    \
+    SETUP_BUFFER_SYNTAX_TABLE ();                                      \
     gl_state.object = (OBJECT);                                                \
     if (BUFFERP (gl_state.object))                                     \
       {                                                                        \
@@ -305,8 +313,6 @@ do                                                                  \
        gl_state.e_property = 1 + SCHARS (gl_state.object);             \
        gl_state.offset = 0;                                            \
       }                                                                        \
-    gl_state.use_global = 0;                                           \
-    gl_state.current_syntax_table = current_buffer->syntax_table;      \
     if (parse_sexp_lookup_properties)                                  \
       update_syntax_table (((FROM) + gl_state.offset                   \
                            + (COUNT > 0 ? 0 :  -1)),                   \