aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/syntax.c b/src/syntax.c
index f0a7dca42dc..2f4f5236a40 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -185,7 +185,8 @@ INTERVAL interval_of (int, Lisp_Object);
185 start/end of OBJECT. */ 185 start/end of OBJECT. */
186 186
187void 187void
188update_syntax_table (int charpos, int count, int init, Lisp_Object object) 188update_syntax_table (EMACS_INT charpos, int count, int init,
189 Lisp_Object object)
189{ 190{
190 Lisp_Object tmp_table; 191 Lisp_Object tmp_table;
191 int cnt = 0, invalidate = 1; 192 int cnt = 0, invalidate = 1;
@@ -475,7 +476,7 @@ find_defun_start (EMACS_INT pos, EMACS_INT pos_byte)
475/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ 476/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */
476 477
477static int 478static int
478prev_char_comend_first (int pos, int pos_byte) 479prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte)
479{ 480{
480 int c, val; 481 int c, val;
481 482
@@ -557,8 +558,9 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested
557 that determines quote parity to the comment-end. */ 558 that determines quote parity to the comment-end. */
558 while (from != stop) 559 while (from != stop)
559 { 560 {
560 int temp_byte, prev_syntax; 561 EMACS_INT temp_byte;
561 int com2start, com2end; 562 int prev_syntax, com2start, com2end;
563 int comstart;
562 564
563 /* Move back and examine a character. */ 565 /* Move back and examine a character. */
564 DEC_BOTH (from, from_byte); 566 DEC_BOTH (from, from_byte);
@@ -578,7 +580,8 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested
578 || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); 580 || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested);
579 com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) 581 com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax)
580 && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax)); 582 && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax));
581 583 comstart = (com2start || code == Scomment);
584
582 /* Nasty cases with overlapping 2-char comment markers: 585 /* Nasty cases with overlapping 2-char comment markers:
583 - snmp-mode: -- c -- foo -- c -- 586 - snmp-mode: -- c -- foo -- c --
584 --- c -- 587 --- c --
@@ -589,15 +592,17 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested
589 /// */ 592 /// */
590 593
591 /* If a 2-char comment sequence partly overlaps with another, 594 /* If a 2-char comment sequence partly overlaps with another,
592 we don't try to be clever. */ 595 we don't try to be clever. E.g. |*| in C, or }% in modes that
593 if (from > stop && (com2end || com2start)) 596 have %..\n and %{..}%. */
597 if (from > stop && (com2end || comstart))
594 { 598 {
595 int next = from, next_byte = from_byte, next_c, next_syntax; 599 EMACS_INT next = from, next_byte = from_byte;
600 int next_c, next_syntax;
596 DEC_BOTH (next, next_byte); 601 DEC_BOTH (next, next_byte);
597 UPDATE_SYNTAX_TABLE_BACKWARD (next); 602 UPDATE_SYNTAX_TABLE_BACKWARD (next);
598 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); 603 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte);
599 next_syntax = SYNTAX_WITH_FLAGS (next_c); 604 next_syntax = SYNTAX_WITH_FLAGS (next_c);
600 if (((com2start || comnested) 605 if (((comstart || comnested)
601 && SYNTAX_FLAGS_COMEND_SECOND (syntax) 606 && SYNTAX_FLAGS_COMEND_SECOND (syntax)
602 && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) 607 && SYNTAX_FLAGS_COMEND_FIRST (next_syntax))
603 || ((com2end || comnested) 608 || ((com2end || comnested)
@@ -1239,12 +1244,12 @@ Lisp_Object Vfind_word_boundary_function_table;
1239 If that many words cannot be found before the end of the buffer, return 0. 1244 If that many words cannot be found before the end of the buffer, return 0.
1240 COUNT negative means scan backward and stop at word beginning. */ 1245 COUNT negative means scan backward and stop at word beginning. */
1241 1246
1242int 1247EMACS_INT
1243scan_words (register int from, register int count) 1248scan_words (register EMACS_INT from, register EMACS_INT count)
1244{ 1249{
1245 register int beg = BEGV; 1250 register EMACS_INT beg = BEGV;
1246 register int end = ZV; 1251 register EMACS_INT end = ZV;
1247 register int from_byte = CHAR_TO_BYTE (from); 1252 register EMACS_INT from_byte = CHAR_TO_BYTE (from);
1248 register enum syntaxcode code; 1253 register enum syntaxcode code;
1249 int ch0, ch1; 1254 int ch0, ch1;
1250 Lisp_Object func, script, pos; 1255 Lisp_Object func, script, pos;
@@ -1452,14 +1457,14 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
1452 int *char_ranges; 1457 int *char_ranges;
1453 int n_char_ranges = 0; 1458 int n_char_ranges = 0;
1454 int negate = 0; 1459 int negate = 0;
1455 register int i, i_byte; 1460 register EMACS_INT i, i_byte;
1456 /* Set to 1 if the current buffer is multibyte and the region 1461 /* Set to 1 if the current buffer is multibyte and the region
1457 contains non-ASCII chars. */ 1462 contains non-ASCII chars. */
1458 int multibyte; 1463 int multibyte;
1459 /* Set to 1 if STRING is multibyte and it contains non-ASCII 1464 /* Set to 1 if STRING is multibyte and it contains non-ASCII
1460 chars. */ 1465 chars. */
1461 int string_multibyte; 1466 int string_multibyte;
1462 int size_byte; 1467 EMACS_INT size_byte;
1463 const unsigned char *str; 1468 const unsigned char *str;
1464 int len; 1469 int len;
1465 Lisp_Object iso_classes; 1470 Lisp_Object iso_classes;
@@ -1771,9 +1776,9 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl
1771 } 1776 }
1772 1777
1773 { 1778 {
1774 int start_point = PT; 1779 EMACS_INT start_point = PT;
1775 int pos = PT; 1780 EMACS_INT pos = PT;
1776 int pos_byte = PT_BYTE; 1781 EMACS_INT pos_byte = PT_BYTE;
1777 unsigned char *p = PT_ADDR, *endp, *stop; 1782 unsigned char *p = PT_ADDR, *endp, *stop;
1778 1783
1779 if (forwardp) 1784 if (forwardp)
@@ -1943,9 +1948,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim)
1943 register unsigned int c; 1948 register unsigned int c;
1944 unsigned char fastmap[0400]; 1949 unsigned char fastmap[0400];
1945 int negate = 0; 1950 int negate = 0;
1946 register int i, i_byte; 1951 register EMACS_INT i, i_byte;
1947 int multibyte; 1952 int multibyte;
1948 int size_byte; 1953 EMACS_INT size_byte;
1949 unsigned char *str; 1954 unsigned char *str;
1950 1955
1951 CHECK_STRING (string); 1956 CHECK_STRING (string);
@@ -1998,9 +2003,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim)
1998 fastmap[i] ^= 1; 2003 fastmap[i] ^= 1;
1999 2004
2000 { 2005 {
2001 int start_point = PT; 2006 EMACS_INT start_point = PT;
2002 int pos = PT; 2007 EMACS_INT pos = PT;
2003 int pos_byte = PT_BYTE; 2008 EMACS_INT pos_byte = PT_BYTE;
2004 unsigned char *p = PT_ADDR, *endp, *stop; 2009 unsigned char *p = PT_ADDR, *endp, *stop;
2005 2010
2006 if (forwardp) 2011 if (forwardp)
@@ -2391,7 +2396,8 @@ between them, return t; otherwise return nil. */)
2391 if (code == Scomment_fence) 2396 if (code == Scomment_fence)
2392 { 2397 {
2393 /* Skip until first preceding unquoted comment_fence. */ 2398 /* Skip until first preceding unquoted comment_fence. */
2394 int found = 0, ini = from, ini_byte = from_byte; 2399 int found = 0;
2400 EMACS_INT ini = from, ini_byte = from_byte;
2395 2401
2396 while (1) 2402 while (1)
2397 { 2403 {
@@ -2907,11 +2913,11 @@ DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
2907This includes chars with "quote" or "prefix" syntax (' or p). */) 2913This includes chars with "quote" or "prefix" syntax (' or p). */)
2908 (void) 2914 (void)
2909{ 2915{
2910 int beg = BEGV; 2916 EMACS_INT beg = BEGV;
2911 int opoint = PT; 2917 EMACS_INT opoint = PT;
2912 int opoint_byte = PT_BYTE; 2918 EMACS_INT opoint_byte = PT_BYTE;
2913 int pos = PT; 2919 EMACS_INT pos = PT;
2914 int pos_byte = PT_BYTE; 2920 EMACS_INT pos_byte = PT_BYTE;
2915 int c; 2921 int c;
2916 2922
2917 if (pos <= beg) 2923 if (pos <= beg)