diff options
| author | Richard M. Stallman | 1995-10-07 21:59:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-10-07 21:59:28 +0000 |
| commit | 8ea151b23b874bc3802fc228d828cf91b9cf5ffb (patch) | |
| tree | fa764c1272fb06e33ee6dea452812656649aa320 /src | |
| parent | e46c910e4a464d0ec115a66f1810a8dea1f1502b (diff) | |
| download | emacs-8ea151b23b874bc3802fc228d828cf91b9cf5ffb.tar.gz emacs-8ea151b23b874bc3802fc228d828cf91b9cf5ffb.zip | |
(describe_syntax): Handle new syntax-table data format.
(Fmodify_syntax_entry, init_syntax_once): Use SET_RAW_SYNTAX_ENTRY.
Handle new syntax-table data format.
(check_syntax_table): Use CHECK_CHAR_TABLE. Now static.
Don't return anything; callers changed.
(Fcopy_syntax_table): Use Fcopy_sequence.
(Fchar_syntax, Fmatching_paren, Fforward_comment): Copy complex args
to SYNTAX into variables before using them.
(Fsyntax_table_p): Accept any char-table.
(syntax_parent_lookup): New function.
(syntax_temp): New variable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax.c | 231 |
1 files changed, 147 insertions, 84 deletions
diff --git a/src/syntax.c b/src/syntax.c index 34f76d76a4a..709f8a93f67 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -32,6 +32,11 @@ static int char_quoted (); | |||
| 32 | 32 | ||
| 33 | int words_include_escapes; | 33 | int words_include_escapes; |
| 34 | 34 | ||
| 35 | /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, | ||
| 36 | if not compiled with GCC. No need to mark it, since it is used | ||
| 37 | only very temporarily. */ | ||
| 38 | Lisp_Object syntax_temp; | ||
| 39 | |||
| 35 | /* This is the internal form of the parse state used in parse-partial-sexp. */ | 40 | /* This is the internal form of the parse state used in parse-partial-sexp. */ |
| 36 | 41 | ||
| 37 | struct lisp_parse_state | 42 | struct lisp_parse_state |
| @@ -107,24 +112,20 @@ find_defun_start (pos) | |||
| 107 | 112 | ||
| 108 | DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, | 113 | DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, |
| 109 | "Return t if ARG is a syntax table.\n\ | 114 | "Return t if ARG is a syntax table.\n\ |
| 110 | Any vector of 256 elements will do.") | 115 | Currently, any char-table counts as a syntax table.") |
| 111 | (obj) | 116 | (obj) |
| 112 | Lisp_Object obj; | 117 | Lisp_Object obj; |
| 113 | { | 118 | { |
| 114 | if (VECTORP (obj) && XVECTOR (obj)->size == 0400) | 119 | if (CHAR_TABLE_P (obj)) |
| 115 | return Qt; | 120 | return Qt; |
| 116 | return Qnil; | 121 | return Qnil; |
| 117 | } | 122 | } |
| 118 | 123 | ||
| 119 | Lisp_Object | 124 | static void |
| 120 | check_syntax_table (obj) | 125 | check_syntax_table (obj) |
| 121 | Lisp_Object obj; | 126 | Lisp_Object obj; |
| 122 | { | 127 | { |
| 123 | register Lisp_Object tem; | 128 | CHECK_CHAR_TABLE (obj, 0); |
| 124 | while (tem = Fsyntax_table_p (obj), | ||
| 125 | NILP (tem)) | ||
| 126 | obj = wrong_type_argument (Qsyntax_table_p, obj); | ||
| 127 | return obj; | ||
| 128 | } | 129 | } |
| 129 | 130 | ||
| 130 | 131 | ||
| @@ -151,20 +152,16 @@ It is a copy of the TABLE, which defaults to the standard syntax table.") | |||
| 151 | (table) | 152 | (table) |
| 152 | Lisp_Object table; | 153 | Lisp_Object table; |
| 153 | { | 154 | { |
| 154 | Lisp_Object size, val; | 155 | Lisp_Object copy; |
| 155 | XSETFASTINT (size, 0400); | 156 | |
| 156 | XSETFASTINT (val, 0); | ||
| 157 | val = Fmake_vector (size, val); | ||
| 158 | if (!NILP (table)) | 157 | if (!NILP (table)) |
| 159 | table = check_syntax_table (table); | 158 | check_syntax_table (table); |
| 160 | else if (NILP (Vstandard_syntax_table)) | 159 | else |
| 161 | /* Can only be null during initialization */ | 160 | table = Vstandard_syntax_table; |
| 162 | return val; | 161 | |
| 163 | else table = Vstandard_syntax_table; | 162 | copy = Fcopy_sequence (table); |
| 164 | 163 | Fset_char_table_parent (copy, Vstandard_syntax_table); | |
| 165 | bcopy (XVECTOR (table)->contents, | 164 | return copy; |
| 166 | XVECTOR (val)->contents, 0400 * sizeof (Lisp_Object)); | ||
| 167 | return val; | ||
| 168 | } | 165 | } |
| 169 | 166 | ||
| 170 | DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, | 167 | DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, |
| @@ -173,7 +170,7 @@ One argument, a syntax table.") | |||
| 173 | (table) | 170 | (table) |
| 174 | Lisp_Object table; | 171 | Lisp_Object table; |
| 175 | { | 172 | { |
| 176 | table = check_syntax_table (table); | 173 | check_syntax_table (table); |
| 177 | current_buffer->syntax_table = table; | 174 | current_buffer->syntax_table = table; |
| 178 | /* Indicate that this buffer now has a specified syntax table. */ | 175 | /* Indicate that this buffer now has a specified syntax table. */ |
| 179 | current_buffer->local_var_flags | 176 | current_buffer->local_var_flags |
| @@ -214,6 +211,29 @@ char syntax_code_spec[14] = | |||
| 214 | ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' | 211 | ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' |
| 215 | }; | 212 | }; |
| 216 | 213 | ||
| 214 | /* Look up the value for CHARACTER in syntax table TABLE's parent | ||
| 215 | and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil | ||
| 216 | for CHARACTER. It's actually used only when not compiled with GCC. */ | ||
| 217 | |||
| 218 | Lisp_Object | ||
| 219 | syntax_parent_lookup (table, character) | ||
| 220 | Lisp_Object table; | ||
| 221 | int character; | ||
| 222 | { | ||
| 223 | Lisp_Object value; | ||
| 224 | |||
| 225 | while (1) | ||
| 226 | { | ||
| 227 | table = XCHAR_TABLE (table)->parent; | ||
| 228 | if (NILP (table)) | ||
| 229 | return Qnil; | ||
| 230 | |||
| 231 | value = XCHAR_TABLE (table)->contents[character]; | ||
| 232 | if (!NILP (value)) | ||
| 233 | return value; | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 217 | DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0, | 237 | DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0, |
| 218 | "Return the syntax code of CHAR, described by a character.\n\ | 238 | "Return the syntax code of CHAR, described by a character.\n\ |
| 219 | For example, if CHAR is a word constituent, the character `?w' is returned.\n\ | 239 | For example, if CHAR is a word constituent, the character `?w' is returned.\n\ |
| @@ -222,8 +242,10 @@ are listed in the documentation of `modify-syntax-entry'.") | |||
| 222 | (ch) | 242 | (ch) |
| 223 | Lisp_Object ch; | 243 | Lisp_Object ch; |
| 224 | { | 244 | { |
| 245 | int char_int; | ||
| 225 | CHECK_NUMBER (ch, 0); | 246 | CHECK_NUMBER (ch, 0); |
| 226 | return make_number (syntax_code_spec[(int) SYNTAX (XINT (ch))]); | 247 | char_int = XINT (ch); |
| 248 | return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); | ||
| 227 | } | 249 | } |
| 228 | 250 | ||
| 229 | DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, | 251 | DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, |
| @@ -231,11 +253,12 @@ DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, | |||
| 231 | (ch) | 253 | (ch) |
| 232 | Lisp_Object ch; | 254 | Lisp_Object ch; |
| 233 | { | 255 | { |
| 234 | int code; | 256 | int char_int, code; |
| 235 | CHECK_NUMBER (ch, 0); | 257 | CHECK_NUMBER (ch, 0); |
| 236 | code = SYNTAX (XINT (ch)); | 258 | char_int = XINT (ch); |
| 259 | code = SYNTAX (char_int); | ||
| 237 | if (code == Sopen || code == Sclose) | 260 | if (code == Sopen || code == Sclose) |
| 238 | return make_number (SYNTAX_MATCH (XINT (ch))); | 261 | return make_number (SYNTAX_MATCH (char_int)); |
| 239 | return Qnil; | 262 | return Qnil; |
| 240 | } | 263 | } |
| 241 | 264 | ||
| @@ -289,27 +312,36 @@ DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, | |||
| 289 | (c, newentry, syntax_table) | 312 | (c, newentry, syntax_table) |
| 290 | Lisp_Object c, newentry, syntax_table; | 313 | Lisp_Object c, newentry, syntax_table; |
| 291 | { | 314 | { |
| 292 | register unsigned char *p, match; | 315 | register unsigned char *p; |
| 293 | register enum syntaxcode code; | 316 | register enum syntaxcode code; |
| 294 | int val; | 317 | int val; |
| 318 | Lisp_Object match; | ||
| 295 | 319 | ||
| 296 | CHECK_NUMBER (c, 0); | 320 | CHECK_NUMBER (c, 0); |
| 297 | CHECK_STRING (newentry, 1); | 321 | CHECK_STRING (newentry, 1); |
| 322 | |||
| 298 | if (NILP (syntax_table)) | 323 | if (NILP (syntax_table)) |
| 299 | syntax_table = current_buffer->syntax_table; | 324 | syntax_table = current_buffer->syntax_table; |
| 300 | else | 325 | else |
| 301 | syntax_table = check_syntax_table (syntax_table); | 326 | check_syntax_table (syntax_table); |
| 302 | 327 | ||
| 303 | p = XSTRING (newentry)->data; | 328 | p = XSTRING (newentry)->data; |
| 304 | code = (enum syntaxcode) syntax_spec_code[*p++]; | 329 | code = (enum syntaxcode) syntax_spec_code[*p++]; |
| 305 | if (((int) code & 0377) == 0377) | 330 | if (((int) code & 0377) == 0377) |
| 306 | error ("invalid syntax description letter: %c", c); | 331 | error ("invalid syntax description letter: %c", c); |
| 307 | 332 | ||
| 308 | match = *p; | 333 | if (code == Sinherit) |
| 309 | if (match) p++; | 334 | { |
| 310 | if (match == ' ') match = 0; | 335 | SET_RAW_SYNTAX_ENTRY (syntax_table, c, Qnil); |
| 336 | return Qnil; | ||
| 337 | } | ||
| 338 | |||
| 339 | if (*p) | ||
| 340 | XSETINT (match, *p++); | ||
| 341 | if (XFASTINT (match) == ' ') | ||
| 342 | match = Qnil; | ||
| 311 | 343 | ||
| 312 | val = (match << 8) + (int) code; | 344 | val = (int) code; |
| 313 | while (*p) | 345 | while (*p) |
| 314 | switch (*p++) | 346 | switch (*p++) |
| 315 | { | 347 | { |
| @@ -338,7 +370,8 @@ DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, | |||
| 338 | break; | 370 | break; |
| 339 | } | 371 | } |
| 340 | 372 | ||
| 341 | XSETFASTINT (XVECTOR (syntax_table)->contents[0xFF & XINT (c)], val); | 373 | SET_RAW_SYNTAX_ENTRY (syntax_table, c, |
| 374 | Fcons (make_number (val), match)); | ||
| 342 | 375 | ||
| 343 | return Qnil; | 376 | return Qnil; |
| 344 | } | 377 | } |
| @@ -352,23 +385,38 @@ describe_syntax (value) | |||
| 352 | register enum syntaxcode code; | 385 | register enum syntaxcode code; |
| 353 | char desc, match, start1, start2, end1, end2, prefix, comstyle; | 386 | char desc, match, start1, start2, end1, end2, prefix, comstyle; |
| 354 | char str[2]; | 387 | char str[2]; |
| 388 | Lisp_Object first, match_lisp; | ||
| 355 | 389 | ||
| 356 | Findent_to (make_number (16), make_number (1)); | 390 | Findent_to (make_number (16), make_number (1)); |
| 357 | 391 | ||
| 358 | if (!INTEGERP (value)) | 392 | if (NILP (value)) |
| 393 | { | ||
| 394 | insert_string ("inherit"); | ||
| 395 | return; | ||
| 396 | } | ||
| 397 | |||
| 398 | if (!CONSP (value)) | ||
| 399 | { | ||
| 400 | insert_string ("invalid"); | ||
| 401 | return; | ||
| 402 | } | ||
| 403 | |||
| 404 | first = XCONS (value)->car; | ||
| 405 | match_lisp = XCONS (value)->cdr; | ||
| 406 | |||
| 407 | if (!INTEGERP (first) || !(NILP (match_lisp) || INTEGERP (match_lisp))) | ||
| 359 | { | 408 | { |
| 360 | insert_string ("invalid"); | 409 | insert_string ("invalid"); |
| 361 | return; | 410 | return; |
| 362 | } | 411 | } |
| 363 | 412 | ||
| 364 | code = (enum syntaxcode) (XINT (value) & 0377); | 413 | code = (enum syntaxcode) (first & 0377); |
| 365 | match = (XINT (value) >> 8) & 0377; | 414 | start1 = (XINT (first) >> 16) & 1; |
| 366 | start1 = (XINT (value) >> 16) & 1; | 415 | start2 = (XINT (first) >> 17) & 1; |
| 367 | start2 = (XINT (value) >> 17) & 1; | 416 | end1 = (XINT (first) >> 18) & 1; |
| 368 | end1 = (XINT (value) >> 18) & 1; | 417 | end2 = (XINT (first) >> 19) & 1; |
| 369 | end2 = (XINT (value) >> 19) & 1; | 418 | prefix = (XINT (first) >> 20) & 1; |
| 370 | prefix = (XINT (value) >> 20) & 1; | 419 | comstyle = (XINT (first) >> 21) & 1; |
| 371 | comstyle = (XINT (value) >> 21) & 1; | ||
| 372 | 420 | ||
| 373 | if ((int) code < 0 || (int) code >= (int) Smax) | 421 | if ((int) code < 0 || (int) code >= (int) Smax) |
| 374 | { | 422 | { |
| @@ -380,10 +428,9 @@ describe_syntax (value) | |||
| 380 | str[0] = desc, str[1] = 0; | 428 | str[0] = desc, str[1] = 0; |
| 381 | insert (str, 1); | 429 | insert (str, 1); |
| 382 | 430 | ||
| 383 | str[0] = match ? match : ' '; | 431 | str[0] = !NILP (match_lisp) ? XINT (match_lisp) : ' '; |
| 384 | insert (str, 1); | 432 | insert (str, 1); |
| 385 | 433 | ||
| 386 | |||
| 387 | if (start1) | 434 | if (start1) |
| 388 | insert ("1", 1); | 435 | insert ("1", 1); |
| 389 | if (start2) | 436 | if (start2) |
| @@ -429,17 +476,15 @@ describe_syntax (value) | |||
| 429 | insert_string ("comment"); break; | 476 | insert_string ("comment"); break; |
| 430 | case Sendcomment: | 477 | case Sendcomment: |
| 431 | insert_string ("endcomment"); break; | 478 | insert_string ("endcomment"); break; |
| 432 | case Sinherit: | ||
| 433 | insert_string ("inherit"); break; | ||
| 434 | default: | 479 | default: |
| 435 | insert_string ("invalid"); | 480 | insert_string ("invalid"); |
| 436 | return; | 481 | return; |
| 437 | } | 482 | } |
| 438 | 483 | ||
| 439 | if (match) | 484 | if (!NILP (match_lisp)) |
| 440 | { | 485 | { |
| 441 | insert_string (", matches "); | 486 | insert_string (", matches "); |
| 442 | insert_char (match); | 487 | insert_char (XINT (match_lisp)); |
| 443 | } | 488 | } |
| 444 | 489 | ||
| 445 | if (start1) | 490 | if (start1) |
| @@ -493,6 +538,7 @@ scan_words (from, count) | |||
| 493 | register int beg = BEGV; | 538 | register int beg = BEGV; |
| 494 | register int end = ZV; | 539 | register int end = ZV; |
| 495 | register int code; | 540 | register int code; |
| 541 | int charcode; | ||
| 496 | 542 | ||
| 497 | immediate_quit = 1; | 543 | immediate_quit = 1; |
| 498 | QUIT; | 544 | QUIT; |
| @@ -506,7 +552,8 @@ scan_words (from, count) | |||
| 506 | immediate_quit = 0; | 552 | immediate_quit = 0; |
| 507 | return 0; | 553 | return 0; |
| 508 | } | 554 | } |
| 509 | code = SYNTAX (FETCH_CHAR (from)); | 555 | charcode = FETCH_CHAR (from); |
| 556 | code = SYNTAX (charcode); | ||
| 510 | if (words_include_escapes | 557 | if (words_include_escapes |
| 511 | && (code == Sescape || code == Scharquote)) | 558 | && (code == Sescape || code == Scharquote)) |
| 512 | break; | 559 | break; |
| @@ -517,7 +564,8 @@ scan_words (from, count) | |||
| 517 | while (1) | 564 | while (1) |
| 518 | { | 565 | { |
| 519 | if (from == end) break; | 566 | if (from == end) break; |
| 520 | code = SYNTAX (FETCH_CHAR (from)); | 567 | charcode = FETCH_CHAR (from); |
| 568 | code = SYNTAX (charcode); | ||
| 521 | if (!(words_include_escapes | 569 | if (!(words_include_escapes |
| 522 | && (code == Sescape || code == Scharquote))) | 570 | && (code == Sescape || code == Scharquote))) |
| 523 | if (code != Sword) | 571 | if (code != Sword) |
| @@ -535,7 +583,8 @@ scan_words (from, count) | |||
| 535 | immediate_quit = 0; | 583 | immediate_quit = 0; |
| 536 | return 0; | 584 | return 0; |
| 537 | } | 585 | } |
| 538 | code = SYNTAX (FETCH_CHAR (from - 1)); | 586 | charcode = FETCH_CHAR (from - 1); |
| 587 | code = SYNTAX (charcode); | ||
| 539 | if (words_include_escapes | 588 | if (words_include_escapes |
| 540 | && (code == Sescape || code == Scharquote)) | 589 | && (code == Sescape || code == Scharquote)) |
| 541 | break; | 590 | break; |
| @@ -546,7 +595,8 @@ scan_words (from, count) | |||
| 546 | while (1) | 595 | while (1) |
| 547 | { | 596 | { |
| 548 | if (from == beg) break; | 597 | if (from == beg) break; |
| 549 | code = SYNTAX (FETCH_CHAR (from - 1)); | 598 | charcode = FETCH_CHAR (from - 1); |
| 599 | code = SYNTAX (charcode); | ||
| 550 | if (!(words_include_escapes | 600 | if (!(words_include_escapes |
| 551 | && (code == Sescape || code == Scharquote))) | 601 | && (code == Sescape || code == Scharquote))) |
| 552 | if (code != Sword) | 602 | if (code != Sword) |
| @@ -592,7 +642,7 @@ between them, return t; otherwise return nil.") | |||
| 592 | { | 642 | { |
| 593 | register int from; | 643 | register int from; |
| 594 | register int stop; | 644 | register int stop; |
| 595 | register int c; | 645 | register int c, c1; |
| 596 | register enum syntaxcode code; | 646 | register enum syntaxcode code; |
| 597 | int comstyle = 0; /* style of comment encountered */ | 647 | int comstyle = 0; /* style of comment encountered */ |
| 598 | int found; | 648 | int found; |
| @@ -622,7 +672,8 @@ between them, return t; otherwise return nil.") | |||
| 622 | from++; | 672 | from++; |
| 623 | comstyle = 0; | 673 | comstyle = 0; |
| 624 | if (from < stop && SYNTAX_COMSTART_FIRST (c) | 674 | if (from < stop && SYNTAX_COMSTART_FIRST (c) |
| 625 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))) | 675 | && (c1 = FETCH_CHAR (from), |
| 676 | SYNTAX_COMSTART_SECOND (c1))) | ||
| 626 | { | 677 | { |
| 627 | /* We have encountered a comment start sequence and we | 678 | /* We have encountered a comment start sequence and we |
| 628 | are ignoring all text inside comments. We must record | 679 | are ignoring all text inside comments. We must record |
| @@ -630,7 +681,7 @@ between them, return t; otherwise return nil.") | |||
| 630 | only a comment end of the same style actually ends | 681 | only a comment end of the same style actually ends |
| 631 | the comment section. */ | 682 | the comment section. */ |
| 632 | code = Scomment; | 683 | code = Scomment; |
| 633 | comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); | 684 | comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 634 | from++; | 685 | from++; |
| 635 | } | 686 | } |
| 636 | } | 687 | } |
| @@ -659,7 +710,8 @@ between them, return t; otherwise return nil.") | |||
| 659 | section */ | 710 | section */ |
| 660 | break; | 711 | break; |
| 661 | if (from < stop && SYNTAX_COMEND_FIRST (c) | 712 | if (from < stop && SYNTAX_COMEND_FIRST (c) |
| 662 | && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) | 713 | && (c1 = FETCH_CHAR (from), |
| 714 | SYNTAX_COMEND_SECOND (c1)) | ||
| 663 | && SYNTAX_COMMENT_STYLE (c) == comstyle) | 715 | && SYNTAX_COMMENT_STYLE (c) == comstyle) |
| 664 | /* we have encountered a comment end of the same style | 716 | /* we have encountered a comment end of the same style |
| 665 | as the comment sequence which began this comment | 717 | as the comment sequence which began this comment |
| @@ -687,14 +739,15 @@ between them, return t; otherwise return nil.") | |||
| 687 | if (code == Sendcomment) | 739 | if (code == Sendcomment) |
| 688 | comstyle = SYNTAX_COMMENT_STYLE (c); | 740 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| 689 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 741 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 690 | && SYNTAX_COMEND_FIRST (FETCH_CHAR (from - 1)) | 742 | && (c1 = FETCH_CHAR (from - 1), |
| 743 | SYNTAX_COMEND_FIRST (c1)) | ||
| 691 | && !char_quoted (from - 1)) | 744 | && !char_quoted (from - 1)) |
| 692 | { | 745 | { |
| 693 | /* We must record the comment style encountered so that | 746 | /* We must record the comment style encountered so that |
| 694 | later, we can match only the proper comment begin | 747 | later, we can match only the proper comment begin |
| 695 | sequence of the same style. */ | 748 | sequence of the same style. */ |
| 696 | code = Sendcomment; | 749 | code = Sendcomment; |
| 697 | comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from - 1)); | 750 | comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 698 | from--; | 751 | from--; |
| 699 | } | 752 | } |
| 700 | 753 | ||
| @@ -708,7 +761,8 @@ between them, return t; otherwise return nil.") | |||
| 708 | if (from != stop) from--; | 761 | if (from != stop) from--; |
| 709 | while (1) | 762 | while (1) |
| 710 | { | 763 | { |
| 711 | if (SYNTAX (c = FETCH_CHAR (from)) == Scomment | 764 | if ((c = FETCH_CHAR (from), |
| 765 | SYNTAX (c) == Scomment) | ||
| 712 | && SYNTAX_COMMENT_STYLE (c) == comstyle) | 766 | && SYNTAX_COMMENT_STYLE (c) == comstyle) |
| 713 | break; | 767 | break; |
| 714 | if (from == stop) | 768 | if (from == stop) |
| @@ -719,7 +773,8 @@ between them, return t; otherwise return nil.") | |||
| 719 | } | 773 | } |
| 720 | from--; | 774 | from--; |
| 721 | if (SYNTAX_COMSTART_SECOND (c) | 775 | if (SYNTAX_COMSTART_SECOND (c) |
| 722 | && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from)) | 776 | && (c1 = FETCH_CHAR (from), |
| 777 | SYNTAX_COMSTART_FIRST (c1)) | ||
| 723 | && SYNTAX_COMMENT_STYLE (c) == comstyle | 778 | && SYNTAX_COMMENT_STYLE (c) == comstyle |
| 724 | && !char_quoted (from)) | 779 | && !char_quoted (from)) |
| 725 | break; | 780 | break; |
| @@ -1663,39 +1718,47 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0, | |||
| 1663 | init_syntax_once () | 1718 | init_syntax_once () |
| 1664 | { | 1719 | { |
| 1665 | register int i; | 1720 | register int i; |
| 1666 | register struct Lisp_Vector *v; | 1721 | Lisp_Object temp; |
| 1667 | 1722 | ||
| 1668 | /* Set this now, so first buffer creation can refer to it. */ | 1723 | temp = Fcons (make_number ((int) Swhitespace), Qnil); |
| 1669 | /* Make it nil before calling copy-syntax-table | ||
| 1670 | so that copy-syntax-table will know not to try to copy from garbage */ | ||
| 1671 | Vstandard_syntax_table = Qnil; | ||
| 1672 | Vstandard_syntax_table = Fcopy_syntax_table (Qnil); | ||
| 1673 | 1724 | ||
| 1674 | v = XVECTOR (Vstandard_syntax_table); | 1725 | Vstandard_syntax_table = Fmake_char_table (make_number (0), temp); |
| 1675 | 1726 | ||
| 1727 | temp = Fcons (make_number ((int) Sword), Qnil); | ||
| 1676 | for (i = 'a'; i <= 'z'; i++) | 1728 | for (i = 'a'; i <= 'z'; i++) |
| 1677 | XSETFASTINT (v->contents[i], (int) Sword); | 1729 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1678 | for (i = 'A'; i <= 'Z'; i++) | 1730 | for (i = 'A'; i <= 'Z'; i++) |
| 1679 | XSETFASTINT (v->contents[i], (int) Sword); | 1731 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1680 | for (i = '0'; i <= '9'; i++) | 1732 | for (i = '0'; i <= '9'; i++) |
| 1681 | XSETFASTINT (v->contents[i], (int) Sword); | 1733 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1682 | XSETFASTINT (v->contents['$'], (int) Sword); | 1734 | |
| 1683 | XSETFASTINT (v->contents['%'], (int) Sword); | 1735 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '$', temp); |
| 1684 | 1736 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '%', temp); | |
| 1685 | XSETFASTINT (v->contents['('], (int) Sopen + (')' << 8)); | 1737 | |
| 1686 | XSETFASTINT (v->contents[')'], (int) Sclose + ('(' << 8)); | 1738 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '(', |
| 1687 | XSETFASTINT (v->contents['['], (int) Sopen + (']' << 8)); | 1739 | Fcons (make_number (Sopen), make_number (')'))); |
| 1688 | XSETFASTINT (v->contents[']'], (int) Sclose + ('[' << 8)); | 1740 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ')', |
| 1689 | XSETFASTINT (v->contents['{'], (int) Sopen + ('}' << 8)); | 1741 | Fcons (make_number (Sclose), make_number ('('))); |
| 1690 | XSETFASTINT (v->contents['}'], (int) Sclose + ('{' << 8)); | 1742 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '[', |
| 1691 | XSETFASTINT (v->contents['"'], (int) Sstring); | 1743 | Fcons (make_number (Sopen), make_number (']'))); |
| 1692 | XSETFASTINT (v->contents['\\'], (int) Sescape); | 1744 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ']', |
| 1693 | 1745 | Fcons (make_number (Sclose), make_number ('['))); | |
| 1746 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '{', | ||
| 1747 | Fcons (make_number (Sopen), make_number ('}'))); | ||
| 1748 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '}', | ||
| 1749 | Fcons (make_number (Sclose), make_number ('{'))); | ||
| 1750 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '"', | ||
| 1751 | Fcons (make_number ((int) Sstring), Qnil)); | ||
| 1752 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', | ||
| 1753 | Fcons (make_number ((int) Sescape), Qnil)); | ||
| 1754 | |||
| 1755 | temp = Fcons (make_number ((int) Ssymbol), Qnil); | ||
| 1694 | for (i = 0; i < 10; i++) | 1756 | for (i = 0; i < 10; i++) |
| 1695 | XSETFASTINT (v->contents["_-+*/&|<>="[i]], (int) Ssymbol); | 1757 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, "_-+*/&|<>="[i], temp); |
| 1696 | 1758 | ||
| 1759 | temp = Fcons (make_number ((int) Spunct), Qnil); | ||
| 1697 | for (i = 0; i < 12; i++) | 1760 | for (i = 0; i < 12; i++) |
| 1698 | XSETFASTINT (v->contents[".,;:?!#@~^'`"[i]], (int) Spunct); | 1761 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ".,;:?!#@~^'`"[i], temp); |
| 1699 | } | 1762 | } |
| 1700 | 1763 | ||
| 1701 | syms_of_syntax () | 1764 | syms_of_syntax () |