diff options
| author | Karl Heuer | 1997-02-20 06:56:29 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-02-20 06:56:29 +0000 |
| commit | 93da5fff9b9bdfc4792699433e33db046f26d0d8 (patch) | |
| tree | 1d1667de1e7b0775a2207984b70f54db2b9d8c74 /src | |
| parent | ed975f8740e868cbc117882be3cb9954e504fad0 (diff) | |
| download | emacs-93da5fff9b9bdfc4792699433e33db046f26d0d8.tar.gz emacs-93da5fff9b9bdfc4792699433e33db046f26d0d8.zip | |
Include charset.h and category.h.
(Vsyntax_code_object): New variable.
(Fmodify_syntax_entry): Handle multibyte characters. A multibyte
character in matching parenthesis is also handled correctly. Use
shared object in the vector Vsyntax_code_object for an ASCII
character.
(describe_syntax): Handle a multibyte character in matching
parenthesis.
(describe_syntax_1): Describe also parent syntax tables.
(scan_words, Fforward_comment): Handle multibyte characters.
(scan_lists, char_quoted, Fbackward_prefix_chars): Likewise.
(scan_sexps_forward): Likewise.
(init_syntax_once): Initialize Vsyntax_code_object.
Initialize Vstandard_syntax_table by share objects in
Vsyntax_code_object.
(syms_of_syntax): Staticpro Vsyntax_code_object.
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax.c | 348 |
1 files changed, 226 insertions, 122 deletions
diff --git a/src/syntax.c b/src/syntax.c index 1404bfab249..b5d9c9a5b01 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -24,7 +24,9 @@ Boston, MA 02111-1307, USA. */ | |||
| 24 | #include "lisp.h" | 24 | #include "lisp.h" |
| 25 | #include "commands.h" | 25 | #include "commands.h" |
| 26 | #include "buffer.h" | 26 | #include "buffer.h" |
| 27 | #include "charset.h" | ||
| 27 | #include "syntax.h" | 28 | #include "syntax.h" |
| 29 | #include "category.h" | ||
| 28 | 30 | ||
| 29 | Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; | 31 | Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; |
| 30 | 32 | ||
| @@ -222,6 +224,14 @@ char syntax_code_spec[14] = | |||
| 222 | { | 224 | { |
| 223 | ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' | 225 | ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' |
| 224 | }; | 226 | }; |
| 227 | |||
| 228 | /* Indexed by syntax code, give the object (cons of syntax code and | ||
| 229 | nil) to be stored in syntax table. Since these objects can be | ||
| 230 | shared among syntax tables, we generate them in advance. By | ||
| 231 | sharing objects, the function `describe-syntax' can give a more | ||
| 232 | compact listing. */ | ||
| 233 | static Lisp_Object Vsyntax_code_object; | ||
| 234 | |||
| 225 | 235 | ||
| 226 | /* Look up the value for CHARACTER in syntax table TABLE's parent | 236 | /* Look up the value for CHARACTER in syntax table TABLE's parent |
| 227 | and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil | 237 | and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil |
| @@ -351,9 +361,13 @@ DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, | |||
| 351 | 361 | ||
| 352 | if (*p) | 362 | if (*p) |
| 353 | { | 363 | { |
| 354 | XSETINT (match, *p++); | 364 | int len; |
| 365 | int character = STRING_CHAR_AND_LENGTH (p, XSTRING (newentry)->size - 1, | ||
| 366 | len); | ||
| 367 | XSETINT (match, character); | ||
| 355 | if (XFASTINT (match) == ' ') | 368 | if (XFASTINT (match) == ' ') |
| 356 | match = Qnil; | 369 | match = Qnil; |
| 370 | p += len; | ||
| 357 | } | 371 | } |
| 358 | else | 372 | else |
| 359 | match = Qnil; | 373 | match = Qnil; |
| @@ -387,8 +401,13 @@ DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, | |||
| 387 | break; | 401 | break; |
| 388 | } | 402 | } |
| 389 | 403 | ||
| 390 | SET_RAW_SYNTAX_ENTRY (syntax_table, c, | 404 | if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match)) |
| 391 | Fcons (make_number (val), match)); | 405 | newentry = XVECTOR (Vsyntax_code_object)->contents[val]; |
| 406 | else | ||
| 407 | /* Since we can't use a shared object, let's make a new one. */ | ||
| 408 | newentry = Fcons (make_number (val), match); | ||
| 409 | |||
| 410 | SET_RAW_SYNTAX_ENTRY (syntax_table, c, newentry); | ||
| 392 | 411 | ||
| 393 | return Qnil; | 412 | return Qnil; |
| 394 | } | 413 | } |
| @@ -408,13 +427,13 @@ describe_syntax (value) | |||
| 408 | 427 | ||
| 409 | if (NILP (value)) | 428 | if (NILP (value)) |
| 410 | { | 429 | { |
| 411 | insert_string ("inherit"); | 430 | insert_string ("default\n"); |
| 412 | return; | 431 | return; |
| 413 | } | 432 | } |
| 414 | 433 | ||
| 415 | if (!CONSP (value)) | 434 | if (!CONSP (value)) |
| 416 | { | 435 | { |
| 417 | insert_string ("invalid"); | 436 | insert_string ("invalid\n"); |
| 418 | return; | 437 | return; |
| 419 | } | 438 | } |
| 420 | 439 | ||
| @@ -423,7 +442,7 @@ describe_syntax (value) | |||
| 423 | 442 | ||
| 424 | if (!INTEGERP (first) || !(NILP (match_lisp) || INTEGERP (match_lisp))) | 443 | if (!INTEGERP (first) || !(NILP (match_lisp) || INTEGERP (match_lisp))) |
| 425 | { | 444 | { |
| 426 | insert_string ("invalid"); | 445 | insert_string ("invalid\n"); |
| 427 | return; | 446 | return; |
| 428 | } | 447 | } |
| 429 | 448 | ||
| @@ -445,8 +464,10 @@ describe_syntax (value) | |||
| 445 | str[0] = desc, str[1] = 0; | 464 | str[0] = desc, str[1] = 0; |
| 446 | insert (str, 1); | 465 | insert (str, 1); |
| 447 | 466 | ||
| 448 | str[0] = !NILP (match_lisp) ? XINT (match_lisp) : ' '; | 467 | if (NILP (match_lisp)) |
| 449 | insert (str, 1); | 468 | insert (" ", 1); |
| 469 | else | ||
| 470 | insert_char (XINT (match_lisp)); | ||
| 450 | 471 | ||
| 451 | if (start1) | 472 | if (start1) |
| 452 | insert ("1", 1); | 473 | insert ("1", 1); |
| @@ -529,6 +550,13 @@ describe_syntax_1 (vector) | |||
| 529 | struct buffer *old = current_buffer; | 550 | struct buffer *old = current_buffer; |
| 530 | set_buffer_internal (XBUFFER (Vstandard_output)); | 551 | set_buffer_internal (XBUFFER (Vstandard_output)); |
| 531 | describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil); | 552 | describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil); |
| 553 | while (! NILP (XCHAR_TABLE (vector)->parent)) | ||
| 554 | { | ||
| 555 | vector = XCHAR_TABLE (vector)->parent; | ||
| 556 | insert_string ("\nThe parent syntax table is:"); | ||
| 557 | describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil); | ||
| 558 | } | ||
| 559 | |||
| 532 | call0 (intern ("help-mode")); | 560 | call0 (intern ("help-mode")); |
| 533 | set_buffer_internal (old); | 561 | set_buffer_internal (old); |
| 534 | return Qnil; | 562 | return Qnil; |
| @@ -554,8 +582,9 @@ scan_words (from, count) | |||
| 554 | { | 582 | { |
| 555 | register int beg = BEGV; | 583 | register int beg = BEGV; |
| 556 | register int end = ZV; | 584 | register int end = ZV; |
| 557 | register int code; | 585 | register enum syntaxcode code; |
| 558 | int charcode; | 586 | int ch0, ch1; |
| 587 | int temp_pos; | ||
| 559 | 588 | ||
| 560 | immediate_quit = 1; | 589 | immediate_quit = 1; |
| 561 | QUIT; | 590 | QUIT; |
| @@ -569,25 +598,28 @@ scan_words (from, count) | |||
| 569 | immediate_quit = 0; | 598 | immediate_quit = 0; |
| 570 | return 0; | 599 | return 0; |
| 571 | } | 600 | } |
| 572 | charcode = FETCH_CHAR (from); | 601 | ch0 = FETCH_CHAR (from); |
| 573 | code = SYNTAX (charcode); | 602 | code = SYNTAX (ch0); |
| 603 | INC_POS (from); | ||
| 574 | if (words_include_escapes | 604 | if (words_include_escapes |
| 575 | && (code == Sescape || code == Scharquote)) | 605 | && (code == Sescape || code == Scharquote)) |
| 576 | break; | 606 | break; |
| 577 | if (code == Sword) | 607 | if (code == Sword) |
| 578 | break; | 608 | break; |
| 579 | from++; | ||
| 580 | } | 609 | } |
| 610 | /* Now CH0 is a character which begins a word and FROM is the | ||
| 611 | position of the next character. */ | ||
| 581 | while (1) | 612 | while (1) |
| 582 | { | 613 | { |
| 583 | if (from == end) break; | 614 | if (from == end) break; |
| 584 | charcode = FETCH_CHAR (from); | 615 | ch1 = FETCH_CHAR (from); |
| 585 | code = SYNTAX (charcode); | 616 | code = SYNTAX (ch1); |
| 586 | if (!(words_include_escapes | 617 | if (!(words_include_escapes |
| 587 | && (code == Sescape || code == Scharquote))) | 618 | && (code == Sescape || code == Scharquote))) |
| 588 | if (code != Sword) | 619 | if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) |
| 589 | break; | 620 | break; |
| 590 | from++; | 621 | INC_POS (from); |
| 622 | ch0 = ch1; | ||
| 591 | } | 623 | } |
| 592 | count--; | 624 | count--; |
| 593 | } | 625 | } |
| @@ -600,25 +632,30 @@ scan_words (from, count) | |||
| 600 | immediate_quit = 0; | 632 | immediate_quit = 0; |
| 601 | return 0; | 633 | return 0; |
| 602 | } | 634 | } |
| 603 | charcode = FETCH_CHAR (from - 1); | 635 | DEC_POS (from); |
| 604 | code = SYNTAX (charcode); | 636 | ch1 = FETCH_CHAR (from); |
| 637 | code = SYNTAX (ch1); | ||
| 605 | if (words_include_escapes | 638 | if (words_include_escapes |
| 606 | && (code == Sescape || code == Scharquote)) | 639 | && (code == Sescape || code == Scharquote)) |
| 607 | break; | 640 | break; |
| 608 | if (code == Sword) | 641 | if (code == Sword) |
| 609 | break; | 642 | break; |
| 610 | from--; | ||
| 611 | } | 643 | } |
| 644 | /* Now CH1 is a character which ends a word and FROM is the | ||
| 645 | position of it. */ | ||
| 612 | while (1) | 646 | while (1) |
| 613 | { | 647 | { |
| 614 | if (from == beg) break; | 648 | if (from == beg) break; |
| 615 | charcode = FETCH_CHAR (from - 1); | 649 | temp_pos = from; |
| 616 | code = SYNTAX (charcode); | 650 | DEC_POS (temp_pos); |
| 651 | ch0 = FETCH_CHAR (temp_pos); | ||
| 652 | code = SYNTAX (ch0); | ||
| 617 | if (!(words_include_escapes | 653 | if (!(words_include_escapes |
| 618 | && (code == Sescape || code == Scharquote))) | 654 | && (code == Sescape || code == Scharquote))) |
| 619 | if (code != Sword) | 655 | if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) |
| 620 | break; | 656 | break; |
| 621 | from--; | 657 | from = temp_pos; |
| 658 | ch1 = ch0; | ||
| 622 | } | 659 | } |
| 623 | count++; | 660 | count++; |
| 624 | } | 661 | } |
| @@ -664,6 +701,7 @@ between them, return t; otherwise return nil.") | |||
| 664 | int comstyle = 0; /* style of comment encountered */ | 701 | int comstyle = 0; /* style of comment encountered */ |
| 665 | int found; | 702 | int found; |
| 666 | int count1; | 703 | int count1; |
| 704 | int temp_pos; | ||
| 667 | 705 | ||
| 668 | CHECK_NUMBER (count, 0); | 706 | CHECK_NUMBER (count, 0); |
| 669 | count1 = XINT (count); | 707 | count1 = XINT (count); |
| @@ -686,7 +724,7 @@ between them, return t; otherwise return nil.") | |||
| 686 | } | 724 | } |
| 687 | c = FETCH_CHAR (from); | 725 | c = FETCH_CHAR (from); |
| 688 | code = SYNTAX (c); | 726 | code = SYNTAX (c); |
| 689 | from++; | 727 | INC_POS (from); |
| 690 | comstyle = 0; | 728 | comstyle = 0; |
| 691 | if (from < stop && SYNTAX_COMSTART_FIRST (c) | 729 | if (from < stop && SYNTAX_COMSTART_FIRST (c) |
| 692 | && (c1 = FETCH_CHAR (from), | 730 | && (c1 = FETCH_CHAR (from), |
| @@ -699,14 +737,15 @@ between them, return t; otherwise return nil.") | |||
| 699 | the comment section. */ | 737 | the comment section. */ |
| 700 | code = Scomment; | 738 | code = Scomment; |
| 701 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 739 | comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 702 | from++; | 740 | INC_POS (from); |
| 703 | } | 741 | } |
| 704 | } | 742 | } |
| 705 | while (code == Swhitespace || code == Sendcomment); | 743 | while (code == Swhitespace || code == Sendcomment); |
| 706 | if (code != Scomment) | 744 | if (code != Scomment) |
| 707 | { | 745 | { |
| 708 | immediate_quit = 0; | 746 | immediate_quit = 0; |
| 709 | SET_PT (from - 1); | 747 | DEC_POS (from); |
| 748 | SET_PT (from); | ||
| 710 | return Qnil; | 749 | return Qnil; |
| 711 | } | 750 | } |
| 712 | /* We're at the start of a comment. */ | 751 | /* We're at the start of a comment. */ |
| @@ -719,7 +758,7 @@ between them, return t; otherwise return nil.") | |||
| 719 | return Qnil; | 758 | return Qnil; |
| 720 | } | 759 | } |
| 721 | c = FETCH_CHAR (from); | 760 | c = FETCH_CHAR (from); |
| 722 | from++; | 761 | INC_POS (from); |
| 723 | if (SYNTAX (c) == Sendcomment | 762 | if (SYNTAX (c) == Sendcomment |
| 724 | && SYNTAX_COMMENT_STYLE (c) == comstyle) | 763 | && SYNTAX_COMMENT_STYLE (c) == comstyle) |
| 725 | /* we have encountered a comment end of the same style | 764 | /* we have encountered a comment end of the same style |
| @@ -733,7 +772,7 @@ between them, return t; otherwise return nil.") | |||
| 733 | /* we have encountered a comment end of the same style | 772 | /* we have encountered a comment end of the same style |
| 734 | as the comment sequence which began this comment | 773 | as the comment sequence which began this comment |
| 735 | section */ | 774 | section */ |
| 736 | { from++; break; } | 775 | { INC_POS (from); break; } |
| 737 | } | 776 | } |
| 738 | /* We have skipped one comment. */ | 777 | /* We have skipped one comment. */ |
| 739 | count1--; | 778 | count1--; |
| @@ -746,26 +785,28 @@ between them, return t; otherwise return nil.") | |||
| 746 | { | 785 | { |
| 747 | int quoted; | 786 | int quoted; |
| 748 | 787 | ||
| 749 | from--; | 788 | DEC_POS (from); |
| 750 | quoted = char_quoted (from); | 789 | quoted = char_quoted (from); |
| 751 | if (quoted) | 790 | if (quoted) |
| 752 | from--; | 791 | DEC_POS (from); |
| 753 | c = FETCH_CHAR (from); | 792 | c = FETCH_CHAR (from); |
| 754 | code = SYNTAX (c); | 793 | code = SYNTAX (c); |
| 755 | comstyle = 0; | 794 | comstyle = 0; |
| 756 | if (code == Sendcomment) | 795 | if (code == Sendcomment) |
| 757 | comstyle = SYNTAX_COMMENT_STYLE (c); | 796 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| 797 | temp_pos = from; | ||
| 798 | DEC_POS (temp_pos); | ||
| 758 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 799 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 759 | && (c1 = FETCH_CHAR (from - 1), | 800 | && (c1 = FETCH_CHAR (temp_pos), |
| 760 | SYNTAX_COMEND_FIRST (c1)) | 801 | SYNTAX_COMEND_FIRST (c1)) |
| 761 | && !char_quoted (from - 1)) | 802 | && !char_quoted (temp_pos)) |
| 762 | { | 803 | { |
| 763 | /* We must record the comment style encountered so that | 804 | /* We must record the comment style encountered so that |
| 764 | later, we can match only the proper comment begin | 805 | later, we can match only the proper comment begin |
| 765 | sequence of the same style. */ | 806 | sequence of the same style. */ |
| 766 | code = Sendcomment; | 807 | code = Sendcomment; |
| 767 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 808 | comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 768 | from--; | 809 | from = temp_pos; |
| 769 | } | 810 | } |
| 770 | 811 | ||
| 771 | if (code == Sendcomment && !quoted) | 812 | if (code == Sendcomment && !quoted) |
| @@ -775,7 +816,7 @@ between them, return t; otherwise return nil.") | |||
| 775 | /* For a two-char comment ender, we can assume | 816 | /* For a two-char comment ender, we can assume |
| 776 | it does end a comment. So scan back in a simple way. */ | 817 | it does end a comment. So scan back in a simple way. */ |
| 777 | { | 818 | { |
| 778 | if (from != stop) from--; | 819 | if (from != stop) DEC_POS (from); |
| 779 | while (1) | 820 | while (1) |
| 780 | { | 821 | { |
| 781 | if ((c = FETCH_CHAR (from), | 822 | if ((c = FETCH_CHAR (from), |
| @@ -788,7 +829,7 @@ between them, return t; otherwise return nil.") | |||
| 788 | SET_PT (from); | 829 | SET_PT (from); |
| 789 | return Qnil; | 830 | return Qnil; |
| 790 | } | 831 | } |
| 791 | from--; | 832 | DEC_POS (from); |
| 792 | if (SYNTAX_COMSTART_SECOND (c) | 833 | if (SYNTAX_COMSTART_SECOND (c) |
| 793 | && (c1 = FETCH_CHAR (from), | 834 | && (c1 = FETCH_CHAR (from), |
| 794 | SYNTAX_COMSTART_FIRST (c1)) | 835 | SYNTAX_COMSTART_FIRST (c1)) |
| @@ -816,33 +857,40 @@ between them, return t; otherwise return nil.") | |||
| 816 | int comment_end = from; | 857 | int comment_end = from; |
| 817 | int comstart_pos = 0; | 858 | int comstart_pos = 0; |
| 818 | int comstart_parity = 0; | 859 | int comstart_parity = 0; |
| 819 | int scanstart = from - 1; | 860 | int scanstart = from; |
| 820 | 861 | ||
| 862 | DEC_POS (scanstart); | ||
| 821 | /* At beginning of range to scan, we're outside of strings; | 863 | /* At beginning of range to scan, we're outside of strings; |
| 822 | that determines quote parity to the comment-end. */ | 864 | that determines quote parity to the comment-end. */ |
| 823 | while (from != stop) | 865 | while (from != stop) |
| 824 | { | 866 | { |
| 825 | /* Move back and examine a character. */ | 867 | /* Move back and examine a character. */ |
| 826 | from--; | 868 | DEC_POS (from); |
| 827 | 869 | ||
| 828 | c = FETCH_CHAR (from); | 870 | c = FETCH_CHAR (from); |
| 829 | code = SYNTAX (c); | 871 | code = SYNTAX (c); |
| 830 | 872 | ||
| 831 | /* If this char is the second of a 2-char comment sequence, | 873 | /* If this char is the second of a 2-char comment sequence, |
| 832 | back up and give the pair the appropriate syntax. */ | 874 | back up and give the pair the appropriate syntax. */ |
| 875 | temp_pos = from; | ||
| 876 | DEC_POS (temp_pos); | ||
| 833 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 877 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 834 | && SYNTAX_COMEND_FIRST (FETCH_CHAR (from - 1))) | 878 | && (c1 = FETCH_CHAR (temp_pos), |
| 879 | SYNTAX_COMEND_FIRST (c1))) | ||
| 835 | { | 880 | { |
| 836 | code = Sendcomment; | 881 | code = Sendcomment; |
| 837 | from--; | 882 | from = temp_pos; |
| 838 | c = FETCH_CHAR (from); | 883 | c = c1; |
| 839 | } | 884 | } |
| 840 | 885 | ||
| 886 | temp_pos = from; | ||
| 887 | INC_POS (temp_pos); | ||
| 841 | /* If this char starts a 2-char comment start sequence, | 888 | /* If this char starts a 2-char comment start sequence, |
| 842 | treat it like a 1-char comment starter. */ | 889 | treat it like a 1-char comment starter. */ |
| 843 | if (from < scanstart && SYNTAX_COMSTART_FIRST (c) | 890 | if (from < scanstart && SYNTAX_COMSTART_FIRST (c) |
| 844 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from + 1)) | 891 | && (c1 = FETCH_CHAR (temp_pos), |
| 845 | && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (from + 1))) | 892 | SYNTAX_COMSTART_SECOND (c1)) |
| 893 | && comstyle == SYNTAX_COMMENT_STYLE (c1)) | ||
| 846 | code = Scomment; | 894 | code = Scomment; |
| 847 | 895 | ||
| 848 | /* Ignore escaped characters. */ | 896 | /* Ignore escaped characters. */ |
| @@ -878,7 +926,7 @@ between them, return t; otherwise return nil.") | |||
| 878 | 926 | ||
| 879 | /* Assume a defun-start point is outside of strings. */ | 927 | /* Assume a defun-start point is outside of strings. */ |
| 880 | if (code == Sopen | 928 | if (code == Sopen |
| 881 | && (from == stop || FETCH_CHAR (from - 1) == '\n')) | 929 | && (from == stop || FETCH_BYTE (from - 1) == '\n')) |
| 882 | break; | 930 | break; |
| 883 | } | 931 | } |
| 884 | 932 | ||
| @@ -914,7 +962,8 @@ between them, return t; otherwise return nil.") | |||
| 914 | else if ((code != Swhitespace && code != Scomment) || quoted) | 962 | else if ((code != Swhitespace && code != Scomment) || quoted) |
| 915 | { | 963 | { |
| 916 | immediate_quit = 0; | 964 | immediate_quit = 0; |
| 917 | SET_PT (from + 1); | 965 | INC_POS (from); |
| 966 | SET_PT (from); | ||
| 918 | return Qnil; | 967 | return Qnil; |
| 919 | } | 968 | } |
| 920 | } | 969 | } |
| @@ -936,13 +985,14 @@ scan_lists (from, count, depth, sexpflag) | |||
| 936 | { | 985 | { |
| 937 | Lisp_Object val; | 986 | Lisp_Object val; |
| 938 | register int stop; | 987 | register int stop; |
| 939 | register int c; | 988 | register int c, c1; |
| 940 | unsigned char stringterm; | 989 | int stringterm; |
| 941 | int quoted; | 990 | int quoted; |
| 942 | int mathexit = 0; | 991 | int mathexit = 0; |
| 943 | register enum syntaxcode code; | 992 | register enum syntaxcode code, temp_code; |
| 944 | int min_depth = depth; /* Err out if depth gets less than this. */ | 993 | int min_depth = depth; /* Err out if depth gets less than this. */ |
| 945 | int comstyle = 0; /* style of comment encountered */ | 994 | int comstyle = 0; /* style of comment encountered */ |
| 995 | int temp_pos; | ||
| 946 | int last_good = from; | 996 | int last_good = from; |
| 947 | 997 | ||
| 948 | if (depth > 0) min_depth = 0; | 998 | if (depth > 0) min_depth = 0; |
| @@ -959,7 +1009,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 959 | code = SYNTAX (c); | 1009 | code = SYNTAX (c); |
| 960 | if (depth == min_depth) | 1010 | if (depth == min_depth) |
| 961 | last_good = from; | 1011 | last_good = from; |
| 962 | from++; | 1012 | INC_POS (from); |
| 963 | if (from < stop && SYNTAX_COMSTART_FIRST (c) | 1013 | if (from < stop && SYNTAX_COMSTART_FIRST (c) |
| 964 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)) | 1014 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)) |
| 965 | && parse_sexp_ignore_comments) | 1015 | && parse_sexp_ignore_comments) |
| @@ -971,7 +1021,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 971 | the comment section */ | 1021 | the comment section */ |
| 972 | code = Scomment; | 1022 | code = Scomment; |
| 973 | comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); | 1023 | comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); |
| 974 | from++; | 1024 | INC_POS (from); |
| 975 | } | 1025 | } |
| 976 | 1026 | ||
| 977 | if (SYNTAX_PREFIX (c)) | 1027 | if (SYNTAX_PREFIX (c)) |
| @@ -982,7 +1032,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 982 | case Sescape: | 1032 | case Sescape: |
| 983 | case Scharquote: | 1033 | case Scharquote: |
| 984 | if (from == stop) goto lose; | 1034 | if (from == stop) goto lose; |
| 985 | from++; | 1035 | INC_POS (from); |
| 986 | /* treat following character as a word constituent */ | 1036 | /* treat following character as a word constituent */ |
| 987 | case Sword: | 1037 | case Sword: |
| 988 | case Ssymbol: | 1038 | case Ssymbol: |
| @@ -994,7 +1044,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 994 | { | 1044 | { |
| 995 | case Scharquote: | 1045 | case Scharquote: |
| 996 | case Sescape: | 1046 | case Sescape: |
| 997 | from++; | 1047 | INC_POS (from); |
| 998 | if (from == stop) goto lose; | 1048 | if (from == stop) goto lose; |
| 999 | break; | 1049 | break; |
| 1000 | case Sword: | 1050 | case Sword: |
| @@ -1004,7 +1054,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1004 | default: | 1054 | default: |
| 1005 | goto done; | 1055 | goto done; |
| 1006 | } | 1056 | } |
| 1007 | from++; | 1057 | INC_POS (from); |
| 1008 | } | 1058 | } |
| 1009 | goto done; | 1059 | goto done; |
| 1010 | 1060 | ||
| @@ -1025,14 +1075,14 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1025 | as the comment sequence which began this comment | 1075 | as the comment sequence which began this comment |
| 1026 | section */ | 1076 | section */ |
| 1027 | break; | 1077 | break; |
| 1028 | from++; | 1078 | INC_POS (from); |
| 1029 | if (from < stop && SYNTAX_COMEND_FIRST (c) | 1079 | if (from < stop && SYNTAX_COMEND_FIRST (c) |
| 1030 | && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) | 1080 | && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) |
| 1031 | && SYNTAX_COMMENT_STYLE (c) == comstyle) | 1081 | && SYNTAX_COMMENT_STYLE (c) == comstyle) |
| 1032 | /* we have encountered a comment end of the same style | 1082 | /* we have encountered a comment end of the same style |
| 1033 | as the comment sequence which began this comment | 1083 | as the comment sequence which began this comment |
| 1034 | section */ | 1084 | section */ |
| 1035 | { from++; break; } | 1085 | { INC_POS (from); break; } |
| 1036 | } | 1086 | } |
| 1037 | break; | 1087 | break; |
| 1038 | 1088 | ||
| @@ -1040,7 +1090,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1040 | if (!sexpflag) | 1090 | if (!sexpflag) |
| 1041 | break; | 1091 | break; |
| 1042 | if (from != stop && c == FETCH_CHAR (from)) | 1092 | if (from != stop && c == FETCH_CHAR (from)) |
| 1043 | from++; | 1093 | INC_POS (from); |
| 1044 | if (mathexit) | 1094 | if (mathexit) |
| 1045 | { | 1095 | { |
| 1046 | mathexit = 0; | 1096 | mathexit = 0; |
| @@ -1063,7 +1113,9 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1063 | break; | 1113 | break; |
| 1064 | 1114 | ||
| 1065 | case Sstring: | 1115 | case Sstring: |
| 1066 | stringterm = FETCH_CHAR (from - 1); | 1116 | temp_pos = from; |
| 1117 | DEC_POS (temp_pos); | ||
| 1118 | stringterm = FETCH_CHAR (temp_pos); | ||
| 1067 | while (1) | 1119 | while (1) |
| 1068 | { | 1120 | { |
| 1069 | if (from >= stop) goto lose; | 1121 | if (from >= stop) goto lose; |
| @@ -1072,11 +1124,11 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1072 | { | 1124 | { |
| 1073 | case Scharquote: | 1125 | case Scharquote: |
| 1074 | case Sescape: | 1126 | case Sescape: |
| 1075 | from++; | 1127 | INC_POS (from); |
| 1076 | } | 1128 | } |
| 1077 | from++; | 1129 | INC_POS (from); |
| 1078 | } | 1130 | } |
| 1079 | from++; | 1131 | INC_POS (from); |
| 1080 | if (!depth && sexpflag) goto done; | 1132 | if (!depth && sexpflag) goto done; |
| 1081 | break; | 1133 | break; |
| 1082 | } | 1134 | } |
| @@ -1098,9 +1150,9 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1098 | stop = BEGV; | 1150 | stop = BEGV; |
| 1099 | while (from > stop) | 1151 | while (from > stop) |
| 1100 | { | 1152 | { |
| 1101 | from--; | 1153 | DEC_POS (from); |
| 1102 | if (quoted = char_quoted (from)) | 1154 | if (quoted = char_quoted (from)) |
| 1103 | from--; | 1155 | DEC_POS (from); |
| 1104 | c = FETCH_CHAR (from); | 1156 | c = FETCH_CHAR (from); |
| 1105 | code = SYNTAX (c); | 1157 | code = SYNTAX (c); |
| 1106 | if (depth == min_depth) | 1158 | if (depth == min_depth) |
| @@ -1108,17 +1160,19 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1108 | comstyle = 0; | 1160 | comstyle = 0; |
| 1109 | if (code == Sendcomment) | 1161 | if (code == Sendcomment) |
| 1110 | comstyle = SYNTAX_COMMENT_STYLE (c); | 1162 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| 1163 | temp_pos = from; | ||
| 1164 | DEC_POS (temp_pos); | ||
| 1111 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 1165 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 1112 | && SYNTAX_COMEND_FIRST (FETCH_CHAR (from - 1)) | 1166 | && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) |
| 1113 | && !char_quoted (from - 1) | 1167 | && !char_quoted (temp_pos) |
| 1114 | && parse_sexp_ignore_comments) | 1168 | && parse_sexp_ignore_comments) |
| 1115 | { | 1169 | { |
| 1116 | /* we must record the comment style encountered so that | 1170 | /* we must record the comment style encountered so that |
| 1117 | later, we can match only the proper comment begin | 1171 | later, we can match only the proper comment begin |
| 1118 | sequence of the same style */ | 1172 | sequence of the same style */ |
| 1119 | code = Sendcomment; | 1173 | code = Sendcomment; |
| 1120 | comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from - 1)); | 1174 | comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 1121 | from--; | 1175 | from = temp_pos; |
| 1122 | } | 1176 | } |
| 1123 | 1177 | ||
| 1124 | if (SYNTAX_PREFIX (c)) | 1178 | if (SYNTAX_PREFIX (c)) |
| @@ -1132,22 +1186,31 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1132 | /* This word counts as a sexp; count object finished after passing it. */ | 1186 | /* This word counts as a sexp; count object finished after passing it. */ |
| 1133 | while (from > stop) | 1187 | while (from > stop) |
| 1134 | { | 1188 | { |
| 1135 | quoted = char_quoted (from - 1); | 1189 | temp_pos = from; |
| 1190 | DEC_POS (temp_pos); | ||
| 1191 | quoted = char_quoted (temp_pos); | ||
| 1136 | if (quoted) | 1192 | if (quoted) |
| 1137 | from--; | 1193 | { |
| 1138 | if (! (quoted || SYNTAX (FETCH_CHAR (from - 1)) == Sword | 1194 | from = temp_pos; |
| 1139 | || SYNTAX (FETCH_CHAR (from - 1)) == Ssymbol | 1195 | DEC_POS (temp_pos); |
| 1140 | || SYNTAX (FETCH_CHAR (from - 1)) == Squote)) | 1196 | } |
| 1197 | c1 = FETCH_CHAR (temp_pos); | ||
| 1198 | temp_code = SYNTAX (c1); | ||
| 1199 | if (! (quoted || temp_code == Sword | ||
| 1200 | || temp_code == Ssymbol | ||
| 1201 | || temp_code == Squote)) | ||
| 1141 | goto done2; | 1202 | goto done2; |
| 1142 | from--; | 1203 | from = temp_pos; |
| 1143 | } | 1204 | } |
| 1144 | goto done2; | 1205 | goto done2; |
| 1145 | 1206 | ||
| 1146 | case Smath: | 1207 | case Smath: |
| 1147 | if (!sexpflag) | 1208 | if (!sexpflag) |
| 1148 | break; | 1209 | break; |
| 1149 | if (from != stop && c == FETCH_CHAR (from - 1)) | 1210 | temp_pos = from; |
| 1150 | from--; | 1211 | DEC_POS (temp_pos); |
| 1212 | if (from != stop && c == FETCH_CHAR (temp_pos)) | ||
| 1213 | from = temp_pos; | ||
| 1151 | if (mathexit) | 1214 | if (mathexit) |
| 1152 | { | 1215 | { |
| 1153 | mathexit = 0; | 1216 | mathexit = 0; |
| @@ -1177,7 +1240,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1177 | /* For a two-char comment ender, we can assume | 1240 | /* For a two-char comment ender, we can assume |
| 1178 | it does end a comment. So scan back in a simple way. */ | 1241 | it does end a comment. So scan back in a simple way. */ |
| 1179 | { | 1242 | { |
| 1180 | if (from != stop) from--; | 1243 | if (from != stop) DEC_POS (from); |
| 1181 | while (1) | 1244 | while (1) |
| 1182 | { | 1245 | { |
| 1183 | if (SYNTAX (c = FETCH_CHAR (from)) == Scomment | 1246 | if (SYNTAX (c = FETCH_CHAR (from)) == Scomment |
| @@ -1189,7 +1252,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1189 | goto done2; | 1252 | goto done2; |
| 1190 | goto lose; | 1253 | goto lose; |
| 1191 | } | 1254 | } |
| 1192 | from--; | 1255 | DEC_POS (from); |
| 1193 | if (SYNTAX_COMSTART_SECOND (c) | 1256 | if (SYNTAX_COMSTART_SECOND (c) |
| 1194 | && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from)) | 1257 | && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from)) |
| 1195 | && SYNTAX_COMMENT_STYLE (c) == comstyle | 1258 | && SYNTAX_COMMENT_STYLE (c) == comstyle |
| @@ -1216,33 +1279,41 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1216 | int comment_end = from; | 1279 | int comment_end = from; |
| 1217 | int comstart_pos = 0; | 1280 | int comstart_pos = 0; |
| 1218 | int comstart_parity = 0; | 1281 | int comstart_parity = 0; |
| 1219 | int scanstart = from - 1; | 1282 | int scanstart = from; |
| 1283 | |||
| 1284 | DEC_POS (scanstart); | ||
| 1220 | 1285 | ||
| 1221 | /* At beginning of range to scan, we're outside of strings; | 1286 | /* At beginning of range to scan, we're outside of strings; |
| 1222 | that determines quote parity to the comment-end. */ | 1287 | that determines quote parity to the comment-end. */ |
| 1223 | while (from != stop) | 1288 | while (from != stop) |
| 1224 | { | 1289 | { |
| 1225 | /* Move back and examine a character. */ | 1290 | /* Move back and examine a character. */ |
| 1226 | from--; | 1291 | DEC_POS (from); |
| 1227 | 1292 | ||
| 1228 | c = FETCH_CHAR (from); | 1293 | c = FETCH_CHAR (from); |
| 1229 | code = SYNTAX (c); | 1294 | code = SYNTAX (c); |
| 1230 | 1295 | ||
| 1231 | /* If this char is the second of a 2-char comment sequence, | 1296 | /* If this char is the second of a 2-char comment sequence, |
| 1232 | back up and give the pair the appropriate syntax. */ | 1297 | back up and give the pair the appropriate syntax. */ |
| 1298 | temp_pos = from; | ||
| 1299 | DEC_POS (temp_pos); | ||
| 1233 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 1300 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 1234 | && SYNTAX_COMEND_FIRST (FETCH_CHAR (from - 1))) | 1301 | && (c1 = FETCH_CHAR (temp_pos), |
| 1302 | SYNTAX_COMEND_FIRST (c1))) | ||
| 1235 | { | 1303 | { |
| 1236 | code = Sendcomment; | 1304 | code = Sendcomment; |
| 1237 | from--; | 1305 | from = temp_pos; |
| 1238 | c = FETCH_CHAR (from); | 1306 | c = c1; |
| 1239 | } | 1307 | } |
| 1240 | 1308 | ||
| 1241 | /* If this char starts a 2-char comment start sequence, | 1309 | /* If this char starts a 2-char comment start sequence, |
| 1242 | treat it like a 1-char comment starter. */ | 1310 | treat it like a 1-char comment starter. */ |
| 1311 | temp_pos = from; | ||
| 1312 | INC_POS (temp_pos); | ||
| 1243 | if (from < scanstart && SYNTAX_COMSTART_FIRST (c) | 1313 | if (from < scanstart && SYNTAX_COMSTART_FIRST (c) |
| 1244 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from + 1)) | 1314 | && (c1 = FETCH_CHAR (temp_pos), |
| 1245 | && comstyle == SYNTAX_COMMENT_STYLE (FETCH_CHAR (from + 1))) | 1315 | SYNTAX_COMSTART_SECOND (c1)) |
| 1316 | && comstyle == SYNTAX_COMMENT_STYLE (c1)) | ||
| 1246 | code = Scomment; | 1317 | code = Scomment; |
| 1247 | 1318 | ||
| 1248 | /* Ignore escaped characters. */ | 1319 | /* Ignore escaped characters. */ |
| @@ -1278,7 +1349,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1278 | 1349 | ||
| 1279 | /* Assume a defun-start point is outside of strings. */ | 1350 | /* Assume a defun-start point is outside of strings. */ |
| 1280 | if (code == Sopen | 1351 | if (code == Sopen |
| 1281 | && (from == stop || FETCH_CHAR (from - 1) == '\n')) | 1352 | && (from == stop || FETCH_BYTE (from - 1) == '\n')) |
| 1282 | break; | 1353 | break; |
| 1283 | } | 1354 | } |
| 1284 | 1355 | ||
| @@ -1315,12 +1386,14 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1315 | while (1) | 1386 | while (1) |
| 1316 | { | 1387 | { |
| 1317 | if (from == stop) goto lose; | 1388 | if (from == stop) goto lose; |
| 1318 | if (!char_quoted (from - 1) | 1389 | temp_pos = from; |
| 1319 | && stringterm == FETCH_CHAR (from - 1)) | 1390 | DEC_POS (temp_pos); |
| 1391 | if (!char_quoted (temp_pos) | ||
| 1392 | && stringterm == FETCH_CHAR (temp_pos)) | ||
| 1320 | break; | 1393 | break; |
| 1321 | from--; | 1394 | from = temp_pos; |
| 1322 | } | 1395 | } |
| 1323 | from--; | 1396 | DEC_POS (from); |
| 1324 | if (!depth && sexpflag) goto done2; | 1397 | if (!depth && sexpflag) goto done2; |
| 1325 | break; | 1398 | break; |
| 1326 | } | 1399 | } |
| @@ -1357,11 +1430,17 @@ char_quoted (pos) | |||
| 1357 | register enum syntaxcode code; | 1430 | register enum syntaxcode code; |
| 1358 | register int beg = BEGV; | 1431 | register int beg = BEGV; |
| 1359 | register int quoted = 0; | 1432 | register int quoted = 0; |
| 1433 | int temp_pos = pos; | ||
| 1360 | 1434 | ||
| 1435 | DEC_POS (temp_pos); | ||
| 1361 | while (pos > beg | 1436 | while (pos > beg |
| 1362 | && ((code = SYNTAX (FETCH_CHAR (pos - 1))) == Scharquote | 1437 | && ((code = SYNTAX (FETCH_CHAR (temp_pos))) == Scharquote |
| 1363 | || code == Sescape)) | 1438 | || code == Sescape)) |
| 1364 | pos--, quoted = !quoted; | 1439 | { |
| 1440 | pos = temp_pos; | ||
| 1441 | quoted = !quoted; | ||
| 1442 | DEC_POS (temp_pos); | ||
| 1443 | } | ||
| 1365 | return quoted; | 1444 | return quoted; |
| 1366 | } | 1445 | } |
| 1367 | 1446 | ||
| @@ -1417,11 +1496,18 @@ This includes chars with \"quote\" or \"prefix\" syntax (' or p).") | |||
| 1417 | { | 1496 | { |
| 1418 | int beg = BEGV; | 1497 | int beg = BEGV; |
| 1419 | int pos = PT; | 1498 | int pos = PT; |
| 1499 | int c; | ||
| 1500 | int temp_pos = pos; | ||
| 1501 | |||
| 1502 | DEC_POS (temp_pos); | ||
| 1420 | 1503 | ||
| 1421 | while (pos > beg && !char_quoted (pos - 1) | 1504 | while (pos > beg && !char_quoted (temp_pos) |
| 1422 | && (SYNTAX (FETCH_CHAR (pos - 1)) == Squote | 1505 | && ((c = FETCH_CHAR (temp_pos), SYNTAX (c) == Squote) |
| 1423 | || SYNTAX_PREFIX (FETCH_CHAR (pos - 1)))) | 1506 | || SYNTAX_PREFIX (c))) |
| 1424 | pos--; | 1507 | { |
| 1508 | pos = temp_pos; | ||
| 1509 | DEC_POS (temp_pos); | ||
| 1510 | } | ||
| 1425 | 1511 | ||
| 1426 | SET_PT (pos); | 1512 | SET_PT (pos); |
| 1427 | 1513 | ||
| @@ -1450,13 +1536,20 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1450 | struct level levelstart[100]; | 1536 | struct level levelstart[100]; |
| 1451 | register struct level *curlevel = levelstart; | 1537 | register struct level *curlevel = levelstart; |
| 1452 | struct level *endlevel = levelstart + 100; | 1538 | struct level *endlevel = levelstart + 100; |
| 1453 | char prev; | 1539 | int prev; |
| 1454 | register int depth; /* Paren depth of current scanning location. | 1540 | register int depth; /* Paren depth of current scanning location. |
| 1455 | level - levelstart equals this except | 1541 | level - levelstart equals this except |
| 1456 | when the depth becomes negative. */ | 1542 | when the depth becomes negative. */ |
| 1457 | int mindepth; /* Lowest DEPTH value seen. */ | 1543 | int mindepth; /* Lowest DEPTH value seen. */ |
| 1458 | int start_quoted = 0; /* Nonzero means starting after a char quote */ | 1544 | int start_quoted = 0; /* Nonzero means starting after a char quote */ |
| 1459 | Lisp_Object tem; | 1545 | Lisp_Object tem; |
| 1546 | int prev_from; /* Keep one character before FROM. */ | ||
| 1547 | |||
| 1548 | prev_from = from; | ||
| 1549 | DEC_POS (prev_from); | ||
| 1550 | |||
| 1551 | /* Use this macro instead of `from++'. */ | ||
| 1552 | #define INC_FROM do { prev_from = from; INC_POS (from); } while (0) | ||
| 1460 | 1553 | ||
| 1461 | immediate_quit = 1; | 1554 | immediate_quit = 1; |
| 1462 | QUIT; | 1555 | QUIT; |
| @@ -1516,11 +1609,11 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1516 | while (from < end) | 1609 | while (from < end) |
| 1517 | { | 1610 | { |
| 1518 | code = SYNTAX (FETCH_CHAR (from)); | 1611 | code = SYNTAX (FETCH_CHAR (from)); |
| 1519 | from++; | 1612 | INC_FROM; |
| 1520 | if (code == Scomment) | 1613 | if (code == Scomment) |
| 1521 | state.comstart = from-1; | 1614 | state.comstart = prev_from; |
| 1522 | 1615 | ||
| 1523 | else if (from < end && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from - 1)) | 1616 | else if (from < end && SYNTAX_COMSTART_FIRST (FETCH_CHAR (prev_from)) |
| 1524 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))) | 1617 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))) |
| 1525 | { | 1618 | { |
| 1526 | /* Record the comment style we have entered so that only | 1619 | /* Record the comment style we have entered so that only |
| @@ -1528,27 +1621,27 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1528 | terminates the comment section. */ | 1621 | terminates the comment section. */ |
| 1529 | code = Scomment; | 1622 | code = Scomment; |
| 1530 | state.comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); | 1623 | state.comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); |
| 1531 | state.comstart = from-1; | 1624 | state.comstart = prev_from; |
| 1532 | from++; | 1625 | INC_FROM; |
| 1533 | } | 1626 | } |
| 1534 | 1627 | ||
| 1535 | if (SYNTAX_PREFIX (FETCH_CHAR (from - 1))) | 1628 | if (SYNTAX_PREFIX (FETCH_CHAR (prev_from))) |
| 1536 | continue; | 1629 | continue; |
| 1537 | switch (SWITCH_ENUM_CAST (code)) | 1630 | switch (SWITCH_ENUM_CAST (code)) |
| 1538 | { | 1631 | { |
| 1539 | case Sescape: | 1632 | case Sescape: |
| 1540 | case Scharquote: | 1633 | case Scharquote: |
| 1541 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ | 1634 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ |
| 1542 | curlevel->last = from - 1; | 1635 | curlevel->last = prev_from; |
| 1543 | startquoted: | 1636 | startquoted: |
| 1544 | if (from == end) goto endquoted; | 1637 | if (from == end) goto endquoted; |
| 1545 | from++; | 1638 | INC_FROM; |
| 1546 | goto symstarted; | 1639 | goto symstarted; |
| 1547 | /* treat following character as a word constituent */ | 1640 | /* treat following character as a word constituent */ |
| 1548 | case Sword: | 1641 | case Sword: |
| 1549 | case Ssymbol: | 1642 | case Ssymbol: |
| 1550 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ | 1643 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ |
| 1551 | curlevel->last = from - 1; | 1644 | curlevel->last = prev_from; |
| 1552 | symstarted: | 1645 | symstarted: |
| 1553 | while (from < end) | 1646 | while (from < end) |
| 1554 | { | 1647 | { |
| @@ -1556,7 +1649,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1556 | { | 1649 | { |
| 1557 | case Scharquote: | 1650 | case Scharquote: |
| 1558 | case Sescape: | 1651 | case Sescape: |
| 1559 | from++; | 1652 | INC_FROM; |
| 1560 | if (from == end) goto endquoted; | 1653 | if (from == end) goto endquoted; |
| 1561 | break; | 1654 | break; |
| 1562 | case Sword: | 1655 | case Sword: |
| @@ -1566,7 +1659,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1566 | default: | 1659 | default: |
| 1567 | goto symdone; | 1660 | goto symdone; |
| 1568 | } | 1661 | } |
| 1569 | from++; | 1662 | INC_FROM; |
| 1570 | } | 1663 | } |
| 1571 | symdone: | 1664 | symdone: |
| 1572 | curlevel->prev = curlevel->last; | 1665 | curlevel->prev = curlevel->last; |
| @@ -1579,7 +1672,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1579 | { | 1672 | { |
| 1580 | /* Enter the loop in the middle so that we find | 1673 | /* Enter the loop in the middle so that we find |
| 1581 | a 2-char comment ender if we start in the middle of it. */ | 1674 | a 2-char comment ender if we start in the middle of it. */ |
| 1582 | prev = FETCH_CHAR (from - 1); | 1675 | prev = FETCH_CHAR (prev_from); |
| 1583 | goto startincomment_1; | 1676 | goto startincomment_1; |
| 1584 | } | 1677 | } |
| 1585 | /* At beginning of buffer, enter the loop the ordinary way. */ | 1678 | /* At beginning of buffer, enter the loop the ordinary way. */ |
| @@ -1598,7 +1691,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1598 | of the same style as the start sequence has been | 1691 | of the same style as the start sequence has been |
| 1599 | encountered. */ | 1692 | encountered. */ |
| 1600 | break; | 1693 | break; |
| 1601 | from++; | 1694 | INC_FROM; |
| 1602 | startincomment_1: | 1695 | startincomment_1: |
| 1603 | if (from < end && SYNTAX_COMEND_FIRST (prev) | 1696 | if (from < end && SYNTAX_COMEND_FIRST (prev) |
| 1604 | && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) | 1697 | && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) |
| @@ -1606,7 +1699,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1606 | /* Only terminate the comment section if the end-comment | 1699 | /* Only terminate the comment section if the end-comment |
| 1607 | sequence of the same style as the start sequence has | 1700 | sequence of the same style as the start sequence has |
| 1608 | been encountered. */ | 1701 | been encountered. */ |
| 1609 | { from++; break; } | 1702 | { INC_FROM; break; } |
| 1610 | } | 1703 | } |
| 1611 | state.incomment = 0; | 1704 | state.incomment = 0; |
| 1612 | state.comstyle = 0; /* reset the comment style */ | 1705 | state.comstyle = 0; /* reset the comment style */ |
| @@ -1616,7 +1709,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1616 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ | 1709 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ |
| 1617 | depth++; | 1710 | depth++; |
| 1618 | /* curlevel++->last ran into compiler bug on Apollo */ | 1711 | /* curlevel++->last ran into compiler bug on Apollo */ |
| 1619 | curlevel->last = from - 1; | 1712 | curlevel->last = prev_from; |
| 1620 | if (++curlevel == endlevel) | 1713 | if (++curlevel == endlevel) |
| 1621 | error ("Nesting too deep for parser"); | 1714 | error ("Nesting too deep for parser"); |
| 1622 | curlevel->prev = -1; | 1715 | curlevel->prev = -1; |
| @@ -1636,26 +1729,29 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1636 | 1729 | ||
| 1637 | case Sstring: | 1730 | case Sstring: |
| 1638 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ | 1731 | if (stopbefore) goto stop; /* this arg means stop at sexp start */ |
| 1639 | curlevel->last = from - 1; | 1732 | curlevel->last = prev_from; |
| 1640 | state.instring = FETCH_CHAR (from - 1); | 1733 | state.instring = FETCH_CHAR (prev_from); |
| 1641 | startinstring: | 1734 | startinstring: |
| 1642 | while (1) | 1735 | while (1) |
| 1643 | { | 1736 | { |
| 1737 | int c; | ||
| 1738 | |||
| 1644 | if (from >= end) goto done; | 1739 | if (from >= end) goto done; |
| 1645 | if (FETCH_CHAR (from) == state.instring) break; | 1740 | c = FETCH_CHAR (from); |
| 1646 | switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from)))) | 1741 | if (c == state.instring) break; |
| 1742 | switch (SWITCH_ENUM_CAST (SYNTAX (c))) | ||
| 1647 | { | 1743 | { |
| 1648 | case Scharquote: | 1744 | case Scharquote: |
| 1649 | case Sescape: | 1745 | case Sescape: |
| 1650 | from++; | 1746 | INC_FROM; |
| 1651 | startquotedinstring: | 1747 | startquotedinstring: |
| 1652 | if (from >= end) goto endquoted; | 1748 | if (from >= end) goto endquoted; |
| 1653 | } | 1749 | } |
| 1654 | from++; | 1750 | INC_FROM; |
| 1655 | } | 1751 | } |
| 1656 | state.instring = -1; | 1752 | state.instring = -1; |
| 1657 | curlevel->prev = curlevel->last; | 1753 | curlevel->prev = curlevel->last; |
| 1658 | from++; | 1754 | INC_FROM; |
| 1659 | break; | 1755 | break; |
| 1660 | 1756 | ||
| 1661 | case Smath: | 1757 | case Smath: |
| @@ -1665,7 +1761,7 @@ scan_sexps_forward (stateptr, from, end, targetdepth, | |||
| 1665 | goto done; | 1761 | goto done; |
| 1666 | 1762 | ||
| 1667 | stop: /* Here if stopping before start of sexp. */ | 1763 | stop: /* Here if stopping before start of sexp. */ |
| 1668 | from--; /* We have just fetched the char that starts it; */ | 1764 | from = prev_from; /* We have just fetched the char that starts it; */ |
| 1669 | goto done; /* but return the position before it. */ | 1765 | goto done; /* but return the position before it. */ |
| 1670 | 1766 | ||
| 1671 | endquoted: | 1767 | endquoted: |
| @@ -1761,15 +1857,21 @@ init_syntax_once () | |||
| 1761 | But don't staticpro it here--that is done in alloc.c. */ | 1857 | But don't staticpro it here--that is done in alloc.c. */ |
| 1762 | Qchar_table_extra_slots = intern ("char-table-extra-slots"); | 1858 | Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
| 1763 | 1859 | ||
| 1860 | /* Create objects which can be shared among syntax tables. */ | ||
| 1861 | Vsyntax_code_object = Fmake_vector (13, Qnil); | ||
| 1862 | for (i = 0; i < XVECTOR (Vsyntax_code_object)->size; i++) | ||
| 1863 | XVECTOR (Vsyntax_code_object)->contents[i] | ||
| 1864 | = Fcons (make_number (i), Qnil); | ||
| 1865 | |||
| 1764 | /* Now we are ready to set up this property, so we can | 1866 | /* Now we are ready to set up this property, so we can |
| 1765 | create syntax tables. */ | 1867 | create syntax tables. */ |
| 1766 | Fput (Qsyntax_table, Qchar_table_extra_slots, make_number (0)); | 1868 | Fput (Qsyntax_table, Qchar_table_extra_slots, make_number (0)); |
| 1767 | 1869 | ||
| 1768 | temp = Fcons (make_number ((int) Swhitespace), Qnil); | 1870 | temp = XVECTOR (Vsyntax_code_object)->contents[(int) Swhitespace]; |
| 1769 | 1871 | ||
| 1770 | Vstandard_syntax_table = Fmake_char_table (Qsyntax_table, temp); | 1872 | Vstandard_syntax_table = Fmake_char_table (Qsyntax_table, temp); |
| 1771 | 1873 | ||
| 1772 | temp = Fcons (make_number ((int) Sword), Qnil); | 1874 | temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword]; |
| 1773 | for (i = 'a'; i <= 'z'; i++) | 1875 | for (i = 'a'; i <= 'z'; i++) |
| 1774 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); | 1876 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
| 1775 | for (i = 'A'; i <= 'Z'; i++) | 1877 | for (i = 'A'; i <= 'Z'; i++) |
| @@ -1797,11 +1899,11 @@ init_syntax_once () | |||
| 1797 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', | 1899 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', |
| 1798 | Fcons (make_number ((int) Sescape), Qnil)); | 1900 | Fcons (make_number ((int) Sescape), Qnil)); |
| 1799 | 1901 | ||
| 1800 | temp = Fcons (make_number ((int) Ssymbol), Qnil); | 1902 | temp = XVECTOR (Vsyntax_code_object)->contents[(int) Ssymbol]; |
| 1801 | for (i = 0; i < 10; i++) | 1903 | for (i = 0; i < 10; i++) |
| 1802 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, "_-+*/&|<>="[i], temp); | 1904 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, "_-+*/&|<>="[i], temp); |
| 1803 | 1905 | ||
| 1804 | temp = Fcons (make_number ((int) Spunct), Qnil); | 1906 | temp = XVECTOR (Vsyntax_code_object)->contents[(int) Spunct]; |
| 1805 | for (i = 0; i < 12; i++) | 1907 | for (i = 0; i < 12; i++) |
| 1806 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ".,;:?!#@~^'`"[i], temp); | 1908 | SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ".,;:?!#@~^'`"[i], temp); |
| 1807 | } | 1909 | } |
| @@ -1811,6 +1913,8 @@ syms_of_syntax () | |||
| 1811 | Qsyntax_table_p = intern ("syntax-table-p"); | 1913 | Qsyntax_table_p = intern ("syntax-table-p"); |
| 1812 | staticpro (&Qsyntax_table_p); | 1914 | staticpro (&Qsyntax_table_p); |
| 1813 | 1915 | ||
| 1916 | staticpro (&Vsyntax_code_object); | ||
| 1917 | |||
| 1814 | Qscan_error = intern ("scan-error"); | 1918 | Qscan_error = intern ("scan-error"); |
| 1815 | staticpro (&Qscan_error); | 1919 | staticpro (&Qscan_error); |
| 1816 | Fput (Qscan_error, Qerror_conditions, | 1920 | Fput (Qscan_error, Qerror_conditions, |