diff options
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 192 |
1 files changed, 98 insertions, 94 deletions
diff --git a/src/syntax.c b/src/syntax.c index 3e51099794b..2960a9c96a0 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -94,8 +94,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 94 | string-ender-char to distinguish comments/strings started by | 94 | string-ender-char to distinguish comments/strings started by |
| 95 | comment_fence and string_fence codes. */ | 95 | comment_fence and string_fence codes. */ |
| 96 | 96 | ||
| 97 | #define ST_COMMENT_STYLE (256 + 1) | 97 | #define ST_COMMENT_STYLE (SYNTAX_FLAGS_COMMENT_STYLE (~0, ~0) + 1) |
| 98 | #define ST_STRING_STYLE (256 + 2) | 98 | #define ST_STRING_STYLE (MAX_CHAR + 1) |
| 99 | 99 | ||
| 100 | static Lisp_Object Qsyntax_table_p; | 100 | static Lisp_Object Qsyntax_table_p; |
| 101 | static Lisp_Object Qsyntax_table, Qscan_error; | 101 | static Lisp_Object Qsyntax_table, Qscan_error; |
| @@ -111,18 +111,18 @@ Lisp_Object syntax_temp; | |||
| 111 | 111 | ||
| 112 | struct lisp_parse_state | 112 | struct lisp_parse_state |
| 113 | { | 113 | { |
| 114 | int depth; /* Depth at end of parsing. */ | 114 | EMACS_INT depth; /* Depth at end of parsing. */ |
| 115 | int instring; /* -1 if not within string, else desired terminator. */ | 115 | int instring; /* -1 if not within string, else desired terminator. */ |
| 116 | int incomment; /* -1 if in unnestable comment else comment nesting */ | 116 | EMACS_INT incomment; /* -1 if in unnestable comment else comment nesting */ |
| 117 | int comstyle; /* comment style a=0, or b=1, or ST_COMMENT_STYLE. */ | 117 | int comstyle; /* comment style a=0, or b=1, or ST_COMMENT_STYLE. */ |
| 118 | int quoted; /* Nonzero if just after an escape char at end of parsing */ | 118 | int quoted; /* Nonzero if just after an escape char at end of parsing */ |
| 119 | int mindepth; /* Minimum depth seen while scanning. */ | 119 | EMACS_INT mindepth; /* Minimum depth seen while scanning. */ |
| 120 | /* Char number of most recent start-of-expression at current level */ | 120 | /* Char number of most recent start-of-expression at current level */ |
| 121 | EMACS_INT thislevelstart; | 121 | ptrdiff_t thislevelstart; |
| 122 | /* Char number of start of containing expression */ | 122 | /* Char number of start of containing expression */ |
| 123 | EMACS_INT prevlevelstart; | 123 | ptrdiff_t prevlevelstart; |
| 124 | EMACS_INT location; /* Char number at which parsing stopped. */ | 124 | ptrdiff_t location; /* Char number at which parsing stopped. */ |
| 125 | EMACS_INT comstr_start; /* Position of last comment/string starter. */ | 125 | ptrdiff_t comstr_start; /* Position of last comment/string starter. */ |
| 126 | Lisp_Object levelstarts; /* Char numbers of starts-of-expression | 126 | Lisp_Object levelstarts; /* Char numbers of starts-of-expression |
| 127 | of levels (starting from outermost). */ | 127 | of levels (starting from outermost). */ |
| 128 | }; | 128 | }; |
| @@ -135,12 +135,12 @@ struct lisp_parse_state | |||
| 135 | find_start_begv is the BEGV value when it was found. | 135 | find_start_begv is the BEGV value when it was found. |
| 136 | find_start_modiff is the value of MODIFF when it was found. */ | 136 | find_start_modiff is the value of MODIFF when it was found. */ |
| 137 | 137 | ||
| 138 | static EMACS_INT find_start_pos; | 138 | static ptrdiff_t find_start_pos; |
| 139 | static EMACS_INT find_start_value; | 139 | static ptrdiff_t find_start_value; |
| 140 | static EMACS_INT find_start_value_byte; | 140 | static ptrdiff_t find_start_value_byte; |
| 141 | static struct buffer *find_start_buffer; | 141 | static struct buffer *find_start_buffer; |
| 142 | static EMACS_INT find_start_begv; | 142 | static ptrdiff_t find_start_begv; |
| 143 | static int find_start_modiff; | 143 | static EMACS_INT find_start_modiff; |
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | static Lisp_Object Fsyntax_table_p (Lisp_Object); | 146 | static Lisp_Object Fsyntax_table_p (Lisp_Object); |
| @@ -148,7 +148,7 @@ static Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); | |||
| 148 | static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object); | 148 | static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object); |
| 149 | static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int); | 149 | static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int); |
| 150 | static void scan_sexps_forward (struct lisp_parse_state *, | 150 | static void scan_sexps_forward (struct lisp_parse_state *, |
| 151 | EMACS_INT, EMACS_INT, EMACS_INT, int, | 151 | ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT, |
| 152 | int, Lisp_Object, int); | 152 | int, Lisp_Object, int); |
| 153 | static int in_classes (int, Lisp_Object); | 153 | static int in_classes (int, Lisp_Object); |
| 154 | 154 | ||
| @@ -177,7 +177,7 @@ struct gl_state_s gl_state; /* Global state of syntax parser. */ | |||
| 177 | start/end of OBJECT. */ | 177 | start/end of OBJECT. */ |
| 178 | 178 | ||
| 179 | void | 179 | void |
| 180 | update_syntax_table (EMACS_INT charpos, EMACS_INT count, int init, | 180 | update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init, |
| 181 | Lisp_Object object) | 181 | Lisp_Object object) |
| 182 | { | 182 | { |
| 183 | Lisp_Object tmp_table; | 183 | Lisp_Object tmp_table; |
| @@ -339,12 +339,12 @@ update_syntax_table (EMACS_INT charpos, EMACS_INT count, int init, | |||
| 339 | or after. On return global syntax data is good for lookup at CHARPOS. */ | 339 | or after. On return global syntax data is good for lookup at CHARPOS. */ |
| 340 | 340 | ||
| 341 | static int | 341 | static int |
| 342 | char_quoted (EMACS_INT charpos, EMACS_INT bytepos) | 342 | char_quoted (ptrdiff_t charpos, ptrdiff_t bytepos) |
| 343 | { | 343 | { |
| 344 | register enum syntaxcode code; | 344 | register enum syntaxcode code; |
| 345 | register EMACS_INT beg = BEGV; | 345 | register ptrdiff_t beg = BEGV; |
| 346 | register int quoted = 0; | 346 | register int quoted = 0; |
| 347 | EMACS_INT orig = charpos; | 347 | ptrdiff_t orig = charpos; |
| 348 | 348 | ||
| 349 | while (charpos > beg) | 349 | while (charpos > beg) |
| 350 | { | 350 | { |
| @@ -367,8 +367,8 @@ char_quoted (EMACS_INT charpos, EMACS_INT bytepos) | |||
| 367 | /* Return the bytepos one character before BYTEPOS. | 367 | /* Return the bytepos one character before BYTEPOS. |
| 368 | We assume that BYTEPOS is not at the start of the buffer. */ | 368 | We assume that BYTEPOS is not at the start of the buffer. */ |
| 369 | 369 | ||
| 370 | static inline EMACS_INT | 370 | static inline ptrdiff_t |
| 371 | dec_bytepos (EMACS_INT bytepos) | 371 | dec_bytepos (ptrdiff_t bytepos) |
| 372 | { | 372 | { |
| 373 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) | 373 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) |
| 374 | return bytepos - 1; | 374 | return bytepos - 1; |
| @@ -391,10 +391,10 @@ dec_bytepos (EMACS_INT bytepos) | |||
| 391 | valid on return from the subroutine, so the caller should explicitly | 391 | valid on return from the subroutine, so the caller should explicitly |
| 392 | update the global data. */ | 392 | update the global data. */ |
| 393 | 393 | ||
| 394 | static EMACS_INT | 394 | static ptrdiff_t |
| 395 | find_defun_start (EMACS_INT pos, EMACS_INT pos_byte) | 395 | find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) |
| 396 | { | 396 | { |
| 397 | EMACS_INT opoint = PT, opoint_byte = PT_BYTE; | 397 | ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; |
| 398 | 398 | ||
| 399 | if (!open_paren_in_column_0_is_defun_start) | 399 | if (!open_paren_in_column_0_is_defun_start) |
| 400 | { | 400 | { |
| @@ -461,7 +461,7 @@ find_defun_start (EMACS_INT pos, EMACS_INT pos_byte) | |||
| 461 | /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ | 461 | /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ |
| 462 | 462 | ||
| 463 | static int | 463 | static int |
| 464 | prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte) | 464 | prev_char_comend_first (ptrdiff_t pos, ptrdiff_t pos_byte) |
| 465 | { | 465 | { |
| 466 | int c, val; | 466 | int c, val; |
| 467 | 467 | ||
| @@ -503,7 +503,7 @@ prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte) | |||
| 503 | the returned value (or at FROM, if the search was not successful). */ | 503 | the returned value (or at FROM, if the search was not successful). */ |
| 504 | 504 | ||
| 505 | static int | 505 | static int |
| 506 | back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested, int comstyle, EMACS_INT *charpos_ptr, EMACS_INT *bytepos_ptr) | 506 | back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, int comnested, int comstyle, ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr) |
| 507 | { | 507 | { |
| 508 | /* Look back, counting the parity of string-quotes, | 508 | /* Look back, counting the parity of string-quotes, |
| 509 | and recording the comment-starters seen. | 509 | and recording the comment-starters seen. |
| @@ -522,14 +522,14 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 522 | inside another comment). | 522 | inside another comment). |
| 523 | Test case: { a (* b } c (* d *) */ | 523 | Test case: { a (* b } c (* d *) */ |
| 524 | int comment_lossage = 0; | 524 | int comment_lossage = 0; |
| 525 | EMACS_INT comment_end = from; | 525 | ptrdiff_t comment_end = from; |
| 526 | EMACS_INT comment_end_byte = from_byte; | 526 | ptrdiff_t comment_end_byte = from_byte; |
| 527 | EMACS_INT comstart_pos = 0; | 527 | ptrdiff_t comstart_pos = 0; |
| 528 | EMACS_INT comstart_byte IF_LINT (= 0); | 528 | ptrdiff_t comstart_byte IF_LINT (= 0); |
| 529 | /* Place where the containing defun starts, | 529 | /* Place where the containing defun starts, |
| 530 | or 0 if we didn't come across it yet. */ | 530 | or 0 if we didn't come across it yet. */ |
| 531 | EMACS_INT defun_start = 0; | 531 | ptrdiff_t defun_start = 0; |
| 532 | EMACS_INT defun_start_byte = 0; | 532 | ptrdiff_t defun_start_byte = 0; |
| 533 | register enum syntaxcode code; | 533 | register enum syntaxcode code; |
| 534 | int nesting = 1; /* current comment nesting */ | 534 | int nesting = 1; /* current comment nesting */ |
| 535 | int c; | 535 | int c; |
| @@ -543,7 +543,7 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 543 | that determines quote parity to the comment-end. */ | 543 | that determines quote parity to the comment-end. */ |
| 544 | while (from != stop) | 544 | while (from != stop) |
| 545 | { | 545 | { |
| 546 | EMACS_INT temp_byte; | 546 | ptrdiff_t temp_byte; |
| 547 | int prev_syntax, com2start, com2end; | 547 | int prev_syntax, com2start, com2end; |
| 548 | int comstart; | 548 | int comstart; |
| 549 | 549 | ||
| @@ -581,7 +581,7 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 581 | have %..\n and %{..}%. */ | 581 | have %..\n and %{..}%. */ |
| 582 | if (from > stop && (com2end || comstart)) | 582 | if (from > stop && (com2end || comstart)) |
| 583 | { | 583 | { |
| 584 | EMACS_INT next = from, next_byte = from_byte; | 584 | ptrdiff_t next = from, next_byte = from_byte; |
| 585 | int next_c, next_syntax; | 585 | int next_c, next_syntax; |
| 586 | DEC_BOTH (next, next_byte); | 586 | DEC_BOTH (next, next_byte); |
| 587 | UPDATE_SYNTAX_TABLE_BACKWARD (next); | 587 | UPDATE_SYNTAX_TABLE_BACKWARD (next); |
| @@ -737,7 +737,8 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 737 | { | 737 | { |
| 738 | scan_sexps_forward (&state, | 738 | scan_sexps_forward (&state, |
| 739 | defun_start, defun_start_byte, | 739 | defun_start, defun_start_byte, |
| 740 | comment_end, -10000, 0, Qnil, 0); | 740 | comment_end, TYPE_MINIMUM (EMACS_INT), |
| 741 | 0, Qnil, 0); | ||
| 741 | defun_start = comment_end; | 742 | defun_start = comment_end; |
| 742 | if (state.incomment == (comnested ? 1 : -1) | 743 | if (state.incomment == (comnested ? 1 : -1) |
| 743 | && state.comstyle == comstyle) | 744 | && state.comstyle == comstyle) |
| @@ -1099,13 +1100,13 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1099 | first = XCAR (value); | 1100 | first = XCAR (value); |
| 1100 | match_lisp = XCDR (value); | 1101 | match_lisp = XCDR (value); |
| 1101 | 1102 | ||
| 1102 | if (!INTEGERP (first) || !(NILP (match_lisp) || INTEGERP (match_lisp))) | 1103 | if (!INTEGERP (first) || !(NILP (match_lisp) || CHARACTERP (match_lisp))) |
| 1103 | { | 1104 | { |
| 1104 | insert_string ("invalid"); | 1105 | insert_string ("invalid"); |
| 1105 | return syntax; | 1106 | return syntax; |
| 1106 | } | 1107 | } |
| 1107 | 1108 | ||
| 1108 | syntax_code = XINT (first); | 1109 | syntax_code = XINT (first) & INT_MAX; |
| 1109 | code = (enum syntaxcode) (syntax_code & 0377); | 1110 | code = (enum syntaxcode) (syntax_code & 0377); |
| 1110 | start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); | 1111 | start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); |
| 1111 | start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; | 1112 | start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; |
| @@ -1223,12 +1224,12 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1223 | If that many words cannot be found before the end of the buffer, return 0. | 1224 | If that many words cannot be found before the end of the buffer, return 0. |
| 1224 | COUNT negative means scan backward and stop at word beginning. */ | 1225 | COUNT negative means scan backward and stop at word beginning. */ |
| 1225 | 1226 | ||
| 1226 | EMACS_INT | 1227 | ptrdiff_t |
| 1227 | scan_words (register EMACS_INT from, register EMACS_INT count) | 1228 | scan_words (register ptrdiff_t from, register EMACS_INT count) |
| 1228 | { | 1229 | { |
| 1229 | register EMACS_INT beg = BEGV; | 1230 | register ptrdiff_t beg = BEGV; |
| 1230 | register EMACS_INT end = ZV; | 1231 | register ptrdiff_t end = ZV; |
| 1231 | register EMACS_INT from_byte = CHAR_TO_BYTE (from); | 1232 | register ptrdiff_t from_byte = CHAR_TO_BYTE (from); |
| 1232 | register enum syntaxcode code; | 1233 | register enum syntaxcode code; |
| 1233 | int ch0, ch1; | 1234 | int ch0, ch1; |
| 1234 | Lisp_Object func, pos; | 1235 | Lisp_Object func, pos; |
| @@ -1263,7 +1264,7 @@ scan_words (register EMACS_INT from, register EMACS_INT count) | |||
| 1263 | if (! NILP (Ffboundp (func))) | 1264 | if (! NILP (Ffboundp (func))) |
| 1264 | { | 1265 | { |
| 1265 | pos = call2 (func, make_number (from - 1), make_number (end)); | 1266 | pos = call2 (func, make_number (from - 1), make_number (end)); |
| 1266 | if (INTEGERP (pos) && XINT (pos) > from) | 1267 | if (RANGED_INTEGERP (from + 1, pos, ZV)) |
| 1267 | { | 1268 | { |
| 1268 | from = XINT (pos); | 1269 | from = XINT (pos); |
| 1269 | from_byte = CHAR_TO_BYTE (from); | 1270 | from_byte = CHAR_TO_BYTE (from); |
| @@ -1313,7 +1314,7 @@ scan_words (register EMACS_INT from, register EMACS_INT count) | |||
| 1313 | if (! NILP (Ffboundp (func))) | 1314 | if (! NILP (Ffboundp (func))) |
| 1314 | { | 1315 | { |
| 1315 | pos = call2 (func, make_number (from), make_number (beg)); | 1316 | pos = call2 (func, make_number (from), make_number (beg)); |
| 1316 | if (INTEGERP (pos) && XINT (pos) < from) | 1317 | if (RANGED_INTEGERP (BEGV, pos, from - 1)) |
| 1317 | { | 1318 | { |
| 1318 | from = XINT (pos); | 1319 | from = XINT (pos); |
| 1319 | from_byte = CHAR_TO_BYTE (from); | 1320 | from_byte = CHAR_TO_BYTE (from); |
| @@ -1357,7 +1358,7 @@ and the function returns nil. Field boundaries are not noticed if | |||
| 1357 | (Lisp_Object arg) | 1358 | (Lisp_Object arg) |
| 1358 | { | 1359 | { |
| 1359 | Lisp_Object tmp; | 1360 | Lisp_Object tmp; |
| 1360 | int orig_val, val; | 1361 | ptrdiff_t orig_val, val; |
| 1361 | 1362 | ||
| 1362 | if (NILP (arg)) | 1363 | if (NILP (arg)) |
| 1363 | XSETFASTINT (arg, 1); | 1364 | XSETFASTINT (arg, 1); |
| @@ -1432,14 +1433,14 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1432 | int *char_ranges IF_LINT (= NULL); | 1433 | int *char_ranges IF_LINT (= NULL); |
| 1433 | int n_char_ranges = 0; | 1434 | int n_char_ranges = 0; |
| 1434 | int negate = 0; | 1435 | int negate = 0; |
| 1435 | register EMACS_INT i, i_byte; | 1436 | register ptrdiff_t i, i_byte; |
| 1436 | /* Set to 1 if the current buffer is multibyte and the region | 1437 | /* Set to 1 if the current buffer is multibyte and the region |
| 1437 | contains non-ASCII chars. */ | 1438 | contains non-ASCII chars. */ |
| 1438 | int multibyte; | 1439 | int multibyte; |
| 1439 | /* Set to 1 if STRING is multibyte and it contains non-ASCII | 1440 | /* Set to 1 if STRING is multibyte and it contains non-ASCII |
| 1440 | chars. */ | 1441 | chars. */ |
| 1441 | int string_multibyte; | 1442 | int string_multibyte; |
| 1442 | EMACS_INT size_byte; | 1443 | ptrdiff_t size_byte; |
| 1443 | const unsigned char *str; | 1444 | const unsigned char *str; |
| 1444 | int len; | 1445 | int len; |
| 1445 | Lisp_Object iso_classes; | 1446 | Lisp_Object iso_classes; |
| @@ -1753,9 +1754,9 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1753 | } | 1754 | } |
| 1754 | 1755 | ||
| 1755 | { | 1756 | { |
| 1756 | EMACS_INT start_point = PT; | 1757 | ptrdiff_t start_point = PT; |
| 1757 | EMACS_INT pos = PT; | 1758 | ptrdiff_t pos = PT; |
| 1758 | EMACS_INT pos_byte = PT_BYTE; | 1759 | ptrdiff_t pos_byte = PT_BYTE; |
| 1759 | unsigned char *p = PT_ADDR, *endp, *stop; | 1760 | unsigned char *p = PT_ADDR, *endp, *stop; |
| 1760 | 1761 | ||
| 1761 | if (forwardp) | 1762 | if (forwardp) |
| @@ -1925,9 +1926,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 1925 | register unsigned int c; | 1926 | register unsigned int c; |
| 1926 | unsigned char fastmap[0400]; | 1927 | unsigned char fastmap[0400]; |
| 1927 | int negate = 0; | 1928 | int negate = 0; |
| 1928 | register EMACS_INT i, i_byte; | 1929 | register ptrdiff_t i, i_byte; |
| 1929 | int multibyte; | 1930 | int multibyte; |
| 1930 | EMACS_INT size_byte; | 1931 | ptrdiff_t size_byte; |
| 1931 | unsigned char *str; | 1932 | unsigned char *str; |
| 1932 | 1933 | ||
| 1933 | CHECK_STRING (string); | 1934 | CHECK_STRING (string); |
| @@ -1980,9 +1981,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 1980 | fastmap[i] ^= 1; | 1981 | fastmap[i] ^= 1; |
| 1981 | 1982 | ||
| 1982 | { | 1983 | { |
| 1983 | EMACS_INT start_point = PT; | 1984 | ptrdiff_t start_point = PT; |
| 1984 | EMACS_INT pos = PT; | 1985 | ptrdiff_t pos = PT; |
| 1985 | EMACS_INT pos_byte = PT_BYTE; | 1986 | ptrdiff_t pos_byte = PT_BYTE; |
| 1986 | unsigned char *p = PT_ADDR, *endp, *stop; | 1987 | unsigned char *p = PT_ADDR, *endp, *stop; |
| 1987 | 1988 | ||
| 1988 | if (forwardp) | 1989 | if (forwardp) |
| @@ -2135,10 +2136,10 @@ in_classes (int c, Lisp_Object iso_classes) | |||
| 2135 | remains valid for forward search starting at the returned position. */ | 2136 | remains valid for forward search starting at the returned position. */ |
| 2136 | 2137 | ||
| 2137 | static int | 2138 | static int |
| 2138 | forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, | 2139 | forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, |
| 2139 | int nesting, int style, int prev_syntax, | 2140 | EMACS_INT nesting, int style, int prev_syntax, |
| 2140 | EMACS_INT *charpos_ptr, EMACS_INT *bytepos_ptr, | 2141 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, |
| 2141 | int *incomment_ptr) | 2142 | EMACS_INT *incomment_ptr) |
| 2142 | { | 2143 | { |
| 2143 | register int c, c1; | 2144 | register int c, c1; |
| 2144 | register enum syntaxcode code; | 2145 | register enum syntaxcode code; |
| @@ -2240,17 +2241,17 @@ If COUNT comments are found as expected, with nothing except whitespace | |||
| 2240 | between them, return t; otherwise return nil. */) | 2241 | between them, return t; otherwise return nil. */) |
| 2241 | (Lisp_Object count) | 2242 | (Lisp_Object count) |
| 2242 | { | 2243 | { |
| 2243 | register EMACS_INT from; | 2244 | register ptrdiff_t from; |
| 2244 | EMACS_INT from_byte; | 2245 | ptrdiff_t from_byte; |
| 2245 | register EMACS_INT stop; | 2246 | register ptrdiff_t stop; |
| 2246 | register int c, c1; | 2247 | register int c, c1; |
| 2247 | register enum syntaxcode code; | 2248 | register enum syntaxcode code; |
| 2248 | int comstyle = 0; /* style of comment encountered */ | 2249 | int comstyle = 0; /* style of comment encountered */ |
| 2249 | int comnested = 0; /* whether the comment is nestable or not */ | 2250 | int comnested = 0; /* whether the comment is nestable or not */ |
| 2250 | int found; | 2251 | int found; |
| 2251 | EMACS_INT count1; | 2252 | EMACS_INT count1; |
| 2252 | EMACS_INT out_charpos, out_bytepos; | 2253 | ptrdiff_t out_charpos, out_bytepos; |
| 2253 | int dummy; | 2254 | ptrdiff_t dummy; |
| 2254 | 2255 | ||
| 2255 | CHECK_NUMBER (count); | 2256 | CHECK_NUMBER (count); |
| 2256 | count1 = XINT (count); | 2257 | count1 = XINT (count); |
| @@ -2374,7 +2375,7 @@ between them, return t; otherwise return nil. */) | |||
| 2374 | { | 2375 | { |
| 2375 | /* Skip until first preceding unquoted comment_fence. */ | 2376 | /* Skip until first preceding unquoted comment_fence. */ |
| 2376 | int fence_found = 0; | 2377 | int fence_found = 0; |
| 2377 | EMACS_INT ini = from, ini_byte = from_byte; | 2378 | ptrdiff_t ini = from, ini_byte = from_byte; |
| 2378 | 2379 | ||
| 2379 | while (1) | 2380 | while (1) |
| 2380 | { | 2381 | { |
| @@ -2457,21 +2458,22 @@ static Lisp_Object | |||
| 2457 | scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpflag) | 2458 | scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpflag) |
| 2458 | { | 2459 | { |
| 2459 | Lisp_Object val; | 2460 | Lisp_Object val; |
| 2460 | register EMACS_INT stop = count > 0 ? ZV : BEGV; | 2461 | register ptrdiff_t stop = count > 0 ? ZV : BEGV; |
| 2461 | register int c, c1; | 2462 | register int c, c1; |
| 2462 | int stringterm; | 2463 | int stringterm; |
| 2463 | int quoted; | 2464 | int quoted; |
| 2464 | int mathexit = 0; | 2465 | int mathexit = 0; |
| 2465 | register enum syntaxcode code, temp_code; | 2466 | register enum syntaxcode code, temp_code; |
| 2466 | int min_depth = depth; /* Err out if depth gets less than this. */ | 2467 | EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */ |
| 2467 | int comstyle = 0; /* style of comment encountered */ | 2468 | int comstyle = 0; /* style of comment encountered */ |
| 2468 | int comnested = 0; /* whether the comment is nestable or not */ | 2469 | int comnested = 0; /* whether the comment is nestable or not */ |
| 2469 | EMACS_INT temp_pos; | 2470 | ptrdiff_t temp_pos; |
| 2470 | EMACS_INT last_good = from; | 2471 | EMACS_INT last_good = from; |
| 2471 | int found; | 2472 | int found; |
| 2472 | EMACS_INT from_byte; | 2473 | ptrdiff_t from_byte; |
| 2473 | EMACS_INT out_bytepos, out_charpos; | 2474 | ptrdiff_t out_bytepos, out_charpos; |
| 2474 | int temp, dummy; | 2475 | int temp; |
| 2476 | ptrdiff_t dummy; | ||
| 2475 | int multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; | 2477 | int multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; |
| 2476 | 2478 | ||
| 2477 | if (depth > 0) min_depth = 0; | 2479 | if (depth > 0) min_depth = 0; |
| @@ -2890,11 +2892,11 @@ DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, | |||
| 2890 | This includes chars with "quote" or "prefix" syntax (' or p). */) | 2892 | This includes chars with "quote" or "prefix" syntax (' or p). */) |
| 2891 | (void) | 2893 | (void) |
| 2892 | { | 2894 | { |
| 2893 | EMACS_INT beg = BEGV; | 2895 | ptrdiff_t beg = BEGV; |
| 2894 | EMACS_INT opoint = PT; | 2896 | ptrdiff_t opoint = PT; |
| 2895 | EMACS_INT opoint_byte = PT_BYTE; | 2897 | ptrdiff_t opoint_byte = PT_BYTE; |
| 2896 | EMACS_INT pos = PT; | 2898 | ptrdiff_t pos = PT; |
| 2897 | EMACS_INT pos_byte = PT_BYTE; | 2899 | ptrdiff_t pos_byte = PT_BYTE; |
| 2898 | int c; | 2900 | int c; |
| 2899 | 2901 | ||
| 2900 | if (pos <= beg) | 2902 | if (pos <= beg) |
| @@ -2935,8 +2937,8 @@ This includes chars with "quote" or "prefix" syntax (' or p). */) | |||
| 2935 | 2937 | ||
| 2936 | static void | 2938 | static void |
| 2937 | scan_sexps_forward (struct lisp_parse_state *stateptr, | 2939 | scan_sexps_forward (struct lisp_parse_state *stateptr, |
| 2938 | EMACS_INT from, EMACS_INT from_byte, EMACS_INT end, | 2940 | ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t end, |
| 2939 | int targetdepth, int stopbefore, | 2941 | EMACS_INT targetdepth, int stopbefore, |
| 2940 | Lisp_Object oldstate, int commentstop) | 2942 | Lisp_Object oldstate, int commentstop) |
| 2941 | { | 2943 | { |
| 2942 | struct lisp_parse_state state; | 2944 | struct lisp_parse_state state; |
| @@ -2944,23 +2946,23 @@ scan_sexps_forward (struct lisp_parse_state *stateptr, | |||
| 2944 | register enum syntaxcode code; | 2946 | register enum syntaxcode code; |
| 2945 | int c1; | 2947 | int c1; |
| 2946 | int comnested; | 2948 | int comnested; |
| 2947 | struct level { int last, prev; }; | 2949 | struct level { ptrdiff_t last, prev; }; |
| 2948 | struct level levelstart[100]; | 2950 | struct level levelstart[100]; |
| 2949 | register struct level *curlevel = levelstart; | 2951 | register struct level *curlevel = levelstart; |
| 2950 | struct level *endlevel = levelstart + 100; | 2952 | struct level *endlevel = levelstart + 100; |
| 2951 | register int depth; /* Paren depth of current scanning location. | 2953 | register EMACS_INT depth; /* Paren depth of current scanning location. |
| 2952 | level - levelstart equals this except | 2954 | level - levelstart equals this except |
| 2953 | when the depth becomes negative. */ | 2955 | when the depth becomes negative. */ |
| 2954 | int mindepth; /* Lowest DEPTH value seen. */ | 2956 | EMACS_INT mindepth; /* Lowest DEPTH value seen. */ |
| 2955 | int start_quoted = 0; /* Nonzero means starting after a char quote */ | 2957 | int start_quoted = 0; /* Nonzero means starting after a char quote */ |
| 2956 | Lisp_Object tem; | 2958 | Lisp_Object tem; |
| 2957 | EMACS_INT prev_from; /* Keep one character before FROM. */ | 2959 | ptrdiff_t prev_from; /* Keep one character before FROM. */ |
| 2958 | EMACS_INT prev_from_byte; | 2960 | ptrdiff_t prev_from_byte; |
| 2959 | int prev_from_syntax; | 2961 | int prev_from_syntax; |
| 2960 | int boundary_stop = commentstop == -1; | 2962 | int boundary_stop = commentstop == -1; |
| 2961 | int nofence; | 2963 | int nofence; |
| 2962 | int found; | 2964 | int found; |
| 2963 | EMACS_INT out_bytepos, out_charpos; | 2965 | ptrdiff_t out_bytepos, out_charpos; |
| 2964 | int temp; | 2966 | int temp; |
| 2965 | 2967 | ||
| 2966 | prev_from = from; | 2968 | prev_from = from; |
| @@ -3004,7 +3006,7 @@ do { prev_from = from; \ | |||
| 3004 | tem = Fcar (oldstate); | 3006 | tem = Fcar (oldstate); |
| 3005 | /* Check whether we are inside string_fence-style string: */ | 3007 | /* Check whether we are inside string_fence-style string: */ |
| 3006 | state.instring = (!NILP (tem) | 3008 | state.instring = (!NILP (tem) |
| 3007 | ? (INTEGERP (tem) ? XINT (tem) : ST_STRING_STYLE) | 3009 | ? (CHARACTERP (tem) ? XFASTINT (tem) : ST_STRING_STYLE) |
| 3008 | : -1); | 3010 | : -1); |
| 3009 | 3011 | ||
| 3010 | oldstate = Fcdr (oldstate); | 3012 | oldstate = Fcdr (oldstate); |
| @@ -3024,19 +3026,21 @@ do { prev_from = from; \ | |||
| 3024 | tem = Fcar (oldstate); | 3026 | tem = Fcar (oldstate); |
| 3025 | state.comstyle = (NILP (tem) | 3027 | state.comstyle = (NILP (tem) |
| 3026 | ? 0 | 3028 | ? 0 |
| 3027 | : (EQ (tem, Qsyntax_table) | 3029 | : (RANGED_INTEGERP (0, tem, ST_COMMENT_STYLE) |
| 3028 | ? ST_COMMENT_STYLE | 3030 | ? XINT (tem) |
| 3029 | : INTEGERP (tem) ? XINT (tem) : 1)); | 3031 | : ST_COMMENT_STYLE)); |
| 3030 | 3032 | ||
| 3031 | oldstate = Fcdr (oldstate); | 3033 | oldstate = Fcdr (oldstate); |
| 3032 | tem = Fcar (oldstate); | 3034 | tem = Fcar (oldstate); |
| 3033 | state.comstr_start = NILP (tem) ? -1 : XINT (tem) ; | 3035 | state.comstr_start = |
| 3036 | RANGED_INTEGERP (PTRDIFF_MIN, tem, PTRDIFF_MAX) ? XINT (tem) : -1; | ||
| 3034 | oldstate = Fcdr (oldstate); | 3037 | oldstate = Fcdr (oldstate); |
| 3035 | tem = Fcar (oldstate); | 3038 | tem = Fcar (oldstate); |
| 3036 | while (!NILP (tem)) /* >= second enclosing sexps. */ | 3039 | while (!NILP (tem)) /* >= second enclosing sexps. */ |
| 3037 | { | 3040 | { |
| 3038 | /* curlevel++->last ran into compiler bug on Apollo */ | 3041 | Lisp_Object temhd = Fcar (tem); |
| 3039 | curlevel->last = XINT (Fcar (tem)); | 3042 | if (RANGED_INTEGERP (PTRDIFF_MIN, temhd, PTRDIFF_MAX)) |
| 3043 | curlevel->last = XINT (temhd); | ||
| 3040 | if (++curlevel == endlevel) | 3044 | if (++curlevel == endlevel) |
| 3041 | curlevel--; /* error ("Nesting too deep for parser"); */ | 3045 | curlevel--; /* error ("Nesting too deep for parser"); */ |
| 3042 | curlevel->prev = -1; | 3046 | curlevel->prev = -1; |
| @@ -3309,14 +3313,14 @@ Fourth arg STOPBEFORE non-nil means stop when come to | |||
| 3309 | any character that starts a sexp. | 3313 | any character that starts a sexp. |
| 3310 | Fifth arg OLDSTATE is a list like what this function returns. | 3314 | Fifth arg OLDSTATE is a list like what this function returns. |
| 3311 | It is used to initialize the state of the parse. Elements number 1, 2, 6 | 3315 | It is used to initialize the state of the parse. Elements number 1, 2, 6 |
| 3312 | and 8 are ignored. | 3316 | are ignored. |
| 3313 | Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. | 3317 | Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. |
| 3314 | If it is symbol `syntax-table', stop after the start of a comment or a | 3318 | If it is symbol `syntax-table', stop after the start of a comment or a |
| 3315 | string, or after end of a comment or a string. */) | 3319 | string, or after end of a comment or a string. */) |
| 3316 | (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) | 3320 | (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) |
| 3317 | { | 3321 | { |
| 3318 | struct lisp_parse_state state; | 3322 | struct lisp_parse_state state; |
| 3319 | int target; | 3323 | EMACS_INT target; |
| 3320 | 3324 | ||
| 3321 | if (!NILP (targetdepth)) | 3325 | if (!NILP (targetdepth)) |
| 3322 | { | 3326 | { |
| @@ -3324,7 +3328,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. | |||
| 3324 | target = XINT (targetdepth); | 3328 | target = XINT (targetdepth); |
| 3325 | } | 3329 | } |
| 3326 | else | 3330 | else |
| 3327 | target = -100000; /* We won't reach this depth */ | 3331 | target = TYPE_MINIMUM (EMACS_INT); /* We won't reach this depth */ |
| 3328 | 3332 | ||
| 3329 | validate_region (&from, &to); | 3333 | validate_region (&from, &to); |
| 3330 | scan_sexps_forward (&state, XINT (from), CHAR_TO_BYTE (XINT (from)), | 3334 | scan_sexps_forward (&state, XINT (from), CHAR_TO_BYTE (XINT (from)), |