aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2010-03-10 09:45:21 -0500
committerStefan Monnier2010-03-10 09:45:21 -0500
commitd48cd3f48fdd0d67f906311b632fb58ae4765b5e (patch)
tree01c407576bb4aa2e07765a0314a58d2344960fce /src
parent61c264722eabe920e3fadf892eb9d2e1c84d1ae3 (diff)
downloademacs-d48cd3f48fdd0d67f906311b632fb58ae4765b5e.tar.gz
emacs-d48cd3f48fdd0d67f906311b632fb58ae4765b5e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/keyboard.c1
-rw-r--r--src/regex.c10
-rw-r--r--src/syntax.c15
-rw-r--r--src/syntax.h14
5 files changed, 30 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ce4fe1cd7b4..96c6c66f1fc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12010-03-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 Cleanup setup of gl_state in various parts of the code.
4 * syntax.h (SETUP_BUFFER_SYNTAX_TABLE): New macro.
5 (SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
6 * syntax.c (find_defun_start, Fchar_syntax, Fmatching_paren)
7 (skip_chars):
8 * regex.c (regex_compile): Use it.
9 (re_compile_pattern): Don't set gl_state.current_syntax_table since
10 it's now set in regex_compile when/if we need it.
11
12010-03-05 Stefan Monnier <monnier@iro.umontreal.ca> 122010-03-05 Stefan Monnier <monnier@iro.umontreal.ca>
2 13
3 Make it possible to C-g in a tight bytecode loop again (bug#5680). 14 Make it possible to C-g in a tight bytecode loop again (bug#5680).
diff --git a/src/keyboard.c b/src/keyboard.c
index 1e331d078ce..48d39235e3f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11235,6 +11235,7 @@ handle_interrupt ()
11235 GCPRO4 (saved.object, saved.global_code, 11235 GCPRO4 (saved.object, saved.global_code,
11236 saved.current_syntax_table, saved.old_prop); 11236 saved.current_syntax_table, saved.old_prop);
11237 Fsignal (Qquit, Qnil); 11237 Fsignal (Qquit, Qnil);
11238 /* FIXME: AFAIK, `quit' can never return, so this code is dead! */
11238 gl_state = saved; 11239 gl_state = saved;
11239 UNGCPRO; 11240 UNGCPRO;
11240 } 11241 }
diff --git a/src/regex.c b/src/regex.c
index f242446796d..e59c48aad74 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -3070,7 +3070,7 @@ regex_compile (pattern, size, syntax, bufp)
3070 syntax-table for ASCII chars, while the other chars 3070 syntax-table for ASCII chars, while the other chars
3071 will obey syntax-table properties. It's not ideal, 3071 will obey syntax-table properties. It's not ideal,
3072 but it's the way it's been done until now. */ 3072 but it's the way it's been done until now. */
3073 SETUP_SYNTAX_TABLE (BEGV, 0); 3073 SETUP_BUFFER_SYNTAX_TABLE ();
3074 3074
3075 for (ch = 0; ch < 256; ++ch) 3075 for (ch = 0; ch < 256; ++ch)
3076 { 3076 {
@@ -4496,7 +4496,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
4496 anchored_start = (bufp->buffer[0] == begline); 4496 anchored_start = (bufp->buffer[0] == begline);
4497 4497
4498#ifdef emacs 4498#ifdef emacs
4499 gl_state.object = re_match_object; 4499 gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
4500 { 4500 {
4501 int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos)); 4501 int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos));
4502 4502
@@ -5099,7 +5099,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
5099 5099
5100#ifdef emacs 5100#ifdef emacs
5101 int charpos; 5101 int charpos;
5102 gl_state.object = re_match_object; 5102 gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
5103 charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos)); 5103 charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos));
5104 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); 5104 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1);
5105#endif 5105#endif
@@ -6504,10 +6504,6 @@ re_compile_pattern (pattern, length, bufp)
6504{ 6504{
6505 reg_errcode_t ret; 6505 reg_errcode_t ret;
6506 6506
6507#ifdef emacs
6508 gl_state.current_syntax_table = current_buffer->syntax_table;
6509#endif
6510
6511 /* GNU code is written to assume at least RE_NREGS registers will be set 6507 /* GNU code is written to assume at least RE_NREGS registers will be set
6512 (and at least one extra will be -1). */ 6508 (and at least one extra will be -1). */
6513 bufp->regs_allocated = REGS_UNALLOCATED; 6509 bufp->regs_allocated = REGS_UNALLOCATED;
diff --git a/src/syntax.c b/src/syntax.c
index 47b4caf5ade..a80f047e43c 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -385,8 +385,7 @@ find_defun_start (pos, pos_byte)
385 /* We optimize syntax-table lookup for rare updates. Thus we accept 385 /* We optimize syntax-table lookup for rare updates. Thus we accept
386 only those `^\s(' which are good in global _and_ text-property 386 only those `^\s(' which are good in global _and_ text-property
387 syntax-tables. */ 387 syntax-tables. */
388 gl_state.current_syntax_table = current_buffer->syntax_table; 388 SETUP_BUFFER_SYNTAX_TABLE ();
389 gl_state.use_global = 0;
390 while (PT > BEGV) 389 while (PT > BEGV)
391 { 390 {
392 int c; 391 int c;
@@ -401,8 +400,7 @@ find_defun_start (pos, pos_byte)
401 if (SYNTAX (c) == Sopen) 400 if (SYNTAX (c) == Sopen)
402 break; 401 break;
403 /* Now fallback to the default value. */ 402 /* Now fallback to the default value. */
404 gl_state.current_syntax_table = current_buffer->syntax_table; 403 SETUP_BUFFER_SYNTAX_TABLE ();
405 gl_state.use_global = 0;
406 } 404 }
407 /* Move to beg of previous line. */ 405 /* Move to beg of previous line. */
408 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); 406 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1);
@@ -860,11 +858,9 @@ are listed in the documentation of `modify-syntax-entry'. */)
860 Lisp_Object character; 858 Lisp_Object character;
861{ 859{
862 int char_int; 860 int char_int;
863 gl_state.current_syntax_table = current_buffer->syntax_table;
864
865 gl_state.use_global = 0;
866 CHECK_NUMBER (character); 861 CHECK_NUMBER (character);
867 char_int = XINT (character); 862 char_int = XINT (character);
863 SETUP_BUFFER_SYNTAX_TABLE ();
868 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); 864 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]);
869} 865}
870 866
@@ -874,10 +870,9 @@ DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0,
874 Lisp_Object character; 870 Lisp_Object character;
875{ 871{
876 int char_int, code; 872 int char_int, code;
877 gl_state.current_syntax_table = current_buffer->syntax_table;
878 gl_state.use_global = 0;
879 CHECK_NUMBER (character); 873 CHECK_NUMBER (character);
880 char_int = XINT (character); 874 char_int = XINT (character);
875 SETUP_BUFFER_SYNTAX_TABLE ();
881 code = SYNTAX (char_int); 876 code = SYNTAX (char_int);
882 if (code == Sopen || code == Sclose) 877 if (code == Sopen || code == Sclose)
883 return SYNTAX_MATCH (char_int); 878 return SYNTAX_MATCH (char_int);
@@ -1752,7 +1747,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1752 let's initialize it manually. 1747 let's initialize it manually.
1753 We ignore syntax-table text-properties for now, since that's 1748 We ignore syntax-table text-properties for now, since that's
1754 what we've done in the past. */ 1749 what we've done in the past. */
1755 SETUP_SYNTAX_TABLE (BEGV, 0); 1750 SETUP_BUFFER_SYNTAX_TABLE ();
1756 if (forwardp) 1751 if (forwardp)
1757 { 1752 {
1758 if (multibyte) 1753 if (multibyte)
diff --git a/src/syntax.h b/src/syntax.h
index c36b1eb28f6..ec8fab0166c 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -245,6 +245,14 @@ extern char syntax_code_spec[16];
245 1) \ 245 1) \
246 : 0)) 246 : 0))
247 247
248/* This macro sets up the buffer-global syntax table. */
249#define SETUP_BUFFER_SYNTAX_TABLE() \
250do \
251 { \
252 gl_state.use_global = 0; \
253 gl_state.current_syntax_table = current_buffer->syntax_table; \
254 } while (0)
255
248/* This macro should be called with FROM at the start of forward 256/* This macro should be called with FROM at the start of forward
249 search, or after the last position of the backward search. It 257 search, or after the last position of the backward search. It
250 makes sure that the first char is picked up with correct table, so 258 makes sure that the first char is picked up with correct table, so
@@ -256,12 +264,11 @@ extern char syntax_code_spec[16];
256#define SETUP_SYNTAX_TABLE(FROM, COUNT) \ 264#define SETUP_SYNTAX_TABLE(FROM, COUNT) \
257do \ 265do \
258 { \ 266 { \
267 SETUP_BUFFER_SYNTAX_TABLE (); \
259 gl_state.b_property = BEGV; \ 268 gl_state.b_property = BEGV; \
260 gl_state.e_property = ZV + 1; \ 269 gl_state.e_property = ZV + 1; \
261 gl_state.object = Qnil; \ 270 gl_state.object = Qnil; \
262 gl_state.use_global = 0; \
263 gl_state.offset = 0; \ 271 gl_state.offset = 0; \
264 gl_state.current_syntax_table = current_buffer->syntax_table; \
265 if (parse_sexp_lookup_properties) \ 272 if (parse_sexp_lookup_properties) \
266 if ((COUNT) > 0 || (FROM) > BEGV) \ 273 if ((COUNT) > 0 || (FROM) > BEGV) \
267 update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\ 274 update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\
@@ -279,6 +286,7 @@ while (0)
279#define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \ 286#define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \
280do \ 287do \
281 { \ 288 { \
289 SETUP_BUFFER_SYNTAX_TABLE (); \
282 gl_state.object = (OBJECT); \ 290 gl_state.object = (OBJECT); \
283 if (BUFFERP (gl_state.object)) \ 291 if (BUFFERP (gl_state.object)) \
284 { \ 292 { \
@@ -305,8 +313,6 @@ do \
305 gl_state.e_property = 1 + SCHARS (gl_state.object); \ 313 gl_state.e_property = 1 + SCHARS (gl_state.object); \
306 gl_state.offset = 0; \ 314 gl_state.offset = 0; \
307 } \ 315 } \
308 gl_state.use_global = 0; \
309 gl_state.current_syntax_table = current_buffer->syntax_table; \
310 if (parse_sexp_lookup_properties) \ 316 if (parse_sexp_lookup_properties) \
311 update_syntax_table (((FROM) + gl_state.offset \ 317 update_syntax_table (((FROM) + gl_state.offset \
312 + (COUNT > 0 ? 0 : -1)), \ 318 + (COUNT > 0 ? 0 : -1)), \