diff options
| author | Bill Wohler | 2014-02-23 18:04:35 -0800 |
|---|---|---|
| committer | Bill Wohler | 2014-02-23 18:04:35 -0800 |
| commit | 3e93bafb95608467e438ba7f725fd1f020669f8c (patch) | |
| tree | f2f90109f283e06a18caea3cb2a2623abcfb3a92 /src/syntax.c | |
| parent | 791c0d7634e44bb92ca85af605be84ff2ae08963 (diff) | |
| parent | e918e27fdf331e89268fc2c9d7cf838d3ecf7aa7 (diff) | |
| download | emacs-3e93bafb95608467e438ba7f725fd1f020669f8c.tar.gz emacs-3e93bafb95608467e438ba7f725fd1f020669f8c.zip | |
Merge from trunk; up to 2014-02-23T23:41:17Z!lekktu@gmail.com.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 668 |
1 files changed, 384 insertions, 284 deletions
diff --git a/src/syntax.c b/src/syntax.c index 390d732944d..f2451332b19 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* GNU Emacs routines to deal with syntax tables; also word and list parsing. | 1 | /* GNU Emacs routines to deal with syntax tables; also word and list parsing. |
| 2 | Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2013 Free | 2 | Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2014 Free |
| 3 | Software Foundation, Inc. | 3 | Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -29,14 +29,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 29 | #include "keymap.h" | 29 | #include "keymap.h" |
| 30 | #include "regex.h" | 30 | #include "regex.h" |
| 31 | 31 | ||
| 32 | /* Make syntax table lookup grant data in gl_state. */ | ||
| 33 | #define SYNTAX_ENTRY_VIA_PROPERTY | ||
| 34 | |||
| 35 | #include "syntax.h" | 32 | #include "syntax.h" |
| 36 | #include "intervals.h" | 33 | #include "intervals.h" |
| 37 | #include "category.h" | 34 | #include "category.h" |
| 38 | 35 | ||
| 39 | /* Then there are seven single-bit flags that have the following meanings: | 36 | /* Make syntax table lookup grant data in gl_state. */ |
| 37 | #define SYNTAX(c) syntax_property (c, 1) | ||
| 38 | #define SYNTAX_ENTRY(c) syntax_property_entry (c, 1) | ||
| 39 | #define SYNTAX_WITH_FLAGS(c) syntax_property_with_flags (c, 1) | ||
| 40 | |||
| 41 | /* Eight single-bit flags have the following meanings: | ||
| 40 | 1. This character is the first of a two-character comment-start sequence. | 42 | 1. This character is the first of a two-character comment-start sequence. |
| 41 | 2. This character is the second of a two-character comment-start sequence. | 43 | 2. This character is the second of a two-character comment-start sequence. |
| 42 | 3. This character is the first of a two-character comment-end sequence. | 44 | 3. This character is the first of a two-character comment-end sequence. |
| @@ -48,64 +50,96 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 48 | Note that any two-character sequence whose first character has flag 1 | 50 | Note that any two-character sequence whose first character has flag 1 |
| 49 | and whose second character has flag 2 will be interpreted as a comment start. | 51 | and whose second character has flag 2 will be interpreted as a comment start. |
| 50 | 52 | ||
| 51 | bit 6 and 8 are used to discriminate between different comment styles. | 53 | Bits 6 and 8 discriminate among different comment styles. |
| 52 | Languages such as C++ allow two orthogonal syntax start/end pairs | 54 | Languages such as C++ allow two orthogonal syntax start/end pairs |
| 53 | and bit 6 is used to determine whether a comment-end or Scommentend | 55 | and bit 6 determines whether a comment-end or Scommentend |
| 54 | ends style a or b. Comment markers can start style a, b, c, or bc. | 56 | ends style a or b. Comment markers can start style a, b, c, or bc. |
| 55 | Style a is always the default. | 57 | Style a is always the default. |
| 56 | For 2-char comment markers, the style b flag is only looked up on the second | 58 | For 2-char comment markers, the style b flag is looked up only on the second |
| 57 | char of the comment marker and on the first char of the comment ender. | 59 | char of the comment marker and on the first char of the comment ender. |
| 58 | For style c (like to for the nested flag), the flag can be placed on any | 60 | For style c (like the nested flag), the flag can be placed on any of |
| 59 | one of the chars. | 61 | the chars. */ |
| 60 | */ | ||
| 61 | 62 | ||
| 62 | /* These macros extract specific flags from an integer | 63 | /* These functions extract specific flags from an integer |
| 63 | that holds the syntax code and the flags. */ | 64 | that holds the syntax code and the flags. */ |
| 64 | 65 | ||
| 65 | #define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) | 66 | static bool |
| 66 | 67 | SYNTAX_FLAGS_COMSTART_FIRST (int flags) | |
| 67 | #define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) | 68 | { |
| 68 | 69 | return (flags >> 16) & 1; | |
| 69 | #define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) | 70 | } |
| 70 | 71 | static bool | |
| 71 | #define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) | 72 | SYNTAX_FLAGS_COMSTART_SECOND (int flags) |
| 72 | 73 | { | |
| 73 | #define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) | 74 | return (flags >> 17) & 1; |
| 75 | } | ||
| 76 | static bool | ||
| 77 | SYNTAX_FLAGS_COMEND_FIRST (int flags) | ||
| 78 | { | ||
| 79 | return (flags >> 18) & 1; | ||
| 80 | } | ||
| 81 | static bool | ||
| 82 | SYNTAX_FLAGS_COMEND_SECOND (int flags) | ||
| 83 | { | ||
| 84 | return (flags >> 19) & 1; | ||
| 85 | } | ||
| 86 | static bool | ||
| 87 | SYNTAX_FLAGS_PREFIX (int flags) | ||
| 88 | { | ||
| 89 | return (flags >> 20) & 1; | ||
| 90 | } | ||
| 91 | static bool | ||
| 92 | SYNTAX_FLAGS_COMMENT_STYLEB (int flags) | ||
| 93 | { | ||
| 94 | return (flags >> 21) & 1; | ||
| 95 | } | ||
| 96 | static bool | ||
| 97 | SYNTAX_FLAGS_COMMENT_STYLEC (int flags) | ||
| 98 | { | ||
| 99 | return (flags >> 23) & 1; | ||
| 100 | } | ||
| 101 | static int | ||
| 102 | SYNTAX_FLAGS_COMMENT_STYLEC2 (int flags) | ||
| 103 | { | ||
| 104 | return (flags >> 22) & 2; /* SYNTAX_FLAGS_COMMENT_STYLEC (flags) * 2 */ | ||
| 105 | } | ||
| 106 | static bool | ||
| 107 | SYNTAX_FLAGS_COMMENT_NESTED (int flags) | ||
| 108 | { | ||
| 109 | return (flags >> 22) & 1; | ||
| 110 | } | ||
| 74 | 111 | ||
| 75 | #define SYNTAX_FLAGS_COMMENT_STYLEB(flags) (((flags) >> 21) & 1) | ||
| 76 | #define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 22) & 2) | ||
| 77 | /* FLAGS should be the flags of the main char of the comment marker, e.g. | 112 | /* FLAGS should be the flags of the main char of the comment marker, e.g. |
| 78 | the second for comstart and the first for comend. */ | 113 | the second for comstart and the first for comend. */ |
| 79 | #define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \ | 114 | static int |
| 80 | (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \ | 115 | SYNTAX_FLAGS_COMMENT_STYLE (int flags, int other_flags) |
| 81 | | SYNTAX_FLAGS_COMMENT_STYLEC (flags) \ | 116 | { |
| 82 | | SYNTAX_FLAGS_COMMENT_STYLEC (other_flags)) | 117 | return (SYNTAX_FLAGS_COMMENT_STYLEB (flags) |
| 83 | 118 | | SYNTAX_FLAGS_COMMENT_STYLEC2 (flags) | |
| 84 | #define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) | 119 | | SYNTAX_FLAGS_COMMENT_STYLEC2 (other_flags)); |
| 120 | } | ||
| 85 | 121 | ||
| 86 | /* These macros extract a particular flag for a given character. */ | 122 | /* Extract a particular flag for a given character. */ |
| 87 | 123 | ||
| 88 | #define SYNTAX_COMEND_FIRST(c) \ | 124 | static bool |
| 89 | (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c))) | 125 | SYNTAX_COMEND_FIRST (int c) |
| 90 | #define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c))) | 126 | { |
| 127 | return SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c)); | ||
| 128 | } | ||
| 91 | 129 | ||
| 92 | /* We use these constants in place for comment-style and | 130 | /* We use these constants in place for comment-style and |
| 93 | string-ender-char to distinguish comments/strings started by | 131 | string-ender-char to distinguish comments/strings started by |
| 94 | comment_fence and string_fence codes. */ | 132 | comment_fence and string_fence codes. */ |
| 95 | 133 | ||
| 96 | #define ST_COMMENT_STYLE (256 + 1) | 134 | enum |
| 97 | #define ST_STRING_STYLE (256 + 2) | 135 | { |
| 136 | ST_COMMENT_STYLE = 256 + 1, | ||
| 137 | ST_STRING_STYLE = 256 + 2 | ||
| 138 | }; | ||
| 98 | 139 | ||
| 99 | static Lisp_Object Qsyntax_table_p; | 140 | static Lisp_Object Qsyntax_table_p; |
| 100 | static Lisp_Object Qsyntax_table, Qscan_error; | 141 | static Lisp_Object Qsyntax_table, Qscan_error; |
| 101 | 142 | ||
| 102 | #ifndef __GNUC__ | ||
| 103 | /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, | ||
| 104 | if not compiled with GCC. No need to mark it, since it is used | ||
| 105 | only very temporarily. */ | ||
| 106 | Lisp_Object syntax_temp; | ||
| 107 | #endif | ||
| 108 | |||
| 109 | /* This is the internal form of the parse state used in parse-partial-sexp. */ | 143 | /* This is the internal form of the parse state used in parse-partial-sexp. */ |
| 110 | 144 | ||
| 111 | struct lisp_parse_state | 145 | struct lisp_parse_state |
| @@ -114,7 +148,7 @@ struct lisp_parse_state | |||
| 114 | int instring; /* -1 if not within string, else desired terminator. */ | 148 | int instring; /* -1 if not within string, else desired terminator. */ |
| 115 | EMACS_INT incomment; /* -1 if in unnestable comment else comment nesting */ | 149 | EMACS_INT incomment; /* -1 if in unnestable comment else comment nesting */ |
| 116 | int comstyle; /* comment style a=0, or b=1, or ST_COMMENT_STYLE. */ | 150 | int comstyle; /* comment style a=0, or b=1, or ST_COMMENT_STYLE. */ |
| 117 | int quoted; /* Nonzero if just after an escape char at end of parsing */ | 151 | bool quoted; /* True if just after an escape char at end of parsing. */ |
| 118 | EMACS_INT mindepth; /* Minimum depth seen while scanning. */ | 152 | EMACS_INT mindepth; /* Minimum depth seen while scanning. */ |
| 119 | /* Char number of most recent start-of-expression at current level */ | 153 | /* Char number of most recent start-of-expression at current level */ |
| 120 | ptrdiff_t thislevelstart; | 154 | ptrdiff_t thislevelstart; |
| @@ -143,13 +177,13 @@ static ptrdiff_t find_start_begv; | |||
| 143 | static EMACS_INT find_start_modiff; | 177 | static EMACS_INT find_start_modiff; |
| 144 | 178 | ||
| 145 | 179 | ||
| 146 | static Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); | 180 | static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool); |
| 147 | static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object); | 181 | static Lisp_Object skip_syntaxes (bool, Lisp_Object, Lisp_Object); |
| 148 | static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int); | 182 | static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, bool); |
| 149 | static void scan_sexps_forward (struct lisp_parse_state *, | 183 | static void scan_sexps_forward (struct lisp_parse_state *, |
| 150 | ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT, | 184 | ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT, |
| 151 | int, Lisp_Object, int); | 185 | bool, Lisp_Object, int); |
| 152 | static int in_classes (int, Lisp_Object); | 186 | static bool in_classes (int, Lisp_Object); |
| 153 | 187 | ||
| 154 | /* This setter is used only in this file, so it can be private. */ | 188 | /* This setter is used only in this file, so it can be private. */ |
| 155 | static void | 189 | static void |
| @@ -159,16 +193,110 @@ bset_syntax_table (struct buffer *b, Lisp_Object val) | |||
| 159 | } | 193 | } |
| 160 | 194 | ||
| 161 | /* Whether the syntax of the character C has the prefix flag set. */ | 195 | /* Whether the syntax of the character C has the prefix flag set. */ |
| 162 | int syntax_prefix_flag_p (int c) | 196 | bool |
| 197 | syntax_prefix_flag_p (int c) | ||
| 163 | { | 198 | { |
| 164 | return SYNTAX_PREFIX (c); | 199 | return SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c)); |
| 165 | } | 200 | } |
| 166 | 201 | ||
| 167 | struct gl_state_s gl_state; /* Global state of syntax parser. */ | 202 | struct gl_state_s gl_state; /* Global state of syntax parser. */ |
| 168 | 203 | ||
| 169 | #define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals | 204 | enum { INTERVALS_AT_ONCE = 10 }; /* 1 + max-number of intervals |
| 170 | to scan to property-change. */ | 205 | to scan to property-change. */ |
| 171 | 206 | ||
| 207 | /* Set the syntax entry VAL for char C in table TABLE. */ | ||
| 208 | |||
| 209 | static void | ||
| 210 | SET_RAW_SYNTAX_ENTRY (Lisp_Object table, int c, Lisp_Object val) | ||
| 211 | { | ||
| 212 | CHAR_TABLE_SET (table, c, val); | ||
| 213 | } | ||
| 214 | |||
| 215 | /* Set the syntax entry VAL for char-range RANGE in table TABLE. | ||
| 216 | RANGE is a cons (FROM . TO) specifying the range of characters. */ | ||
| 217 | |||
| 218 | static void | ||
| 219 | SET_RAW_SYNTAX_ENTRY_RANGE (Lisp_Object table, Lisp_Object range, | ||
| 220 | Lisp_Object val) | ||
| 221 | { | ||
| 222 | Fset_char_table_range (table, range, val); | ||
| 223 | } | ||
| 224 | |||
| 225 | /* Extract the information from the entry for character C | ||
| 226 | in the current syntax table. */ | ||
| 227 | |||
| 228 | static Lisp_Object | ||
| 229 | SYNTAX_MATCH (int c) | ||
| 230 | { | ||
| 231 | Lisp_Object ent = SYNTAX_ENTRY (c); | ||
| 232 | return CONSP (ent) ? XCDR (ent) : Qnil; | ||
| 233 | } | ||
| 234 | |||
| 235 | /* This should be called with FROM at the start of forward | ||
| 236 | search, or after the last position of the backward search. It | ||
| 237 | makes sure that the first char is picked up with correct table, so | ||
| 238 | one does not need to call UPDATE_SYNTAX_TABLE immediately after the | ||
| 239 | call. | ||
| 240 | Sign of COUNT gives the direction of the search. | ||
| 241 | */ | ||
| 242 | |||
| 243 | static void | ||
| 244 | SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count) | ||
| 245 | { | ||
| 246 | SETUP_BUFFER_SYNTAX_TABLE (); | ||
| 247 | gl_state.b_property = BEGV; | ||
| 248 | gl_state.e_property = ZV + 1; | ||
| 249 | gl_state.object = Qnil; | ||
| 250 | gl_state.offset = 0; | ||
| 251 | if (parse_sexp_lookup_properties) | ||
| 252 | if (count > 0 || from > BEGV) | ||
| 253 | update_syntax_table (count > 0 ? from : from - 1, count, 1, Qnil); | ||
| 254 | } | ||
| 255 | |||
| 256 | /* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. | ||
| 257 | If it is t (which is only used in fast_c_string_match_ignore_case), | ||
| 258 | ignore properties altogether. | ||
| 259 | |||
| 260 | This is meant for regex.c to use. For buffers, regex.c passes arguments | ||
| 261 | to the UPDATE_SYNTAX_TABLE functions which are relative to BEGV. | ||
| 262 | So if it is a buffer, we set the offset field to BEGV. */ | ||
| 263 | |||
| 264 | void | ||
| 265 | SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object, | ||
| 266 | ptrdiff_t from, ptrdiff_t count) | ||
| 267 | { | ||
| 268 | SETUP_BUFFER_SYNTAX_TABLE (); | ||
| 269 | gl_state.object = object; | ||
| 270 | if (BUFFERP (gl_state.object)) | ||
| 271 | { | ||
| 272 | struct buffer *buf = XBUFFER (gl_state.object); | ||
| 273 | gl_state.b_property = 1; | ||
| 274 | gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1; | ||
| 275 | gl_state.offset = BUF_BEGV (buf) - 1; | ||
| 276 | } | ||
| 277 | else if (NILP (gl_state.object)) | ||
| 278 | { | ||
| 279 | gl_state.b_property = 1; | ||
| 280 | gl_state.e_property = ZV - BEGV + 1; | ||
| 281 | gl_state.offset = BEGV - 1; | ||
| 282 | } | ||
| 283 | else if (EQ (gl_state.object, Qt)) | ||
| 284 | { | ||
| 285 | gl_state.b_property = 0; | ||
| 286 | gl_state.e_property = PTRDIFF_MAX; | ||
| 287 | gl_state.offset = 0; | ||
| 288 | } | ||
| 289 | else | ||
| 290 | { | ||
| 291 | gl_state.b_property = 0; | ||
| 292 | gl_state.e_property = 1 + SCHARS (gl_state.object); | ||
| 293 | gl_state.offset = 0; | ||
| 294 | } | ||
| 295 | if (parse_sexp_lookup_properties) | ||
| 296 | update_syntax_table (from + gl_state.offset - (count <= 0), | ||
| 297 | count, 1, gl_state.object); | ||
| 298 | } | ||
| 299 | |||
| 172 | /* Update gl_state to an appropriate interval which contains CHARPOS. The | 300 | /* Update gl_state to an appropriate interval which contains CHARPOS. The |
| 173 | sign of COUNT give the relative position of CHARPOS wrt the previously | 301 | sign of COUNT give the relative position of CHARPOS wrt the previously |
| 174 | valid interval. If INIT, only [be]_property fields of gl_state are | 302 | valid interval. If INIT, only [be]_property fields of gl_state are |
| @@ -183,12 +311,12 @@ struct gl_state_s gl_state; /* Global state of syntax parser. */ | |||
| 183 | start/end of OBJECT. */ | 311 | start/end of OBJECT. */ |
| 184 | 312 | ||
| 185 | void | 313 | void |
| 186 | update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init, | 314 | update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init, |
| 187 | Lisp_Object object) | 315 | Lisp_Object object) |
| 188 | { | 316 | { |
| 189 | Lisp_Object tmp_table; | 317 | Lisp_Object tmp_table; |
| 190 | unsigned cnt = 0; | 318 | int cnt = 0; |
| 191 | int invalidate = 1; | 319 | bool invalidate = 1; |
| 192 | INTERVAL i; | 320 | INTERVAL i; |
| 193 | 321 | ||
| 194 | if (init) | 322 | if (init) |
| @@ -340,16 +468,16 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init, | |||
| 340 | gl_state.b_property = gl_state.start; | 468 | gl_state.b_property = gl_state.start; |
| 341 | } | 469 | } |
| 342 | 470 | ||
| 343 | /* Returns TRUE if char at CHARPOS is quoted. | 471 | /* Returns true if char at CHARPOS is quoted. |
| 344 | Global syntax-table data should be set up already to be good at CHARPOS | 472 | Global syntax-table data should be set up already to be good at CHARPOS |
| 345 | or after. On return global syntax data is good for lookup at CHARPOS. */ | 473 | or after. On return global syntax data is good for lookup at CHARPOS. */ |
| 346 | 474 | ||
| 347 | static int | 475 | static bool |
| 348 | char_quoted (ptrdiff_t charpos, ptrdiff_t bytepos) | 476 | char_quoted (ptrdiff_t charpos, ptrdiff_t bytepos) |
| 349 | { | 477 | { |
| 350 | register enum syntaxcode code; | 478 | enum syntaxcode code; |
| 351 | register ptrdiff_t beg = BEGV; | 479 | ptrdiff_t beg = BEGV; |
| 352 | register int quoted = 0; | 480 | bool quoted = 0; |
| 353 | ptrdiff_t orig = charpos; | 481 | ptrdiff_t orig = charpos; |
| 354 | 482 | ||
| 355 | while (charpos > beg) | 483 | while (charpos > beg) |
| @@ -466,10 +594,11 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 466 | 594 | ||
| 467 | /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ | 595 | /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ |
| 468 | 596 | ||
| 469 | static int | 597 | static bool |
| 470 | prev_char_comend_first (ptrdiff_t pos, ptrdiff_t pos_byte) | 598 | prev_char_comend_first (ptrdiff_t pos, ptrdiff_t pos_byte) |
| 471 | { | 599 | { |
| 472 | int c, val; | 600 | int c; |
| 601 | bool val; | ||
| 473 | 602 | ||
| 474 | DEC_BOTH (pos, pos_byte); | 603 | DEC_BOTH (pos, pos_byte); |
| 475 | UPDATE_SYNTAX_TABLE_BACKWARD (pos); | 604 | UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
| @@ -479,28 +608,11 @@ prev_char_comend_first (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 479 | return val; | 608 | return val; |
| 480 | } | 609 | } |
| 481 | 610 | ||
| 482 | /* Return the SYNTAX_COMSTART_FIRST of the character before POS, POS_BYTE. */ | 611 | /* Check whether charpos FROM is at the end of a comment. |
| 483 | |||
| 484 | /* static int | ||
| 485 | * prev_char_comstart_first (pos, pos_byte) | ||
| 486 | * int pos, pos_byte; | ||
| 487 | * { | ||
| 488 | * int c, val; | ||
| 489 | * | ||
| 490 | * DEC_BOTH (pos, pos_byte); | ||
| 491 | * UPDATE_SYNTAX_TABLE_BACKWARD (pos); | ||
| 492 | * c = FETCH_CHAR (pos_byte); | ||
| 493 | * val = SYNTAX_COMSTART_FIRST (c); | ||
| 494 | * UPDATE_SYNTAX_TABLE_FORWARD (pos + 1); | ||
| 495 | * return val; | ||
| 496 | * } */ | ||
| 497 | |||
| 498 | /* Checks whether charpos FROM is at the end of a comment. | ||
| 499 | FROM_BYTE is the bytepos corresponding to FROM. | 612 | FROM_BYTE is the bytepos corresponding to FROM. |
| 500 | Do not move back before STOP. | 613 | Do not move back before STOP. |
| 501 | 614 | ||
| 502 | Return a positive value if we find a comment ending at FROM/FROM_BYTE; | 615 | Return true if we find a comment ending at FROM/FROM_BYTE. |
| 503 | return -1 otherwise. | ||
| 504 | 616 | ||
| 505 | If successful, store the charpos of the comment's beginning | 617 | If successful, store the charpos of the comment's beginning |
| 506 | into *CHARPOS_PTR, and the bytepos into *BYTEPOS_PTR. | 618 | into *CHARPOS_PTR, and the bytepos into *BYTEPOS_PTR. |
| @@ -508,8 +620,10 @@ prev_char_comend_first (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 508 | Global syntax data remains valid for backward search starting at | 620 | Global syntax data remains valid for backward search starting at |
| 509 | the returned value (or at FROM, if the search was not successful). */ | 621 | the returned value (or at FROM, if the search was not successful). */ |
| 510 | 622 | ||
| 511 | static int | 623 | static bool |
| 512 | back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, int comnested, int comstyle, ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr) | 624 | back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, |
| 625 | bool comnested, int comstyle, ptrdiff_t *charpos_ptr, | ||
| 626 | ptrdiff_t *bytepos_ptr) | ||
| 513 | { | 627 | { |
| 514 | /* Look back, counting the parity of string-quotes, | 628 | /* Look back, counting the parity of string-quotes, |
| 515 | and recording the comment-starters seen. | 629 | and recording the comment-starters seen. |
| @@ -521,13 +635,13 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, int comnested | |||
| 521 | which is I+2X quotes from the comment-end. | 635 | which is I+2X quotes from the comment-end. |
| 522 | PARITY is current parity of quotes from the comment end. */ | 636 | PARITY is current parity of quotes from the comment end. */ |
| 523 | int string_style = -1; /* Presumed outside of any string. */ | 637 | int string_style = -1; /* Presumed outside of any string. */ |
| 524 | int string_lossage = 0; | 638 | bool string_lossage = 0; |
| 525 | /* Not a real lossage: indicates that we have passed a matching comment | 639 | /* Not a real lossage: indicates that we have passed a matching comment |
| 526 | starter plus a non-matching comment-ender, meaning that any matching | 640 | starter plus a non-matching comment-ender, meaning that any matching |
| 527 | comment-starter we might see later could be a false positive (hidden | 641 | comment-starter we might see later could be a false positive (hidden |
| 528 | inside another comment). | 642 | inside another comment). |
| 529 | Test case: { a (* b } c (* d *) */ | 643 | Test case: { a (* b } c (* d *) */ |
| 530 | int comment_lossage = 0; | 644 | bool comment_lossage = 0; |
| 531 | ptrdiff_t comment_end = from; | 645 | ptrdiff_t comment_end = from; |
| 532 | ptrdiff_t comment_end_byte = from_byte; | 646 | ptrdiff_t comment_end_byte = from_byte; |
| 533 | ptrdiff_t comstart_pos = 0; | 647 | ptrdiff_t comstart_pos = 0; |
| @@ -536,8 +650,8 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, int comnested | |||
| 536 | or 0 if we didn't come across it yet. */ | 650 | or 0 if we didn't come across it yet. */ |
| 537 | ptrdiff_t defun_start = 0; | 651 | ptrdiff_t defun_start = 0; |
| 538 | ptrdiff_t defun_start_byte = 0; | 652 | ptrdiff_t defun_start_byte = 0; |
| 539 | register enum syntaxcode code; | 653 | enum syntaxcode code; |
| 540 | int nesting = 1; /* current comment nesting */ | 654 | ptrdiff_t nesting = 1; /* current comment nesting */ |
| 541 | int c; | 655 | int c; |
| 542 | int syntax = 0; | 656 | int syntax = 0; |
| 543 | 657 | ||
| @@ -550,8 +664,8 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, int comnested | |||
| 550 | while (from != stop) | 664 | while (from != stop) |
| 551 | { | 665 | { |
| 552 | ptrdiff_t temp_byte; | 666 | ptrdiff_t temp_byte; |
| 553 | int prev_syntax, com2start, com2end; | 667 | int prev_syntax; |
| 554 | int comstart; | 668 | bool com2start, com2end, comstart; |
| 555 | 669 | ||
| 556 | /* Move back and examine a character. */ | 670 | /* Move back and examine a character. */ |
| 557 | DEC_BOTH (from, from_byte); | 671 | DEC_BOTH (from, from_byte); |
| @@ -772,7 +886,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, int comnested | |||
| 772 | *charpos_ptr = from; | 886 | *charpos_ptr = from; |
| 773 | *bytepos_ptr = from_byte; | 887 | *bytepos_ptr = from_byte; |
| 774 | 888 | ||
| 775 | return (from == comment_end) ? -1 : from; | 889 | return from != comment_end; |
| 776 | } | 890 | } |
| 777 | 891 | ||
| 778 | DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, | 892 | DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, |
| @@ -854,31 +968,28 @@ One argument, a syntax table. */) | |||
| 854 | into the code it signifies. | 968 | into the code it signifies. |
| 855 | This is used by modify-syntax-entry, and other things. */ | 969 | This is used by modify-syntax-entry, and other things. */ |
| 856 | 970 | ||
| 857 | unsigned char syntax_spec_code[0400] = | 971 | unsigned char const syntax_spec_code[0400] = |
| 858 | { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 972 | { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 859 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 973 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 860 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 974 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 861 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 975 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 862 | (char) Swhitespace, (char) Scomment_fence, (char) Sstring, 0377, | 976 | Swhitespace, Scomment_fence, Sstring, 0377, Smath, 0377, 0377, Squote, |
| 863 | (char) Smath, 0377, 0377, (char) Squote, | 977 | Sopen, Sclose, 0377, 0377, 0377, Swhitespace, Spunct, Scharquote, |
| 864 | (char) Sopen, (char) Sclose, 0377, 0377, | ||
| 865 | 0377, (char) Swhitespace, (char) Spunct, (char) Scharquote, | ||
| 866 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 978 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 867 | 0377, 0377, 0377, 0377, | 979 | 0377, 0377, 0377, 0377, Scomment, 0377, Sendcomment, 0377, |
| 868 | (char) Scomment, 0377, (char) Sendcomment, 0377, | 980 | Sinherit, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */ |
| 869 | (char) Sinherit, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */ | ||
| 870 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 981 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 871 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword, | 982 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, Sword, |
| 872 | 0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol, | 983 | 0377, 0377, 0377, 0377, Sescape, 0377, 0377, Ssymbol, |
| 873 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */ | 984 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */ |
| 874 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | 985 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
| 875 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword, | 986 | 0377, 0377, 0377, 0377, 0377, 0377, 0377, Sword, |
| 876 | 0377, 0377, 0377, 0377, (char) Sstring_fence, 0377, 0377, 0377 | 987 | 0377, 0377, 0377, 0377, Sstring_fence, 0377, 0377, 0377 |
| 877 | }; | 988 | }; |
| 878 | 989 | ||
| 879 | /* Indexed by syntax code, give the letter that describes it. */ | 990 | /* Indexed by syntax code, give the letter that describes it. */ |
| 880 | 991 | ||
| 881 | char syntax_code_spec[16] = | 992 | char const syntax_code_spec[16] = |
| 882 | { | 993 | { |
| 883 | ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@', | 994 | ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@', |
| 884 | '!', '|' | 995 | '!', '|' |
| @@ -904,15 +1015,16 @@ are listed in the documentation of `modify-syntax-entry'. */) | |||
| 904 | CHECK_CHARACTER (character); | 1015 | CHECK_CHARACTER (character); |
| 905 | char_int = XINT (character); | 1016 | char_int = XINT (character); |
| 906 | SETUP_BUFFER_SYNTAX_TABLE (); | 1017 | SETUP_BUFFER_SYNTAX_TABLE (); |
| 907 | return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); | 1018 | return make_number (syntax_code_spec[SYNTAX (char_int)]); |
| 908 | } | 1019 | } |
| 909 | 1020 | ||
| 910 | DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, | 1021 | DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, |
| 911 | doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */) | 1022 | doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */) |
| 912 | (Lisp_Object character) | 1023 | (Lisp_Object character) |
| 913 | { | 1024 | { |
| 914 | int char_int, code; | 1025 | int char_int; |
| 915 | CHECK_NUMBER (character); | 1026 | enum syntaxcode code; |
| 1027 | CHECK_CHARACTER (character); | ||
| 916 | char_int = XINT (character); | 1028 | char_int = XINT (character); |
| 917 | SETUP_BUFFER_SYNTAX_TABLE (); | 1029 | SETUP_BUFFER_SYNTAX_TABLE (); |
| 918 | code = SYNTAX (char_int); | 1030 | code = SYNTAX (char_int); |
| @@ -929,19 +1041,18 @@ cons cell \(CODE . MATCHING-CHAR) which can be used, for example, as | |||
| 929 | the value of a `syntax-table' text property. */) | 1041 | the value of a `syntax-table' text property. */) |
| 930 | (Lisp_Object string) | 1042 | (Lisp_Object string) |
| 931 | { | 1043 | { |
| 932 | register const unsigned char *p; | 1044 | const unsigned char *p; |
| 933 | register enum syntaxcode code; | ||
| 934 | int val; | 1045 | int val; |
| 935 | Lisp_Object match; | 1046 | Lisp_Object match; |
| 936 | 1047 | ||
| 937 | CHECK_STRING (string); | 1048 | CHECK_STRING (string); |
| 938 | 1049 | ||
| 939 | p = SDATA (string); | 1050 | p = SDATA (string); |
| 940 | code = (enum syntaxcode) syntax_spec_code[*p++]; | 1051 | val = syntax_spec_code[*p++]; |
| 941 | if (((int) code & 0377) == 0377) | 1052 | if (val == 0377) |
| 942 | error ("Invalid syntax description letter: %c", p[-1]); | 1053 | error ("Invalid syntax description letter: %c", p[-1]); |
| 943 | 1054 | ||
| 944 | if (code == Sinherit) | 1055 | if (val == Sinherit) |
| 945 | return Qnil; | 1056 | return Qnil; |
| 946 | 1057 | ||
| 947 | if (*p) | 1058 | if (*p) |
| @@ -956,7 +1067,6 @@ the value of a `syntax-table' text property. */) | |||
| 956 | else | 1067 | else |
| 957 | match = Qnil; | 1068 | match = Qnil; |
| 958 | 1069 | ||
| 959 | val = (int) code; | ||
| 960 | while (*p) | 1070 | while (*p) |
| 961 | switch (*p++) | 1071 | switch (*p++) |
| 962 | { | 1072 | { |
| @@ -1078,10 +1188,8 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1078 | doc: /* Insert a description of the internal syntax description SYNTAX at point. */) | 1188 | doc: /* Insert a description of the internal syntax description SYNTAX at point. */) |
| 1079 | (Lisp_Object syntax) | 1189 | (Lisp_Object syntax) |
| 1080 | { | 1190 | { |
| 1081 | register enum syntaxcode code; | 1191 | int code, syntax_code; |
| 1082 | int syntax_code; | 1192 | bool start1, start2, end1, end2, prefix, comstyleb, comstylec, comnested; |
| 1083 | char desc, start1, start2, end1, end2, prefix, | ||
| 1084 | comstyleb, comstylec, comnested; | ||
| 1085 | char str[2]; | 1193 | char str[2]; |
| 1086 | Lisp_Object first, match_lisp, value = syntax; | 1194 | Lisp_Object first, match_lisp, value = syntax; |
| 1087 | 1195 | ||
| @@ -1113,7 +1221,7 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1113 | } | 1221 | } |
| 1114 | 1222 | ||
| 1115 | syntax_code = XINT (first) & INT_MAX; | 1223 | syntax_code = XINT (first) & INT_MAX; |
| 1116 | code = (enum syntaxcode) (syntax_code & 0377); | 1224 | code = syntax_code & 0377; |
| 1117 | start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); | 1225 | start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); |
| 1118 | start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; | 1226 | start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; |
| 1119 | end1 = SYNTAX_FLAGS_COMEND_FIRST (syntax_code); | 1227 | end1 = SYNTAX_FLAGS_COMEND_FIRST (syntax_code); |
| @@ -1123,14 +1231,13 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1123 | comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code); | 1231 | comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code); |
| 1124 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code); | 1232 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code); |
| 1125 | 1233 | ||
| 1126 | if ((int) code < 0 || (int) code >= (int) Smax) | 1234 | if (Smax <= code) |
| 1127 | { | 1235 | { |
| 1128 | insert_string ("invalid"); | 1236 | insert_string ("invalid"); |
| 1129 | return syntax; | 1237 | return syntax; |
| 1130 | } | 1238 | } |
| 1131 | desc = syntax_code_spec[(int) code]; | ||
| 1132 | 1239 | ||
| 1133 | str[0] = desc, str[1] = 0; | 1240 | str[0] = syntax_code_spec[code], str[1] = 0; |
| 1134 | insert (str, 1); | 1241 | insert (str, 1); |
| 1135 | 1242 | ||
| 1136 | if (NILP (match_lisp)) | 1243 | if (NILP (match_lisp)) |
| @@ -1357,6 +1464,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1357 | 1464 | ||
| 1358 | DEFUN ("forward-word", Fforward_word, Sforward_word, 0, 1, "^p", | 1465 | DEFUN ("forward-word", Fforward_word, Sforward_word, 0, 1, "^p", |
| 1359 | doc: /* Move point forward ARG words (backward if ARG is negative). | 1466 | doc: /* Move point forward ARG words (backward if ARG is negative). |
| 1467 | If ARG is omitted or nil, move point forward one word. | ||
| 1360 | Normally returns t. | 1468 | Normally returns t. |
| 1361 | If an edge of the buffer or a field boundary is reached, point is left there | 1469 | If an edge of the buffer or a field boundary is reached, point is left there |
| 1362 | and the function returns nil. Field boundaries are not noticed if | 1470 | and the function returns nil. Field boundaries are not noticed if |
| @@ -1377,7 +1485,7 @@ and the function returns nil. Field boundaries are not noticed if | |||
| 1377 | 1485 | ||
| 1378 | /* Avoid jumping out of an input field. */ | 1486 | /* Avoid jumping out of an input field. */ |
| 1379 | tmp = Fconstrain_to_field (make_number (val), make_number (PT), | 1487 | tmp = Fconstrain_to_field (make_number (val), make_number (PT), |
| 1380 | Qt, Qnil, Qnil); | 1488 | Qnil, Qnil, Qnil); |
| 1381 | val = XFASTINT (tmp); | 1489 | val = XFASTINT (tmp); |
| 1382 | 1490 | ||
| 1383 | SET_PT (val); | 1491 | SET_PT (val); |
| @@ -1424,28 +1532,29 @@ DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, | |||
| 1424 | SYNTAX is a string of syntax code characters. | 1532 | SYNTAX is a string of syntax code characters. |
| 1425 | Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM. | 1533 | Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM. |
| 1426 | If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. | 1534 | If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. |
| 1427 | This function returns the distance traveled, either zero or negative. */) | 1535 | This function returns either zero or a negative number, and the absolute value |
| 1536 | of this is the distance traveled. */) | ||
| 1428 | (Lisp_Object syntax, Lisp_Object lim) | 1537 | (Lisp_Object syntax, Lisp_Object lim) |
| 1429 | { | 1538 | { |
| 1430 | return skip_syntaxes (0, syntax, lim); | 1539 | return skip_syntaxes (0, syntax, lim); |
| 1431 | } | 1540 | } |
| 1432 | 1541 | ||
| 1433 | static Lisp_Object | 1542 | static Lisp_Object |
| 1434 | skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_classes) | 1543 | skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, |
| 1544 | bool handle_iso_classes) | ||
| 1435 | { | 1545 | { |
| 1436 | register unsigned int c; | 1546 | int c; |
| 1437 | unsigned char fastmap[0400]; | 1547 | char fastmap[0400]; |
| 1438 | /* Store the ranges of non-ASCII characters. */ | 1548 | /* Store the ranges of non-ASCII characters. */ |
| 1439 | int *char_ranges IF_LINT (= NULL); | 1549 | int *char_ranges IF_LINT (= NULL); |
| 1440 | int n_char_ranges = 0; | 1550 | int n_char_ranges = 0; |
| 1441 | int negate = 0; | 1551 | bool negate = 0; |
| 1442 | register ptrdiff_t i, i_byte; | 1552 | ptrdiff_t i, i_byte; |
| 1443 | /* Set to 1 if the current buffer is multibyte and the region | 1553 | /* True if the current buffer is multibyte and the region contains |
| 1444 | contains non-ASCII chars. */ | 1554 | non-ASCII chars. */ |
| 1445 | int multibyte; | 1555 | bool multibyte; |
| 1446 | /* Set to 1 if STRING is multibyte and it contains non-ASCII | 1556 | /* True if STRING is multibyte and it contains non-ASCII chars. */ |
| 1447 | chars. */ | 1557 | bool string_multibyte; |
| 1448 | int string_multibyte; | ||
| 1449 | ptrdiff_t size_byte; | 1558 | ptrdiff_t size_byte; |
| 1450 | const unsigned char *str; | 1559 | const unsigned char *str; |
| 1451 | int len; | 1560 | int len; |
| @@ -1489,7 +1598,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1489 | 1598 | ||
| 1490 | if (! string_multibyte) | 1599 | if (! string_multibyte) |
| 1491 | { | 1600 | { |
| 1492 | int string_has_eight_bit = 0; | 1601 | bool string_has_eight_bit = 0; |
| 1493 | 1602 | ||
| 1494 | /* At first setup fastmap. */ | 1603 | /* At first setup fastmap. */ |
| 1495 | while (i_byte < size_byte) | 1604 | while (i_byte < size_byte) |
| @@ -1544,7 +1653,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1544 | if (i_byte + 1 < size_byte | 1653 | if (i_byte + 1 < size_byte |
| 1545 | && str[i_byte] == '-') | 1654 | && str[i_byte] == '-') |
| 1546 | { | 1655 | { |
| 1547 | unsigned int c2; | 1656 | int c2; |
| 1548 | 1657 | ||
| 1549 | /* Skip over the dash. */ | 1658 | /* Skip over the dash. */ |
| 1550 | i_byte++; | 1659 | i_byte++; |
| @@ -1557,7 +1666,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1557 | 1666 | ||
| 1558 | if (c <= c2) | 1667 | if (c <= c2) |
| 1559 | { | 1668 | { |
| 1560 | unsigned lim2 = c2 + 1; | 1669 | int lim2 = c2 + 1; |
| 1561 | while (c < lim2) | 1670 | while (c < lim2) |
| 1562 | fastmap[c++] = 1; | 1671 | fastmap[c++] = 1; |
| 1563 | if (! ASCII_CHAR_P (c2)) | 1672 | if (! ASCII_CHAR_P (c2)) |
| @@ -1577,34 +1686,31 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1577 | the corresponding multibyte chars. */ | 1686 | the corresponding multibyte chars. */ |
| 1578 | if (multibyte && string_has_eight_bit) | 1687 | if (multibyte && string_has_eight_bit) |
| 1579 | { | 1688 | { |
| 1580 | unsigned char fastmap2[0400]; | 1689 | char *p1; |
| 1581 | int range_start_byte, range_start_char; | 1690 | char himap[0200 + 1]; |
| 1582 | 1691 | memcpy (himap, fastmap + 0200, 0200); | |
| 1583 | memcpy (fastmap + 0200, fastmap2 + 0200, 0200); | 1692 | himap[0200] = 0; |
| 1584 | memset (fastmap + 0200, 0, 0200); | 1693 | memset (fastmap + 0200, 0, 0200); |
| 1585 | /* We are sure that this loop stops. */ | ||
| 1586 | for (i = 0200; ! fastmap2[i]; i++); | ||
| 1587 | c = BYTE8_TO_CHAR (i); | ||
| 1588 | fastmap[CHAR_LEADING_CODE (c)] = 1; | ||
| 1589 | range_start_byte = i; | ||
| 1590 | range_start_char = c; | ||
| 1591 | char_ranges = alloca (sizeof *char_ranges * 128 * 2); | 1694 | char_ranges = alloca (sizeof *char_ranges * 128 * 2); |
| 1592 | for (i = 129; i < 0400; i++) | 1695 | i = 0; |
| 1696 | |||
| 1697 | while ((p1 = memchr (himap + i, 1, 0200 - i))) | ||
| 1593 | { | 1698 | { |
| 1594 | c = BYTE8_TO_CHAR (i); | 1699 | /* Deduce the next range C..C2 from the next clump of 1s |
| 1595 | fastmap[CHAR_LEADING_CODE (c)] = 1; | 1700 | in HIMAP starting with &HIMAP[I]. HIMAP is the high |
| 1596 | if (i - range_start_byte != c - range_start_char) | 1701 | order half of the old FASTMAP. */ |
| 1597 | { | 1702 | int c2, leading_code; |
| 1598 | char_ranges[n_char_ranges++] = range_start_char; | 1703 | i = p1 - himap; |
| 1599 | char_ranges[n_char_ranges++] = ((i - 1 - range_start_byte) | 1704 | c = BYTE8_TO_CHAR (i + 0200); |
| 1600 | + range_start_char); | 1705 | i += strlen (p1); |
| 1601 | range_start_byte = i; | 1706 | c2 = BYTE8_TO_CHAR (i + 0200 - 1); |
| 1602 | range_start_char = c; | 1707 | |
| 1603 | } | 1708 | char_ranges[n_char_ranges++] = c; |
| 1709 | char_ranges[n_char_ranges++] = c2; | ||
| 1710 | leading_code = CHAR_LEADING_CODE (c); | ||
| 1711 | memset (fastmap + leading_code, 1, | ||
| 1712 | CHAR_LEADING_CODE (c2) - leading_code + 1); | ||
| 1604 | } | 1713 | } |
| 1605 | char_ranges[n_char_ranges++] = range_start_char; | ||
| 1606 | char_ranges[n_char_ranges++] = ((i - 1 - range_start_byte) | ||
| 1607 | + range_start_char); | ||
| 1608 | } | 1714 | } |
| 1609 | } | 1715 | } |
| 1610 | else /* STRING is multibyte */ | 1716 | else /* STRING is multibyte */ |
| @@ -1613,9 +1719,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1613 | 1719 | ||
| 1614 | while (i_byte < size_byte) | 1720 | while (i_byte < size_byte) |
| 1615 | { | 1721 | { |
| 1616 | unsigned char leading_code; | 1722 | int leading_code = str[i_byte]; |
| 1617 | |||
| 1618 | leading_code = str[i_byte]; | ||
| 1619 | c = STRING_CHAR_AND_LENGTH (str + i_byte, len); | 1723 | c = STRING_CHAR_AND_LENGTH (str + i_byte, len); |
| 1620 | i_byte += len; | 1724 | i_byte += len; |
| 1621 | 1725 | ||
| @@ -1669,8 +1773,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1669 | if (i_byte + 1 < size_byte | 1773 | if (i_byte + 1 < size_byte |
| 1670 | && str[i_byte] == '-') | 1774 | && str[i_byte] == '-') |
| 1671 | { | 1775 | { |
| 1672 | unsigned int c2; | 1776 | int c2, leading_code2; |
| 1673 | unsigned char leading_code2; | ||
| 1674 | 1777 | ||
| 1675 | /* Skip over the dash. */ | 1778 | /* Skip over the dash. */ |
| 1676 | i_byte++; | 1779 | i_byte++; |
| @@ -1684,7 +1787,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1684 | && i_byte < size_byte) | 1787 | && i_byte < size_byte) |
| 1685 | { | 1788 | { |
| 1686 | leading_code2 = str[i_byte]; | 1789 | leading_code2 = str[i_byte]; |
| 1687 | c2 =STRING_CHAR_AND_LENGTH (str + i_byte, len); | 1790 | c2 = STRING_CHAR_AND_LENGTH (str + i_byte, len); |
| 1688 | i_byte += len; | 1791 | i_byte += len; |
| 1689 | } | 1792 | } |
| 1690 | 1793 | ||
| @@ -1698,7 +1801,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1698 | } | 1801 | } |
| 1699 | if (! ASCII_CHAR_P (c)) | 1802 | if (! ASCII_CHAR_P (c)) |
| 1700 | { | 1803 | { |
| 1701 | unsigned lim2 = leading_code2 + 1; | 1804 | int lim2 = leading_code2 + 1; |
| 1702 | while (leading_code < lim2) | 1805 | while (leading_code < lim2) |
| 1703 | fastmap[leading_code++] = 1; | 1806 | fastmap[leading_code++] = 1; |
| 1704 | if (c <= c2) | 1807 | if (c <= c2) |
| @@ -1731,7 +1834,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1731 | for (i = 0; i < n_char_ranges; i += 2) | 1834 | for (i = 0; i < n_char_ranges; i += 2) |
| 1732 | { | 1835 | { |
| 1733 | int c1 = char_ranges[i]; | 1836 | int c1 = char_ranges[i]; |
| 1734 | unsigned lim2 = char_ranges[i + 1] + 1; | 1837 | int lim2 = char_ranges[i + 1] + 1; |
| 1735 | 1838 | ||
| 1736 | for (; c1 < lim2; c1++) | 1839 | for (; c1 < lim2; c1++) |
| 1737 | { | 1840 | { |
| @@ -1777,7 +1880,7 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1777 | } | 1880 | } |
| 1778 | 1881 | ||
| 1779 | immediate_quit = 1; | 1882 | immediate_quit = 1; |
| 1780 | /* This code may look up syntax tables using macros that rely on the | 1883 | /* This code may look up syntax tables using functions that rely on the |
| 1781 | gl_state object. To make sure this object is not out of date, | 1884 | gl_state object. To make sure this object is not out of date, |
| 1782 | let's initialize it manually. | 1885 | let's initialize it manually. |
| 1783 | We ignore syntax-table text-properties for now, since that's | 1886 | We ignore syntax-table text-properties for now, since that's |
| @@ -1927,13 +2030,13 @@ skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_cl | |||
| 1927 | 2030 | ||
| 1928 | 2031 | ||
| 1929 | static Lisp_Object | 2032 | static Lisp_Object |
| 1930 | skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | 2033 | skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) |
| 1931 | { | 2034 | { |
| 1932 | register unsigned int c; | 2035 | int c; |
| 1933 | unsigned char fastmap[0400]; | 2036 | unsigned char fastmap[0400]; |
| 1934 | int negate = 0; | 2037 | bool negate = 0; |
| 1935 | register ptrdiff_t i, i_byte; | 2038 | ptrdiff_t i, i_byte; |
| 1936 | int multibyte; | 2039 | bool multibyte; |
| 1937 | ptrdiff_t size_byte; | 2040 | ptrdiff_t size_byte; |
| 1938 | unsigned char *str; | 2041 | unsigned char *str; |
| 1939 | 2042 | ||
| @@ -2021,7 +2124,7 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2021 | stop = endp; | 2124 | stop = endp; |
| 2022 | } | 2125 | } |
| 2023 | c = STRING_CHAR_AND_LENGTH (p, nbytes); | 2126 | c = STRING_CHAR_AND_LENGTH (p, nbytes); |
| 2024 | if (! fastmap[(int) SYNTAX (c)]) | 2127 | if (! fastmap[SYNTAX (c)]) |
| 2025 | break; | 2128 | break; |
| 2026 | p += nbytes, pos++, pos_byte += nbytes; | 2129 | p += nbytes, pos++, pos_byte += nbytes; |
| 2027 | UPDATE_SYNTAX_TABLE_FORWARD (pos); | 2130 | UPDATE_SYNTAX_TABLE_FORWARD (pos); |
| @@ -2038,7 +2141,7 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2038 | p = GAP_END_ADDR; | 2141 | p = GAP_END_ADDR; |
| 2039 | stop = endp; | 2142 | stop = endp; |
| 2040 | } | 2143 | } |
| 2041 | if (! fastmap[(int) SYNTAX (*p)]) | 2144 | if (! fastmap[SYNTAX (*p)]) |
| 2042 | break; | 2145 | break; |
| 2043 | p++, pos++, pos_byte++; | 2146 | p++, pos++, pos_byte++; |
| 2044 | UPDATE_SYNTAX_TABLE_FORWARD (pos); | 2147 | UPDATE_SYNTAX_TABLE_FORWARD (pos); |
| @@ -2064,7 +2167,7 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2064 | prev_p = p; | 2167 | prev_p = p; |
| 2065 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2168 | while (--p >= stop && ! CHAR_HEAD_P (*p)); |
| 2066 | c = STRING_CHAR (p); | 2169 | c = STRING_CHAR (p); |
| 2067 | if (! fastmap[(int) SYNTAX (c)]) | 2170 | if (! fastmap[SYNTAX (c)]) |
| 2068 | break; | 2171 | break; |
| 2069 | pos--, pos_byte -= prev_p - p; | 2172 | pos--, pos_byte -= prev_p - p; |
| 2070 | } | 2173 | } |
| @@ -2081,7 +2184,7 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2081 | stop = endp; | 2184 | stop = endp; |
| 2082 | } | 2185 | } |
| 2083 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); | 2186 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
| 2084 | if (! fastmap[(int) SYNTAX (p[-1])]) | 2187 | if (! fastmap[SYNTAX (p[-1])]) |
| 2085 | break; | 2188 | break; |
| 2086 | p--, pos--, pos_byte--; | 2189 | p--, pos--, pos_byte--; |
| 2087 | } | 2190 | } |
| @@ -2095,14 +2198,14 @@ skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2095 | } | 2198 | } |
| 2096 | } | 2199 | } |
| 2097 | 2200 | ||
| 2098 | /* Return 1 if character C belongs to one of the ISO classes | 2201 | /* Return true if character C belongs to one of the ISO classes |
| 2099 | in the list ISO_CLASSES. Each class is represented by an | 2202 | in the list ISO_CLASSES. Each class is represented by an |
| 2100 | integer which is its type according to re_wctype. */ | 2203 | integer which is its type according to re_wctype. */ |
| 2101 | 2204 | ||
| 2102 | static int | 2205 | static bool |
| 2103 | in_classes (int c, Lisp_Object iso_classes) | 2206 | in_classes (int c, Lisp_Object iso_classes) |
| 2104 | { | 2207 | { |
| 2105 | int fits_class = 0; | 2208 | bool fits_class = 0; |
| 2106 | 2209 | ||
| 2107 | while (CONSP (iso_classes)) | 2210 | while (CONSP (iso_classes)) |
| 2108 | { | 2211 | { |
| @@ -2122,26 +2225,26 @@ in_classes (int c, Lisp_Object iso_classes) | |||
| 2122 | FROM_BYTE is the bytepos corresponding to FROM. | 2225 | FROM_BYTE is the bytepos corresponding to FROM. |
| 2123 | Do not move past STOP (a charpos). | 2226 | Do not move past STOP (a charpos). |
| 2124 | The comment over which we have to jump is of style STYLE | 2227 | The comment over which we have to jump is of style STYLE |
| 2125 | (either SYNTAX_FLAGS_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). | 2228 | (either SYNTAX_FLAGS_COMMENT_STYLE (foo) or ST_COMMENT_STYLE). |
| 2126 | NESTING should be positive to indicate the nesting at the beginning | 2229 | NESTING should be positive to indicate the nesting at the beginning |
| 2127 | for nested comments and should be zero or negative else. | 2230 | for nested comments and should be zero or negative else. |
| 2128 | ST_COMMENT_STYLE cannot be nested. | 2231 | ST_COMMENT_STYLE cannot be nested. |
| 2129 | PREV_SYNTAX is the SYNTAX_WITH_FLAGS of the previous character | 2232 | PREV_SYNTAX is the SYNTAX_WITH_FLAGS of the previous character |
| 2130 | (or 0 If the search cannot start in the middle of a two-character). | 2233 | (or 0 If the search cannot start in the middle of a two-character). |
| 2131 | 2234 | ||
| 2132 | If successful, return 1 and store the charpos of the comment's end | 2235 | If successful, return true and store the charpos of the comment's end |
| 2133 | into *CHARPOS_PTR and the corresponding bytepos into *BYTEPOS_PTR. | 2236 | into *CHARPOS_PTR and the corresponding bytepos into *BYTEPOS_PTR. |
| 2134 | Else, return 0 and store the charpos STOP into *CHARPOS_PTR, the | 2237 | Else, return false and store the charpos STOP into *CHARPOS_PTR, the |
| 2135 | corresponding bytepos into *BYTEPOS_PTR and the current nesting | 2238 | corresponding bytepos into *BYTEPOS_PTR and the current nesting |
| 2136 | (as defined for state.incomment) in *INCOMMENT_PTR. | 2239 | (as defined for state.incomment) in *INCOMMENT_PTR. |
| 2137 | 2240 | ||
| 2138 | The comment end is the last character of the comment rather than the | 2241 | The comment end is the last character of the comment rather than the |
| 2139 | character just after the comment. | 2242 | character just after the comment. |
| 2140 | 2243 | ||
| 2141 | Global syntax data is assumed to initially be valid for FROM and | 2244 | Global syntax data is assumed to initially be valid for FROM and |
| 2142 | remains valid for forward search starting at the returned position. */ | 2245 | remains valid for forward search starting at the returned position. */ |
| 2143 | 2246 | ||
| 2144 | static int | 2247 | static bool |
| 2145 | forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | 2248 | forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, |
| 2146 | EMACS_INT nesting, int style, int prev_syntax, | 2249 | EMACS_INT nesting, int style, int prev_syntax, |
| 2147 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, | 2250 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, |
| @@ -2247,14 +2350,12 @@ If COUNT comments are found as expected, with nothing except whitespace | |||
| 2247 | between them, return t; otherwise return nil. */) | 2350 | between them, return t; otherwise return nil. */) |
| 2248 | (Lisp_Object count) | 2351 | (Lisp_Object count) |
| 2249 | { | 2352 | { |
| 2250 | register ptrdiff_t from; | 2353 | ptrdiff_t from, from_byte, stop; |
| 2251 | ptrdiff_t from_byte; | 2354 | int c, c1; |
| 2252 | register ptrdiff_t stop; | 2355 | enum syntaxcode code; |
| 2253 | register int c, c1; | ||
| 2254 | register enum syntaxcode code; | ||
| 2255 | int comstyle = 0; /* style of comment encountered */ | 2356 | int comstyle = 0; /* style of comment encountered */ |
| 2256 | int comnested = 0; /* whether the comment is nestable or not */ | 2357 | bool comnested = 0; /* whether the comment is nestable or not */ |
| 2257 | int found; | 2358 | bool found; |
| 2258 | EMACS_INT count1; | 2359 | EMACS_INT count1; |
| 2259 | ptrdiff_t out_charpos, out_bytepos; | 2360 | ptrdiff_t out_charpos, out_bytepos; |
| 2260 | EMACS_INT dummy; | 2361 | EMACS_INT dummy; |
| @@ -2274,7 +2375,8 @@ between them, return t; otherwise return nil. */) | |||
| 2274 | { | 2375 | { |
| 2275 | do | 2376 | do |
| 2276 | { | 2377 | { |
| 2277 | int comstart_first, syntax, other_syntax; | 2378 | bool comstart_first; |
| 2379 | int syntax, other_syntax; | ||
| 2278 | 2380 | ||
| 2279 | if (from == stop) | 2381 | if (from == stop) |
| 2280 | { | 2382 | { |
| @@ -2302,8 +2404,7 @@ between them, return t; otherwise return nil. */) | |||
| 2302 | the comment section. */ | 2404 | the comment section. */ |
| 2303 | code = Scomment; | 2405 | code = Scomment; |
| 2304 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); | 2406 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2305 | comnested | 2407 | comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); |
| 2306 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2307 | INC_BOTH (from, from_byte); | 2408 | INC_BOTH (from, from_byte); |
| 2308 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2409 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2309 | } | 2410 | } |
| @@ -2339,7 +2440,8 @@ between them, return t; otherwise return nil. */) | |||
| 2339 | { | 2440 | { |
| 2340 | while (1) | 2441 | while (1) |
| 2341 | { | 2442 | { |
| 2342 | int quoted, syntax; | 2443 | bool quoted; |
| 2444 | int syntax; | ||
| 2343 | 2445 | ||
| 2344 | if (from <= stop) | 2446 | if (from <= stop) |
| 2345 | { | 2447 | { |
| @@ -2373,14 +2475,13 @@ between them, return t; otherwise return nil. */) | |||
| 2373 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2475 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2374 | other_syntax = SYNTAX_WITH_FLAGS (c1); | 2476 | other_syntax = SYNTAX_WITH_FLAGS (c1); |
| 2375 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); | 2477 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2376 | comnested | 2478 | comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); |
| 2377 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2378 | } | 2479 | } |
| 2379 | 2480 | ||
| 2380 | if (code == Scomment_fence) | 2481 | if (code == Scomment_fence) |
| 2381 | { | 2482 | { |
| 2382 | /* Skip until first preceding unquoted comment_fence. */ | 2483 | /* Skip until first preceding unquoted comment_fence. */ |
| 2383 | int fence_found = 0; | 2484 | bool fence_found = 0; |
| 2384 | ptrdiff_t ini = from, ini_byte = from_byte; | 2485 | ptrdiff_t ini = from, ini_byte = from_byte; |
| 2385 | 2486 | ||
| 2386 | while (1) | 2487 | while (1) |
| @@ -2411,7 +2512,7 @@ between them, return t; otherwise return nil. */) | |||
| 2411 | { | 2512 | { |
| 2412 | found = back_comment (from, from_byte, stop, comnested, comstyle, | 2513 | found = back_comment (from, from_byte, stop, comnested, comstyle, |
| 2413 | &out_charpos, &out_bytepos); | 2514 | &out_charpos, &out_bytepos); |
| 2414 | if (found == -1) | 2515 | if (!found) |
| 2415 | { | 2516 | { |
| 2416 | if (c == '\n') | 2517 | if (c == '\n') |
| 2417 | /* This end-of-line is not an end-of-comment. | 2518 | /* This end-of-line is not an end-of-comment. |
| @@ -2454,33 +2555,34 @@ between them, return t; otherwise return nil. */) | |||
| 2454 | } | 2555 | } |
| 2455 | 2556 | ||
| 2456 | /* Return syntax code of character C if C is an ASCII character | 2557 | /* Return syntax code of character C if C is an ASCII character |
| 2457 | or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */ | 2558 | or if MULTIBYTE_SYMBOL_P is false. Otherwise, return Ssymbol. */ |
| 2458 | 2559 | ||
| 2459 | #define SYNTAX_WITH_MULTIBYTE_CHECK(c) \ | 2560 | static enum syntaxcode |
| 2460 | ((ASCII_CHAR_P (c) || !multibyte_symbol_p) \ | 2561 | syntax_multibyte (int c, bool multibyte_symbol_p) |
| 2461 | ? SYNTAX (c) : Ssymbol) | 2562 | { |
| 2563 | return ASCII_CHAR_P (c) || !multibyte_symbol_p ? SYNTAX (c) : Ssymbol; | ||
| 2564 | } | ||
| 2462 | 2565 | ||
| 2463 | static Lisp_Object | 2566 | static Lisp_Object |
| 2464 | scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpflag) | 2567 | scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) |
| 2465 | { | 2568 | { |
| 2466 | Lisp_Object val; | 2569 | Lisp_Object val; |
| 2467 | register ptrdiff_t stop = count > 0 ? ZV : BEGV; | 2570 | ptrdiff_t stop = count > 0 ? ZV : BEGV; |
| 2468 | register int c, c1; | 2571 | int c, c1; |
| 2469 | int stringterm; | 2572 | int stringterm; |
| 2470 | int quoted; | 2573 | bool quoted; |
| 2471 | int mathexit = 0; | 2574 | bool mathexit = 0; |
| 2472 | register enum syntaxcode code, temp_code; | 2575 | enum syntaxcode code; |
| 2473 | EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */ | 2576 | EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */ |
| 2474 | int comstyle = 0; /* style of comment encountered */ | 2577 | int comstyle = 0; /* style of comment encountered */ |
| 2475 | int comnested = 0; /* whether the comment is nestable or not */ | 2578 | bool comnested = 0; /* whether the comment is nestable or not */ |
| 2476 | ptrdiff_t temp_pos; | 2579 | ptrdiff_t temp_pos; |
| 2477 | EMACS_INT last_good = from; | 2580 | EMACS_INT last_good = from; |
| 2478 | int found; | 2581 | bool found; |
| 2479 | ptrdiff_t from_byte; | 2582 | ptrdiff_t from_byte; |
| 2480 | ptrdiff_t out_bytepos, out_charpos; | 2583 | ptrdiff_t out_bytepos, out_charpos; |
| 2481 | int temp; | ||
| 2482 | EMACS_INT dummy; | 2584 | EMACS_INT dummy; |
| 2483 | int multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; | 2585 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; |
| 2484 | 2586 | ||
| 2485 | if (depth > 0) min_depth = 0; | 2587 | if (depth > 0) min_depth = 0; |
| 2486 | 2588 | ||
| @@ -2497,11 +2599,12 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2497 | { | 2599 | { |
| 2498 | while (from < stop) | 2600 | while (from < stop) |
| 2499 | { | 2601 | { |
| 2500 | int comstart_first, prefix, syntax, other_syntax; | 2602 | bool comstart_first, prefix; |
| 2603 | int syntax, other_syntax; | ||
| 2501 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2604 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2502 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2605 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2503 | syntax = SYNTAX_WITH_FLAGS (c); | 2606 | syntax = SYNTAX_WITH_FLAGS (c); |
| 2504 | code = SYNTAX_WITH_MULTIBYTE_CHECK (c); | 2607 | code = syntax_multibyte (c, multibyte_symbol_p); |
| 2505 | comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); | 2608 | comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); |
| 2506 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); | 2609 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| 2507 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); | 2610 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); |
| @@ -2523,8 +2626,7 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2523 | the comment section */ | 2626 | the comment section */ |
| 2524 | code = Scomment; | 2627 | code = Scomment; |
| 2525 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); | 2628 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2526 | comnested | 2629 | comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); |
| 2527 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2528 | INC_BOTH (from, from_byte); | 2630 | INC_BOTH (from, from_byte); |
| 2529 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2631 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2530 | } | 2632 | } |
| @@ -2548,10 +2650,8 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2548 | { | 2650 | { |
| 2549 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2651 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2550 | 2652 | ||
| 2551 | /* Some compilers can't handle this inside the switch. */ | ||
| 2552 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2653 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2553 | temp = SYNTAX_WITH_MULTIBYTE_CHECK (c); | 2654 | switch (syntax_multibyte (c, multibyte_symbol_p)) |
| 2554 | switch (temp) | ||
| 2555 | { | 2655 | { |
| 2556 | case Scharquote: | 2656 | case Scharquote: |
| 2557 | case Sescape: | 2657 | case Sescape: |
| @@ -2623,19 +2723,18 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2623 | stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos); | 2723 | stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos); |
| 2624 | while (1) | 2724 | while (1) |
| 2625 | { | 2725 | { |
| 2726 | enum syntaxcode c_code; | ||
| 2626 | if (from >= stop) | 2727 | if (from >= stop) |
| 2627 | goto lose; | 2728 | goto lose; |
| 2628 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2729 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2629 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2730 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2731 | c_code = syntax_multibyte (c, multibyte_symbol_p); | ||
| 2630 | if (code == Sstring | 2732 | if (code == Sstring |
| 2631 | ? (c == stringterm | 2733 | ? c == stringterm && c_code == Sstring |
| 2632 | && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) | 2734 | : c_code == Sstring_fence) |
| 2633 | : SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring_fence) | ||
| 2634 | break; | 2735 | break; |
| 2635 | 2736 | ||
| 2636 | /* Some compilers can't handle this inside the switch. */ | 2737 | switch (c_code) |
| 2637 | temp = SYNTAX_WITH_MULTIBYTE_CHECK (c); | ||
| 2638 | switch (temp) | ||
| 2639 | { | 2738 | { |
| 2640 | case Scharquote: | 2739 | case Scharquote: |
| 2641 | case Sescape: | 2740 | case Sescape: |
| @@ -2673,7 +2772,7 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2673 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2772 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2674 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2773 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2675 | syntax= SYNTAX_WITH_FLAGS (c); | 2774 | syntax= SYNTAX_WITH_FLAGS (c); |
| 2676 | code = SYNTAX_WITH_MULTIBYTE_CHECK (c); | 2775 | code = syntax_multibyte (c, multibyte_symbol_p); |
| 2677 | if (depth == min_depth) | 2776 | if (depth == min_depth) |
| 2678 | last_good = from; | 2777 | last_good = from; |
| 2679 | comstyle = 0; | 2778 | comstyle = 0; |
| @@ -2694,8 +2793,7 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2694 | c2 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2793 | c2 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2695 | other_syntax = SYNTAX_WITH_FLAGS (c2); | 2794 | other_syntax = SYNTAX_WITH_FLAGS (c2); |
| 2696 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); | 2795 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2697 | comnested | 2796 | comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); |
| 2698 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2699 | } | 2797 | } |
| 2700 | 2798 | ||
| 2701 | /* Quoting turns anything except a comment-ender | 2799 | /* Quoting turns anything except a comment-ender |
| @@ -2727,9 +2825,8 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2727 | temp_pos--; | 2825 | temp_pos--; |
| 2728 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 2826 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 2729 | c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); | 2827 | c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); |
| 2730 | temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); | ||
| 2731 | /* Don't allow comment-end to be quoted. */ | 2828 | /* Don't allow comment-end to be quoted. */ |
| 2732 | if (temp_code == Sendcomment) | 2829 | if (syntax_multibyte (c1, multibyte_symbol_p) == Sendcomment) |
| 2733 | goto done2; | 2830 | goto done2; |
| 2734 | quoted = char_quoted (from - 1, temp_pos); | 2831 | quoted = char_quoted (from - 1, temp_pos); |
| 2735 | if (quoted) | 2832 | if (quoted) |
| @@ -2739,11 +2836,12 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2739 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); | 2836 | UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
| 2740 | } | 2837 | } |
| 2741 | c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); | 2838 | c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); |
| 2742 | temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); | 2839 | if (! quoted) |
| 2743 | if (! (quoted || temp_code == Sword | 2840 | switch (syntax_multibyte (c1, multibyte_symbol_p)) |
| 2744 | || temp_code == Ssymbol | 2841 | { |
| 2745 | || temp_code == Squote)) | 2842 | case Sword: case Ssymbol: case Squote: break; |
| 2746 | goto done2; | 2843 | default: goto done2; |
| 2844 | } | ||
| 2747 | DEC_BOTH (from, from_byte); | 2845 | DEC_BOTH (from, from_byte); |
| 2748 | } | 2846 | } |
| 2749 | goto done2; | 2847 | goto done2; |
| @@ -2780,13 +2878,13 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2780 | break; | 2878 | break; |
| 2781 | found = back_comment (from, from_byte, stop, comnested, comstyle, | 2879 | found = back_comment (from, from_byte, stop, comnested, comstyle, |
| 2782 | &out_charpos, &out_bytepos); | 2880 | &out_charpos, &out_bytepos); |
| 2783 | /* FIXME: if found == -1, then it really wasn't a comment-end. | 2881 | /* FIXME: if !found, it really wasn't a comment-end. |
| 2784 | For single-char Sendcomment, we can't do much about it apart | 2882 | For single-char Sendcomment, we can't do much about it apart |
| 2785 | from skipping the char. | 2883 | from skipping the char. |
| 2786 | For 2-char endcomments, we could try again, taking both | 2884 | For 2-char endcomments, we could try again, taking both |
| 2787 | chars as separate entities, but it's a lot of trouble | 2885 | chars as separate entities, but it's a lot of trouble |
| 2788 | for very little gain, so we don't bother either. -sm */ | 2886 | for very little gain, so we don't bother either. -sm */ |
| 2789 | if (found != -1) | 2887 | if (found) |
| 2790 | from = out_charpos, from_byte = out_bytepos; | 2888 | from = out_charpos, from_byte = out_bytepos; |
| 2791 | break; | 2889 | break; |
| 2792 | 2890 | ||
| @@ -2798,10 +2896,12 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2798 | goto lose; | 2896 | goto lose; |
| 2799 | DEC_BOTH (from, from_byte); | 2897 | DEC_BOTH (from, from_byte); |
| 2800 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2898 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2801 | if (!char_quoted (from, from_byte) | 2899 | if (!char_quoted (from, from_byte)) |
| 2802 | && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), | 2900 | { |
| 2803 | SYNTAX_WITH_MULTIBYTE_CHECK (c) == code)) | 2901 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2804 | break; | 2902 | if (syntax_multibyte (c, multibyte_symbol_p) == code) |
| 2903 | break; | ||
| 2904 | } | ||
| 2805 | } | 2905 | } |
| 2806 | if (code == Sstring_fence && !depth && sexpflag) goto done2; | 2906 | if (code == Sstring_fence && !depth && sexpflag) goto done2; |
| 2807 | break; | 2907 | break; |
| @@ -2814,11 +2914,14 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2814 | goto lose; | 2914 | goto lose; |
| 2815 | DEC_BOTH (from, from_byte); | 2915 | DEC_BOTH (from, from_byte); |
| 2816 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2916 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2817 | if (!char_quoted (from, from_byte) | 2917 | if (!char_quoted (from, from_byte)) |
| 2818 | && (stringterm | 2918 | { |
| 2819 | == (c = FETCH_CHAR_AS_MULTIBYTE (from_byte))) | 2919 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2820 | && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) | 2920 | if (c == stringterm |
| 2821 | break; | 2921 | && (syntax_multibyte (c, multibyte_symbol_p) |
| 2922 | == Sstring)) | ||
| 2923 | break; | ||
| 2924 | } | ||
| 2822 | } | 2925 | } |
| 2823 | if (!depth && sexpflag) goto done2; | 2926 | if (!depth && sexpflag) goto done2; |
| 2824 | break; | 2927 | break; |
| @@ -2924,7 +3027,7 @@ This includes chars with "quote" or "prefix" syntax (' or p). */) | |||
| 2924 | while (!char_quoted (pos, pos_byte) | 3027 | while (!char_quoted (pos, pos_byte) |
| 2925 | /* Previous statement updates syntax table. */ | 3028 | /* Previous statement updates syntax table. */ |
| 2926 | && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote) | 3029 | && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote) |
| 2927 | || SYNTAX_PREFIX (c))) | 3030 | || syntax_prefix_flag_p (c))) |
| 2928 | { | 3031 | { |
| 2929 | opoint = pos; | 3032 | opoint = pos; |
| 2930 | opoint_byte = pos_byte; | 3033 | opoint_byte = pos_byte; |
| @@ -2941,7 +3044,7 @@ This includes chars with "quote" or "prefix" syntax (' or p). */) | |||
| 2941 | /* Parse forward from FROM / FROM_BYTE to END, | 3044 | /* Parse forward from FROM / FROM_BYTE to END, |
| 2942 | assuming that FROM has state OLDSTATE (nil means FROM is start of function), | 3045 | assuming that FROM has state OLDSTATE (nil means FROM is start of function), |
| 2943 | and return a description of the state of the parse at END. | 3046 | and return a description of the state of the parse at END. |
| 2944 | If STOPBEFORE is nonzero, stop at the start of an atom. | 3047 | If STOPBEFORE, stop at the start of an atom. |
| 2945 | If COMMENTSTOP is 1, stop at the start of a comment. | 3048 | If COMMENTSTOP is 1, stop at the start of a comment. |
| 2946 | If COMMENTSTOP is -1, stop at the start or end of a comment, | 3049 | If COMMENTSTOP is -1, stop at the start or end of a comment, |
| 2947 | after the beginning of a string, or after the end of a string. */ | 3050 | after the beginning of a string, or after the end of a string. */ |
| @@ -2949,30 +3052,29 @@ This includes chars with "quote" or "prefix" syntax (' or p). */) | |||
| 2949 | static void | 3052 | static void |
| 2950 | scan_sexps_forward (struct lisp_parse_state *stateptr, | 3053 | scan_sexps_forward (struct lisp_parse_state *stateptr, |
| 2951 | ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t end, | 3054 | ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t end, |
| 2952 | EMACS_INT targetdepth, int stopbefore, | 3055 | EMACS_INT targetdepth, bool stopbefore, |
| 2953 | Lisp_Object oldstate, int commentstop) | 3056 | Lisp_Object oldstate, int commentstop) |
| 2954 | { | 3057 | { |
| 2955 | struct lisp_parse_state state; | 3058 | struct lisp_parse_state state; |
| 2956 | 3059 | enum syntaxcode code; | |
| 2957 | register enum syntaxcode code; | ||
| 2958 | int c1; | 3060 | int c1; |
| 2959 | int comnested; | 3061 | bool comnested; |
| 2960 | struct level { ptrdiff_t last, prev; }; | 3062 | struct level { ptrdiff_t last, prev; }; |
| 2961 | struct level levelstart[100]; | 3063 | struct level levelstart[100]; |
| 2962 | register struct level *curlevel = levelstart; | 3064 | struct level *curlevel = levelstart; |
| 2963 | struct level *endlevel = levelstart + 100; | 3065 | struct level *endlevel = levelstart + 100; |
| 2964 | register EMACS_INT depth; /* Paren depth of current scanning location. | 3066 | EMACS_INT depth; /* Paren depth of current scanning location. |
| 2965 | level - levelstart equals this except | 3067 | level - levelstart equals this except |
| 2966 | when the depth becomes negative. */ | 3068 | when the depth becomes negative. */ |
| 2967 | EMACS_INT mindepth; /* Lowest DEPTH value seen. */ | 3069 | EMACS_INT mindepth; /* Lowest DEPTH value seen. */ |
| 2968 | int start_quoted = 0; /* Nonzero means starting after a char quote */ | 3070 | bool start_quoted = 0; /* True means starting after a char quote. */ |
| 2969 | Lisp_Object tem; | 3071 | Lisp_Object tem; |
| 2970 | ptrdiff_t prev_from; /* Keep one character before FROM. */ | 3072 | ptrdiff_t prev_from; /* Keep one character before FROM. */ |
| 2971 | ptrdiff_t prev_from_byte; | 3073 | ptrdiff_t prev_from_byte; |
| 2972 | int prev_from_syntax; | 3074 | int prev_from_syntax; |
| 2973 | int boundary_stop = commentstop == -1; | 3075 | bool boundary_stop = commentstop == -1; |
| 2974 | int nofence; | 3076 | bool nofence; |
| 2975 | int found; | 3077 | bool found; |
| 2976 | ptrdiff_t out_bytepos, out_charpos; | 3078 | ptrdiff_t out_bytepos, out_charpos; |
| 2977 | int temp; | 3079 | int temp; |
| 2978 | 3080 | ||
| @@ -3103,8 +3205,8 @@ do { prev_from = from; \ | |||
| 3103 | terminates the comment section. */ | 3205 | terminates the comment section. */ |
| 3104 | state.comstyle | 3206 | state.comstyle |
| 3105 | = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); | 3207 | = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); |
| 3106 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax); | 3208 | comnested = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) |
| 3107 | comnested = comnested || SYNTAX_FLAGS_COMMENT_NESTED (syntax); | 3209 | | SYNTAX_FLAGS_COMMENT_NESTED (syntax)); |
| 3108 | state.incomment = comnested ? 1 : -1; | 3210 | state.incomment = comnested ? 1 : -1; |
| 3109 | state.comstr_start = prev_from; | 3211 | state.comstr_start = prev_from; |
| 3110 | INC_FROM; | 3212 | INC_FROM; |
| @@ -3148,10 +3250,8 @@ do { prev_from = from; \ | |||
| 3148 | symstarted: | 3250 | symstarted: |
| 3149 | while (from < end) | 3251 | while (from < end) |
| 3150 | { | 3252 | { |
| 3151 | /* Some compilers can't handle this inside the switch. */ | 3253 | int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 3152 | temp = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 3254 | switch (SYNTAX (symchar)) |
| 3153 | temp = SYNTAX (temp); | ||
| 3154 | switch (temp) | ||
| 3155 | { | 3255 | { |
| 3156 | case Scharquote: | 3256 | case Scharquote: |
| 3157 | case Sescape: | 3257 | case Sescape: |
| @@ -3233,19 +3333,19 @@ do { prev_from = from; \ | |||
| 3233 | while (1) | 3333 | while (1) |
| 3234 | { | 3334 | { |
| 3235 | int c; | 3335 | int c; |
| 3336 | enum syntaxcode c_code; | ||
| 3236 | 3337 | ||
| 3237 | if (from >= end) goto done; | 3338 | if (from >= end) goto done; |
| 3238 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 3339 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 3239 | /* Some compilers can't handle this inside the switch. */ | 3340 | c_code = SYNTAX (c); |
| 3240 | temp = SYNTAX (c); | ||
| 3241 | 3341 | ||
| 3242 | /* Check TEMP here so that if the char has | 3342 | /* Check C_CODE here so that if the char has |
| 3243 | a syntax-table property which says it is NOT | 3343 | a syntax-table property which says it is NOT |
| 3244 | a string character, it does not end the string. */ | 3344 | a string character, it does not end the string. */ |
| 3245 | if (nofence && c == state.instring && temp == Sstring) | 3345 | if (nofence && c == state.instring && c_code == Sstring) |
| 3246 | break; | 3346 | break; |
| 3247 | 3347 | ||
| 3248 | switch (temp) | 3348 | switch (c_code) |
| 3249 | { | 3349 | { |
| 3250 | case Sstring_fence: | 3350 | case Sstring_fence: |
| 3251 | if (!nofence) goto string_end; | 3351 | if (!nofence) goto string_end; |
| @@ -3387,9 +3487,9 @@ init_syntax_once (void) | |||
| 3387 | /* This has to be done here, before we call Fmake_char_table. */ | 3487 | /* This has to be done here, before we call Fmake_char_table. */ |
| 3388 | DEFSYM (Qsyntax_table, "syntax-table"); | 3488 | DEFSYM (Qsyntax_table, "syntax-table"); |
| 3389 | 3489 | ||
| 3390 | /* Intern_C_String this now in case it isn't already done. | 3490 | /* This variable is DEFSYMed in alloc.c and not initialized yet, so |
| 3391 | Setting this variable twice is harmless. | 3491 | intern it here. NOTE: you must guarantee that init_syntax_once |
| 3392 | But don't staticpro it here--that is done in alloc.c. */ | 3492 | is called before all other users of this variable. */ |
| 3393 | Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); | 3493 | Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); |
| 3394 | 3494 | ||
| 3395 | /* Create objects which can be shared among syntax tables. */ | 3495 | /* Create objects which can be shared among syntax tables. */ |
| @@ -3401,25 +3501,25 @@ init_syntax_once (void) | |||
| 3401 | create syntax tables. */ | 3501 | create syntax tables. */ |
| 3402 | Fput (Qsyntax_table, Qchar_table_extra_slots, make_number (0)); | 3502 | Fput (Qsyntax_table, Qchar_table_extra_slots, make_number (0)); |
| 3403 | 3503 | ||
| 3404 | temp = AREF (Vsyntax_code_object, (int) Swhitespace); | 3504 | temp = AREF (Vsyntax_code_object, Swhitespace); |
| 3405 | 3505 | ||
| 3406 | Vstandard_syntax_table = Fmake_char_table (Qsyntax_table, temp); | 3506 | Vstandard_syntax_table = Fmake_char_table (Qsyntax_table, temp); |
| 3407 | 3507 | ||
| 3408 | /* Control characters should not be whitespace. */ | 3508 | /* Control characters should not be whitespace. */ |
| 3409 | temp = AREF (Vsyntax_code_object, (int) Spunct); | 3509 | temp = AREF (Vsyntax_code_object, Spunct); |
| 3410 | for (i = 0; i <= ' ' - 1; i++) | 3510 | for (i = 0; i <= ' ' - 1; i++) |
| 3411 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); | 3511 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 3412 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, 0177, temp); | 3512 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, 0177, temp); |
| 3413 | 3513 | ||
| 3414 | /* Except that a few really are whitespace. */ | 3514 | /* Except that a few really are whitespace. */ |
| 3415 | temp = AREF (Vsyntax_code_object, (int) Swhitespace); | 3515 | temp = AREF (Vsyntax_code_object, Swhitespace); |
| 3416 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ' ', temp); | 3516 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ' ', temp); |
| 3417 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\t', temp); | 3517 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\t', temp); |
| 3418 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\n', temp); | 3518 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\n', temp); |
| 3419 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, 015, temp); | 3519 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, 015, temp); |
| 3420 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, 014, temp); | 3520 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, 014, temp); |
| 3421 | 3521 | ||
| 3422 | temp = AREF (Vsyntax_code_object, (int) Sword); | 3522 | temp = AREF (Vsyntax_code_object, Sword); |
| 3423 | for (i = 'a'; i <= 'z'; i++) | 3523 | for (i = 'a'; i <= 'z'; i++) |
| 3424 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); | 3524 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 3425 | for (i = 'A'; i <= 'Z'; i++) | 3525 | for (i = 'A'; i <= 'Z'; i++) |
| @@ -3443,18 +3543,18 @@ init_syntax_once (void) | |||
| 3443 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '}', | 3543 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '}', |
| 3444 | Fcons (make_number (Sclose), make_number ('{'))); | 3544 | Fcons (make_number (Sclose), make_number ('{'))); |
| 3445 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '"', | 3545 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '"', |
| 3446 | Fcons (make_number ((int) Sstring), Qnil)); | 3546 | Fcons (make_number (Sstring), Qnil)); |
| 3447 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', | 3547 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', |
| 3448 | Fcons (make_number ((int) Sescape), Qnil)); | 3548 | Fcons (make_number (Sescape), Qnil)); |
| 3449 | 3549 | ||
| 3450 | temp = AREF (Vsyntax_code_object, (int) Ssymbol); | 3550 | temp = AREF (Vsyntax_code_object, Ssymbol); |
| 3451 | for (i = 0; i < 10; i++) | 3551 | for (i = 0; i < 10; i++) |
| 3452 | { | 3552 | { |
| 3453 | c = "_-+*/&|<>="[i]; | 3553 | c = "_-+*/&|<>="[i]; |
| 3454 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, c, temp); | 3554 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, c, temp); |
| 3455 | } | 3555 | } |
| 3456 | 3556 | ||
| 3457 | temp = AREF (Vsyntax_code_object, (int) Spunct); | 3557 | temp = AREF (Vsyntax_code_object, Spunct); |
| 3458 | for (i = 0; i < 12; i++) | 3558 | for (i = 0; i < 12; i++) |
| 3459 | { | 3559 | { |
| 3460 | c = ".,;:?!#@~^'`"[i]; | 3560 | c = ".,;:?!#@~^'`"[i]; |
| @@ -3462,7 +3562,7 @@ init_syntax_once (void) | |||
| 3462 | } | 3562 | } |
| 3463 | 3563 | ||
| 3464 | /* All multibyte characters have syntax `word' by default. */ | 3564 | /* All multibyte characters have syntax `word' by default. */ |
| 3465 | temp = AREF (Vsyntax_code_object, (int) Sword); | 3565 | temp = AREF (Vsyntax_code_object, Sword); |
| 3466 | char_table_set_range (Vstandard_syntax_table, 0x80, MAX_CHAR, temp); | 3566 | char_table_set_range (Vstandard_syntax_table, 0x80, MAX_CHAR, temp); |
| 3467 | } | 3567 | } |
| 3468 | 3568 | ||