diff options
| author | Stefan Monnier | 2000-10-02 21:59:00 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-10-02 21:59:00 +0000 |
| commit | abf8a9ffcc978497c75a9c32984acf7c8583967d (patch) | |
| tree | 94ea3b198a9c6265878d24f31195ffe840473309 /src/syntax.c | |
| parent | 00ed1b100c6f74f0b0f659799d7abad5df143956 (diff) | |
| download | emacs-abf8a9ffcc978497c75a9c32984acf7c8583967d.tar.gz emacs-abf8a9ffcc978497c75a9c32984acf7c8583967d.zip | |
(forw_comment): Match nestedness of ender/starter.
(Fforward_comment): Treat an unmatched \n comment-ender as whitespace.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/syntax.c b/src/syntax.c index 1b3f9fc9dc3..bb552d9ea05 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1696,7 +1696,8 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, | |||
| 1696 | code = syntax & 0xff; | 1696 | code = syntax & 0xff; |
| 1697 | if (code == Sendcomment | 1697 | if (code == Sendcomment |
| 1698 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style | 1698 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style |
| 1699 | && --nesting <= 0) | 1699 | && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? |
| 1700 | (nesting > 0 && --nesting == 0) : nesting < 0)) | ||
| 1700 | /* we have encountered a comment end of the same style | 1701 | /* we have encountered a comment end of the same style |
| 1701 | as the comment sequence which began this comment | 1702 | as the comment sequence which began this comment |
| 1702 | section */ | 1703 | section */ |
| @@ -1709,6 +1710,7 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, | |||
| 1709 | break; | 1710 | break; |
| 1710 | if (nesting > 0 | 1711 | if (nesting > 0 |
| 1711 | && code == Scomment | 1712 | && code == Scomment |
| 1713 | && SYNTAX_FLAGS_COMMENT_NESTED (syntax) | ||
| 1712 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style) | 1714 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style) |
| 1713 | /* we have encountered a nested comment of the same style | 1715 | /* we have encountered a nested comment of the same style |
| 1714 | as the comment sequence which began this comment section */ | 1716 | as the comment sequence which began this comment section */ |
| @@ -1720,7 +1722,9 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, | |||
| 1720 | if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) | 1722 | if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) |
| 1721 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style | 1723 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style |
| 1722 | && (c1 = FETCH_CHAR (from_byte), | 1724 | && (c1 = FETCH_CHAR (from_byte), |
| 1723 | SYNTAX_COMEND_SECOND (c1))) | 1725 | SYNTAX_COMEND_SECOND (c1)) |
| 1726 | && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) || | ||
| 1727 | SYNTAX_COMMENT_NESTED (c1)) ? nesting > 0 : nesting < 0)) | ||
| 1724 | { | 1728 | { |
| 1725 | if (--nesting <= 0) | 1729 | if (--nesting <= 0) |
| 1726 | /* we have encountered a comment end of the same style | 1730 | /* we have encountered a comment end of the same style |
| @@ -1738,7 +1742,9 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, | |||
| 1738 | && SYNTAX_FLAGS_COMSTART_FIRST (syntax) | 1742 | && SYNTAX_FLAGS_COMSTART_FIRST (syntax) |
| 1739 | && (c1 = FETCH_CHAR (from_byte), | 1743 | && (c1 = FETCH_CHAR (from_byte), |
| 1740 | SYNTAX_COMMENT_STYLE (c1) == style | 1744 | SYNTAX_COMMENT_STYLE (c1) == style |
| 1741 | && SYNTAX_COMSTART_SECOND (c1))) | 1745 | && SYNTAX_COMSTART_SECOND (c1)) |
| 1746 | && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) || | ||
| 1747 | SYNTAX_COMMENT_NESTED (c1))) | ||
| 1742 | /* we have encountered a nested comment of the same style | 1748 | /* we have encountered a nested comment of the same style |
| 1743 | as the comment sequence which began this comment | 1749 | as the comment sequence which began this comment |
| 1744 | section */ | 1750 | section */ |
| @@ -1819,10 +1825,8 @@ between them, return t; otherwise return nil.") | |||
| 1819 | INC_BOTH (from, from_byte); | 1825 | INC_BOTH (from, from_byte); |
| 1820 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 1826 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 1821 | } | 1827 | } |
| 1822 | /* FIXME: here we ignore 2-char endcomments while we don't | ||
| 1823 | when going backwards. */ | ||
| 1824 | } | 1828 | } |
| 1825 | while (code == Swhitespace || code == Sendcomment); | 1829 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); |
| 1826 | 1830 | ||
| 1827 | if (code == Scomment_fence) | 1831 | if (code == Scomment_fence) |
| 1828 | comstyle = ST_COMMENT_STYLE; | 1832 | comstyle = ST_COMMENT_STYLE; |
| @@ -1876,7 +1880,6 @@ between them, return t; otherwise return nil.") | |||
| 1876 | comnested = SYNTAX_COMMENT_NESTED (c); | 1880 | comnested = SYNTAX_COMMENT_NESTED (c); |
| 1877 | if (code == Sendcomment) | 1881 | if (code == Sendcomment) |
| 1878 | comstyle = SYNTAX_COMMENT_STYLE (c); | 1882 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| 1879 | comstart_second = SYNTAX_COMSTART_SECOND (c); | ||
| 1880 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 1883 | if (from > stop && SYNTAX_COMEND_SECOND (c) |
| 1881 | && prev_char_comend_first (from, from_byte) | 1884 | && prev_char_comend_first (from, from_byte) |
| 1882 | && !char_quoted (from - 1, dec_bytepos (from_byte))) | 1885 | && !char_quoted (from - 1, dec_bytepos (from_byte))) |
| @@ -1892,13 +1895,6 @@ between them, return t; otherwise return nil.") | |||
| 1892 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 1895 | comstyle = SYNTAX_COMMENT_STYLE (c1); |
| 1893 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); | 1896 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); |
| 1894 | } | 1897 | } |
| 1895 | if (from > stop && comstart_second | ||
| 1896 | && prev_char_comstart_first (from, from_byte) | ||
| 1897 | && !char_quoted (from - 1, dec_bytepos (from_byte))) | ||
| 1898 | { | ||
| 1899 | code = Scomment; | ||
| 1900 | DEC_BOTH (from, from_byte); | ||
| 1901 | } | ||
| 1902 | 1898 | ||
| 1903 | if (code == Scomment_fence) | 1899 | if (code == Scomment_fence) |
| 1904 | { | 1900 | { |
| @@ -1932,21 +1928,29 @@ between them, return t; otherwise return nil.") | |||
| 1932 | &out_charpos, &out_bytepos); | 1928 | &out_charpos, &out_bytepos); |
| 1933 | if (found == -1) | 1929 | if (found == -1) |
| 1934 | { | 1930 | { |
| 1935 | #if 0 /* cc-mode (and maybe others) relies on the bogus behavior. */ | 1931 | if (c == '\n') |
| 1936 | /* Failure: we should go back to the end of this | 1932 | /* This end-of-line is not an end-of-comment. |
| 1937 | not-quite-endcomment. */ | 1933 | Treat it like a whitespace. |
| 1938 | if (SYNTAX(c) != code) | 1934 | CC-mode (and maybe others) relies on this behavior. */ |
| 1939 | /* It was a two-char Sendcomment. */ | 1935 | ; |
| 1940 | INC_BOTH (from, from_byte); | 1936 | else |
| 1941 | goto leave; | 1937 | { |
| 1942 | #endif | 1938 | /* Failure: we should go back to the end of this |
| 1939 | not-quite-endcomment. */ | ||
| 1940 | if (SYNTAX(c) != code) | ||
| 1941 | /* It was a two-char Sendcomment. */ | ||
| 1942 | INC_BOTH (from, from_byte); | ||
| 1943 | goto leave; | ||
| 1944 | } | ||
| 1943 | } | 1945 | } |
| 1944 | else | 1946 | else |
| 1945 | /* We have skipped one comment. */ | 1947 | { |
| 1946 | from = out_charpos, from_byte = out_bytepos; | 1948 | /* We have skipped one comment. */ |
| 1947 | break; | 1949 | from = out_charpos, from_byte = out_bytepos; |
| 1950 | break; | ||
| 1951 | } | ||
| 1948 | } | 1952 | } |
| 1949 | else if (code != Swhitespace && code != Scomment) | 1953 | else if (code != Swhitespace) |
| 1950 | { | 1954 | { |
| 1951 | leave: | 1955 | leave: |
| 1952 | immediate_quit = 0; | 1956 | immediate_quit = 0; |