X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/9e69cb054d5c124bdf913c82453518ac4d9d6d53..77ab81d0545e980c57c0a35510ade29a9e43b4cd:/src/syntax.c diff --git a/src/syntax.c b/src/syntax.c index f0a7dca42d..1c619044ff 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1,6 +1,6 @@ /* GNU Emacs routines to deal with syntax tables; also word and list parsing. Copyright (C) 1985, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -167,7 +167,6 @@ int syntax_prefix_flag_p (int c) struct gl_state_s gl_state; /* Global state of syntax parser. */ -INTERVAL interval_of (int, Lisp_Object); #define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals to scan to property-change. */ @@ -185,7 +184,8 @@ INTERVAL interval_of (int, Lisp_Object); start/end of OBJECT. */ void -update_syntax_table (int charpos, int count, int init, Lisp_Object object) +update_syntax_table (EMACS_INT charpos, int count, int init, + Lisp_Object object) { Lisp_Object tmp_table; int cnt = 0, invalidate = 1; @@ -370,23 +370,10 @@ char_quoted (EMACS_INT charpos, EMACS_INT bytepos) return quoted; } -/* Return the bytepos one character after BYTEPOS. - We assume that BYTEPOS is not at the end of the buffer. */ - -INLINE EMACS_INT -inc_bytepos (EMACS_INT bytepos) -{ - if (NILP (current_buffer->enable_multibyte_characters)) - return bytepos + 1; - - INC_POS (bytepos); - return bytepos; -} - /* Return the bytepos one character before BYTEPOS. We assume that BYTEPOS is not at the start of the buffer. */ -INLINE EMACS_INT +static INLINE EMACS_INT dec_bytepos (EMACS_INT bytepos) { if (NILP (current_buffer->enable_multibyte_characters)) @@ -475,7 +462,7 @@ find_defun_start (EMACS_INT pos, EMACS_INT pos_byte) /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ static int -prev_char_comend_first (int pos, int pos_byte) +prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte) { int c, val; @@ -557,8 +544,9 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested that determines quote parity to the comment-end. */ while (from != stop) { - int temp_byte, prev_syntax; - int com2start, com2end; + EMACS_INT temp_byte; + int prev_syntax, com2start, com2end; + int comstart; /* Move back and examine a character. */ DEC_BOTH (from, from_byte); @@ -578,7 +566,8 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax)); - + comstart = (com2start || code == Scomment); + /* Nasty cases with overlapping 2-char comment markers: - snmp-mode: -- c -- foo -- c -- --- c -- @@ -589,15 +578,17 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested /// */ /* If a 2-char comment sequence partly overlaps with another, - we don't try to be clever. */ - if (from > stop && (com2end || com2start)) + we don't try to be clever. E.g. |*| in C, or }% in modes that + have %..\n and %{..}%. */ + if (from > stop && (com2end || comstart)) { - int next = from, next_byte = from_byte, next_c, next_syntax; + EMACS_INT next = from, next_byte = from_byte; + int next_c, next_syntax; DEC_BOTH (next, next_byte); UPDATE_SYNTAX_TABLE_BACKWARD (next); next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); next_syntax = SYNTAX_WITH_FLAGS (next_c); - if (((com2start || comnested) + if (((comstart || comnested) && SYNTAX_FLAGS_COMEND_SECOND (syntax) && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) || ((com2end || comnested) @@ -1239,12 +1230,12 @@ Lisp_Object Vfind_word_boundary_function_table; If that many words cannot be found before the end of the buffer, return 0. COUNT negative means scan backward and stop at word beginning. */ -int -scan_words (register int from, register int count) +EMACS_INT +scan_words (register EMACS_INT from, register EMACS_INT count) { - register int beg = BEGV; - register int end = ZV; - register int from_byte = CHAR_TO_BYTE (from); + register EMACS_INT beg = BEGV; + register EMACS_INT end = ZV; + register EMACS_INT from_byte = CHAR_TO_BYTE (from); register enum syntaxcode code; int ch0, ch1; Lisp_Object func, script, pos; @@ -1452,14 +1443,14 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl int *char_ranges; int n_char_ranges = 0; int negate = 0; - register int i, i_byte; + register EMACS_INT i, i_byte; /* Set to 1 if the current buffer is multibyte and the region contains non-ASCII chars. */ int multibyte; /* Set to 1 if STRING is multibyte and it contains non-ASCII chars. */ int string_multibyte; - int size_byte; + EMACS_INT size_byte; const unsigned char *str; int len; Lisp_Object iso_classes; @@ -1771,9 +1762,9 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl } { - int start_point = PT; - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT start_point = PT; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; unsigned char *p = PT_ADDR, *endp, *stop; if (forwardp) @@ -1943,9 +1934,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) register unsigned int c; unsigned char fastmap[0400]; int negate = 0; - register int i, i_byte; + register EMACS_INT i, i_byte; int multibyte; - int size_byte; + EMACS_INT size_byte; unsigned char *str; CHECK_STRING (string); @@ -1998,9 +1989,9 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) fastmap[i] ^= 1; { - int start_point = PT; - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT start_point = PT; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; unsigned char *p = PT_ADDR, *endp, *stop; if (forwardp) @@ -2391,7 +2382,8 @@ between them, return t; otherwise return nil. */) if (code == Scomment_fence) { /* Skip until first preceding unquoted comment_fence. */ - int found = 0, ini = from, ini_byte = from_byte; + int found = 0; + EMACS_INT ini = from, ini_byte = from_byte; while (1) { @@ -2907,11 +2899,11 @@ DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, This includes chars with "quote" or "prefix" syntax (' or p). */) (void) { - int beg = BEGV; - int opoint = PT; - int opoint_byte = PT_BYTE; - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT beg = BEGV; + EMACS_INT opoint = PT; + EMACS_INT opoint_byte = PT_BYTE; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; int c; if (pos <= beg)