Mercurial > hg > xemacs-beta
comparison src/syntax.c @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | 9d177e8d4150 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
115 | 115 |
116 static Bufpos | 116 static Bufpos |
117 find_defun_start (struct buffer *buf, Bufpos pos) | 117 find_defun_start (struct buffer *buf, Bufpos pos) |
118 { | 118 { |
119 Bufpos tem; | 119 Bufpos tem; |
120 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 120 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
121 | 121 |
122 /* Use previous finding, if it's valid and applies to this inquiry. */ | 122 /* Use previous finding, if it's valid and applies to this inquiry. */ |
123 if (buf == find_start_buffer | 123 if (buf == find_start_buffer |
124 /* Reuse the defun-start even if POS is a little farther on. | 124 /* Reuse the defun-start even if POS is a little farther on. |
125 POS might be in the next defun, but that's ok. | 125 POS might be in the next defun, but that's ok. |
266 Optional second argument TABLE defaults to the current buffer's | 266 Optional second argument TABLE defaults to the current buffer's |
267 syntax table. | 267 syntax table. |
268 */ | 268 */ |
269 (ch, table)) | 269 (ch, table)) |
270 { | 270 { |
271 struct Lisp_Char_Table *mirrortab; | 271 Lisp_Char_Table *mirrortab; |
272 | 272 |
273 if (NILP(ch)) | 273 if (NILP(ch)) |
274 { | 274 { |
275 ch = make_char('\000'); | 275 ch = make_char('\000'); |
276 } | 276 } |
312 Optional second argument TABLE defaults to the current buffer's | 312 Optional second argument TABLE defaults to the current buffer's |
313 syntax table. | 313 syntax table. |
314 */ | 314 */ |
315 (ch, table)) | 315 (ch, table)) |
316 { | 316 { |
317 struct Lisp_Char_Table *mirrortab; | 317 Lisp_Char_Table *mirrortab; |
318 int code; | 318 int code; |
319 | 319 |
320 CHECK_CHAR_COERCE_INT (ch); | 320 CHECK_CHAR_COERCE_INT (ch); |
321 table = check_syntax_table (table, current_buffer->syntax_table); | 321 table = check_syntax_table (table, current_buffer->syntax_table); |
322 mirrortab = XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table); | 322 mirrortab = XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table); |
346 | 346 |
347 Bufpos | 347 Bufpos |
348 scan_words (struct buffer *buf, Bufpos from, int count) | 348 scan_words (struct buffer *buf, Bufpos from, int count) |
349 { | 349 { |
350 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); | 350 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); |
351 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 351 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
352 Emchar ch0, ch1; | 352 Emchar ch0, ch1; |
353 enum syntaxcode code; | 353 enum syntaxcode code; |
354 | 354 |
355 /* #### is it really worth it to hand expand both cases? JV */ | 355 /* #### is it really worth it to hand expand both cases? JV */ |
356 while (count > 0) | 356 while (count > 0) |
474 static int | 474 static int |
475 find_start_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask) | 475 find_start_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask) |
476 { | 476 { |
477 Emchar c; | 477 Emchar c; |
478 enum syntaxcode code; | 478 enum syntaxcode code; |
479 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 479 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
480 | 480 |
481 /* Look back, counting the parity of string-quotes, | 481 /* Look back, counting the parity of string-quotes, |
482 and recording the comment-starters seen. | 482 and recording the comment-starters seen. |
483 When we reach a safe place, assume that's not in a string; | 483 When we reach a safe place, assume that's not in a string; |
484 then step the main scan to the earliest comment-starter seen | 484 then step the main scan to the earliest comment-starter seen |
608 | 608 |
609 static Bufpos | 609 static Bufpos |
610 find_end_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask) | 610 find_end_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask) |
611 { | 611 { |
612 int c; | 612 int c; |
613 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 613 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
614 | 614 |
615 while (1) | 615 while (1) |
616 { | 616 { |
617 if (from == stop) | 617 if (from == stop) |
618 { | 618 { |
661 Bufpos stop; | 661 Bufpos stop; |
662 Emchar c; | 662 Emchar c; |
663 enum syntaxcode code; | 663 enum syntaxcode code; |
664 EMACS_INT count; | 664 EMACS_INT count; |
665 struct buffer *buf = decode_buffer (buffer, 0); | 665 struct buffer *buf = decode_buffer (buffer, 0); |
666 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 666 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
667 | 667 |
668 CHECK_INT (n); | 668 CHECK_INT (n); |
669 count = XINT (n); | 669 count = XINT (n); |
670 | 670 |
671 from = BUF_PT (buf); | 671 from = BUF_PT (buf); |
815 int quoted; | 815 int quoted; |
816 int mathexit = 0; | 816 int mathexit = 0; |
817 enum syntaxcode code; | 817 enum syntaxcode code; |
818 int min_depth = depth; /* Err out if depth gets less than this. */ | 818 int min_depth = depth; /* Err out if depth gets less than this. */ |
819 Lisp_Object syntaxtab = buf->syntax_table; | 819 Lisp_Object syntaxtab = buf->syntax_table; |
820 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 820 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
821 | 821 |
822 if (depth > 0) min_depth = 0; | 822 if (depth > 0) min_depth = 0; |
823 | 823 |
824 while (count > 0) | 824 while (count > 0) |
825 { | 825 { |
1134 char_quoted (struct buffer *buf, Bufpos pos) | 1134 char_quoted (struct buffer *buf, Bufpos pos) |
1135 { | 1135 { |
1136 enum syntaxcode code; | 1136 enum syntaxcode code; |
1137 Bufpos beg = BUF_BEGV (buf); | 1137 Bufpos beg = BUF_BEGV (buf); |
1138 int quoted = 0; | 1138 int quoted = 0; |
1139 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 1139 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
1140 | 1140 |
1141 while (pos > beg | 1141 while (pos > beg |
1142 && ((code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1))) | 1142 && ((code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1))) |
1143 == Scharquote | 1143 == Scharquote |
1144 || code == Sescape)) | 1144 || code == Sescape)) |
1216 (buffer)) | 1216 (buffer)) |
1217 { | 1217 { |
1218 struct buffer *buf = decode_buffer (buffer, 0); | 1218 struct buffer *buf = decode_buffer (buffer, 0); |
1219 Bufpos beg = BUF_BEGV (buf); | 1219 Bufpos beg = BUF_BEGV (buf); |
1220 Bufpos pos = BUF_PT (buf); | 1220 Bufpos pos = BUF_PT (buf); |
1221 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 1221 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
1222 | 1222 |
1223 while (pos > beg && !char_quoted (buf, pos - 1) | 1223 while (pos > beg && !char_quoted (buf, pos - 1) |
1224 && (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)) == Squote | 1224 && (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)) == Squote |
1225 || SYNTAX_PREFIX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)))) | 1225 || SYNTAX_PREFIX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)))) |
1226 pos--; | 1226 pos--; |
1256 int mindepth; /* Lowest DEPTH value seen. */ | 1256 int mindepth; /* Lowest DEPTH value seen. */ |
1257 int start_quoted = 0; /* Nonzero means starting after a char quote */ | 1257 int start_quoted = 0; /* Nonzero means starting after a char quote */ |
1258 Lisp_Object tem; | 1258 Lisp_Object tem; |
1259 int mask; /* comment mask */ | 1259 int mask; /* comment mask */ |
1260 Lisp_Object syntaxtab = buf->syntax_table; | 1260 Lisp_Object syntaxtab = buf->syntax_table; |
1261 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); | 1261 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); |
1262 | 1262 |
1263 if (NILP (oldstate)) | 1263 if (NILP (oldstate)) |
1264 { | 1264 { |
1265 depth = 0; | 1265 depth = 0; |
1266 state.instring = -1; | 1266 state.instring = -1; |
1609 put_char_table (XCHAR_TABLE (closure->mirrortab), range, val); | 1609 put_char_table (XCHAR_TABLE (closure->mirrortab), range, val); |
1610 return 0; | 1610 return 0; |
1611 } | 1611 } |
1612 | 1612 |
1613 static void | 1613 static void |
1614 update_just_this_syntax_table (struct Lisp_Char_Table *ct) | 1614 update_just_this_syntax_table (Lisp_Char_Table *ct) |
1615 { | 1615 { |
1616 struct chartab_range range; | 1616 struct chartab_range range; |
1617 struct cmst_arg arg; | 1617 struct cmst_arg arg; |
1618 | 1618 |
1619 arg.mirrortab = ct->mirror_table; | 1619 arg.mirrortab = ct->mirror_table; |
1627 If this is the standard syntax table, we need to recompute | 1627 If this is the standard syntax table, we need to recompute |
1628 *all* syntax tables (yuck). Otherwise we just recompute this | 1628 *all* syntax tables (yuck). Otherwise we just recompute this |
1629 one. */ | 1629 one. */ |
1630 | 1630 |
1631 void | 1631 void |
1632 update_syntax_table (struct Lisp_Char_Table *ct) | 1632 update_syntax_table (Lisp_Char_Table *ct) |
1633 { | 1633 { |
1634 /* Don't be stymied at startup. */ | 1634 /* Don't be stymied at startup. */ |
1635 if (CHAR_TABLEP (Vstandard_syntax_table) | 1635 if (CHAR_TABLEP (Vstandard_syntax_table) |
1636 && ct == XCHAR_TABLE (Vstandard_syntax_table)) | 1636 && ct == XCHAR_TABLE (Vstandard_syntax_table)) |
1637 { | 1637 { |