Mercurial > emacs
comparison src/syntax.c @ 110551:f28cc7ff91f9
Fix int/EMACS_INT use in casefiddle.c and syntax.c.
syntax.c (scan_words, update_syntax_table)
(prev_char_comend_first, back_comment, skip_chars)
(skip_syntaxes, Fforward_comment, Fbackward_prefix_chars): Use
EMACS_INT for buffer and string positions.
syntax.h (scan_words, update_syntax_table): Adjust prototypes.
casefiddle.c (operate_on_word): Use EMACS_INT for buffer
positions.
| author | Eli Zaretskii <eliz@gnu.org> |
|---|---|
| date | Fri, 24 Sep 2010 11:24:47 -0400 |
| parents | b799d38f522a |
| children | 8bd4a845ba2a |
comparison
equal
deleted
inserted
replaced
| 110550:d33e6623664c | 110551:f28cc7ff91f9 |
|---|---|
| 183 NULL_INTERVAL. We also update lim_property to be the next value of | 183 NULL_INTERVAL. We also update lim_property to be the next value of |
| 184 charpos to call this subroutine again - or be before/after the | 184 charpos to call this subroutine again - or be before/after the |
| 185 start/end of OBJECT. */ | 185 start/end of OBJECT. */ |
| 186 | 186 |
| 187 void | 187 void |
| 188 update_syntax_table (int charpos, int count, int init, Lisp_Object object) | 188 update_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; |
| 192 INTERVAL i; | 193 INTERVAL i; |
| 193 | 194 |
| 473 } | 474 } |
| 474 | 475 |
| 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 |
| 477 static int | 478 static int |
| 478 prev_char_comend_first (int pos, int pos_byte) | 479 prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte) |
| 479 { | 480 { |
| 480 int c, val; | 481 int c, val; |
| 481 | 482 |
| 482 DEC_BOTH (pos, pos_byte); | 483 DEC_BOTH (pos, pos_byte); |
| 483 UPDATE_SYNTAX_TABLE_BACKWARD (pos); | 484 UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
| 555 | 556 |
| 556 /* At beginning of range to scan, we're outside of strings; | 557 /* At beginning of range to scan, we're outside of strings; |
| 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; |
| 562 int comstart; | 563 int comstart; |
| 563 | 564 |
| 564 /* Move back and examine a character. */ | 565 /* Move back and examine a character. */ |
| 565 DEC_BOTH (from, from_byte); | 566 DEC_BOTH (from, from_byte); |
| 566 UPDATE_SYNTAX_TABLE_BACKWARD (from); | 567 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 593 /* If a 2-char comment sequence partly overlaps with another, | 594 /* If a 2-char comment sequence partly overlaps with another, |
| 594 we don't try to be clever. E.g. |*| in C, or }% in modes that | 595 we don't try to be clever. E.g. |*| in C, or }% in modes that |
| 595 have %..\n and %{..}%. */ | 596 have %..\n and %{..}%. */ |
| 596 if (from > stop && (com2end || comstart)) | 597 if (from > stop && (com2end || comstart)) |
| 597 { | 598 { |
| 598 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; | |
| 599 DEC_BOTH (next, next_byte); | 601 DEC_BOTH (next, next_byte); |
| 600 UPDATE_SYNTAX_TABLE_BACKWARD (next); | 602 UPDATE_SYNTAX_TABLE_BACKWARD (next); |
| 601 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); | 603 next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); |
| 602 next_syntax = SYNTAX_WITH_FLAGS (next_c); | 604 next_syntax = SYNTAX_WITH_FLAGS (next_c); |
| 603 if (((comstart || comnested) | 605 if (((comstart || comnested) |
| 1240 | 1242 |
| 1241 /* Return the position across COUNT words from FROM. | 1243 /* Return the position across COUNT words from FROM. |
| 1242 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. |
| 1243 COUNT negative means scan backward and stop at word beginning. */ | 1245 COUNT negative means scan backward and stop at word beginning. */ |
| 1244 | 1246 |
| 1245 int | 1247 EMACS_INT |
| 1246 scan_words (register int from, register int count) | 1248 scan_words (register EMACS_INT from, register EMACS_INT count) |
| 1247 { | 1249 { |
| 1248 register int beg = BEGV; | 1250 register EMACS_INT beg = BEGV; |
| 1249 register int end = ZV; | 1251 register EMACS_INT end = ZV; |
| 1250 register int from_byte = CHAR_TO_BYTE (from); | 1252 register EMACS_INT from_byte = CHAR_TO_BYTE (from); |
| 1251 register enum syntaxcode code; | 1253 register enum syntaxcode code; |
| 1252 int ch0, ch1; | 1254 int ch0, ch1; |
| 1253 Lisp_Object func, script, pos; | 1255 Lisp_Object func, script, pos; |
| 1254 | 1256 |
| 1255 immediate_quit = 1; | 1257 immediate_quit = 1; |
| 1453 unsigned char fastmap[0400]; | 1455 unsigned char fastmap[0400]; |
| 1454 /* Store the ranges of non-ASCII characters. */ | 1456 /* Store the ranges of non-ASCII characters. */ |
| 1455 int *char_ranges; | 1457 int *char_ranges; |
| 1456 int n_char_ranges = 0; | 1458 int n_char_ranges = 0; |
| 1457 int negate = 0; | 1459 int negate = 0; |
| 1458 register int i, i_byte; | 1460 register EMACS_INT i, i_byte; |
| 1459 /* 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 |
| 1460 contains non-ASCII chars. */ | 1462 contains non-ASCII chars. */ |
| 1461 int multibyte; | 1463 int multibyte; |
| 1462 /* 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 |
| 1463 chars. */ | 1465 chars. */ |
| 1464 int string_multibyte; | 1466 int string_multibyte; |
| 1465 int size_byte; | 1467 EMACS_INT size_byte; |
| 1466 const unsigned char *str; | 1468 const unsigned char *str; |
| 1467 int len; | 1469 int len; |
| 1468 Lisp_Object iso_classes; | 1470 Lisp_Object iso_classes; |
| 1469 | 1471 |
| 1470 CHECK_STRING (string); | 1472 CHECK_STRING (string); |
| 1772 fastmap[i] = 1; | 1774 fastmap[i] = 1; |
| 1773 } | 1775 } |
| 1774 } | 1776 } |
| 1775 | 1777 |
| 1776 { | 1778 { |
| 1777 int start_point = PT; | 1779 EMACS_INT start_point = PT; |
| 1778 int pos = PT; | 1780 EMACS_INT pos = PT; |
| 1779 int pos_byte = PT_BYTE; | 1781 EMACS_INT pos_byte = PT_BYTE; |
| 1780 unsigned char *p = PT_ADDR, *endp, *stop; | 1782 unsigned char *p = PT_ADDR, *endp, *stop; |
| 1781 | 1783 |
| 1782 if (forwardp) | 1784 if (forwardp) |
| 1783 { | 1785 { |
| 1784 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); | 1786 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); |
| 1944 skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | 1946 skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) |
| 1945 { | 1947 { |
| 1946 register unsigned int c; | 1948 register unsigned int c; |
| 1947 unsigned char fastmap[0400]; | 1949 unsigned char fastmap[0400]; |
| 1948 int negate = 0; | 1950 int negate = 0; |
| 1949 register int i, i_byte; | 1951 register EMACS_INT i, i_byte; |
| 1950 int multibyte; | 1952 int multibyte; |
| 1951 int size_byte; | 1953 EMACS_INT size_byte; |
| 1952 unsigned char *str; | 1954 unsigned char *str; |
| 1953 | 1955 |
| 1954 CHECK_STRING (string); | 1956 CHECK_STRING (string); |
| 1955 | 1957 |
| 1956 if (NILP (lim)) | 1958 if (NILP (lim)) |
| 1999 if (negate) | 2001 if (negate) |
| 2000 for (i = 0; i < sizeof fastmap; i++) | 2002 for (i = 0; i < sizeof fastmap; i++) |
| 2001 fastmap[i] ^= 1; | 2003 fastmap[i] ^= 1; |
| 2002 | 2004 |
| 2003 { | 2005 { |
| 2004 int start_point = PT; | 2006 EMACS_INT start_point = PT; |
| 2005 int pos = PT; | 2007 EMACS_INT pos = PT; |
| 2006 int pos_byte = PT_BYTE; | 2008 EMACS_INT pos_byte = PT_BYTE; |
| 2007 unsigned char *p = PT_ADDR, *endp, *stop; | 2009 unsigned char *p = PT_ADDR, *endp, *stop; |
| 2008 | 2010 |
| 2009 if (forwardp) | 2011 if (forwardp) |
| 2010 { | 2012 { |
| 2011 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); | 2013 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); |
| 2392 } | 2394 } |
| 2393 | 2395 |
| 2394 if (code == Scomment_fence) | 2396 if (code == Scomment_fence) |
| 2395 { | 2397 { |
| 2396 /* Skip until first preceding unquoted comment_fence. */ | 2398 /* Skip until first preceding unquoted comment_fence. */ |
| 2397 int found = 0, ini = from, ini_byte = from_byte; | 2399 int found = 0; |
| 2400 EMACS_INT ini = from, ini_byte = from_byte; | |
| 2398 | 2401 |
| 2399 while (1) | 2402 while (1) |
| 2400 { | 2403 { |
| 2401 DEC_BOTH (from, from_byte); | 2404 DEC_BOTH (from, from_byte); |
| 2402 UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2405 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2908 0, 0, 0, | 2911 0, 0, 0, |
| 2909 doc: /* Move point backward over any number of chars with prefix syntax. | 2912 doc: /* Move point backward over any number of chars with prefix syntax. |
| 2910 This includes chars with "quote" or "prefix" syntax (' or p). */) | 2913 This includes chars with "quote" or "prefix" syntax (' or p). */) |
| 2911 (void) | 2914 (void) |
| 2912 { | 2915 { |
| 2913 int beg = BEGV; | 2916 EMACS_INT beg = BEGV; |
| 2914 int opoint = PT; | 2917 EMACS_INT opoint = PT; |
| 2915 int opoint_byte = PT_BYTE; | 2918 EMACS_INT opoint_byte = PT_BYTE; |
| 2916 int pos = PT; | 2919 EMACS_INT pos = PT; |
| 2917 int pos_byte = PT_BYTE; | 2920 EMACS_INT pos_byte = PT_BYTE; |
| 2918 int c; | 2921 int c; |
| 2919 | 2922 |
| 2920 if (pos <= beg) | 2923 if (pos <= beg) |
| 2921 { | 2924 { |
| 2922 SET_PT_BOTH (opoint, opoint_byte); | 2925 SET_PT_BOTH (opoint, opoint_byte); |
