diff options
| author | Stefan Monnier | 2000-02-15 06:21:26 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-02-15 06:21:26 +0000 |
| commit | 1aa963c81342d12f2071fb0db49653117847cd4d (patch) | |
| tree | 11a0f5c8b9740dc9d1f03887342b997340820373 /src/syntax.c | |
| parent | b9b84fd34dce0840095349b5ada09285039f8bff (diff) | |
| download | emacs-1aa963c81342d12f2071fb0db49653117847cd4d.tar.gz emacs-1aa963c81342d12f2071fb0db49653117847cd4d.zip | |
(back_comment): Make sure we only consider comment-starters
of the relevant style and return -1 in case of a failure to find the
beginning of the comment.
(Fforward_comment): If back_comment fails, go back to the position just
after the comment-end.
(scan_lists): Add comment describing a very minor bug.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/syntax.c b/src/syntax.c index ceb48f3ec37..43f49dae9cf 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -508,6 +508,9 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p | |||
| 508 | code = Scomment; | 508 | code = Scomment; |
| 509 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 509 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 510 | } | 510 | } |
| 511 | else if (code == Scomment && comstyle != SYNTAX_COMMENT_STYLE (c)) | ||
| 512 | /* Ignore comment starters of a different style. */ | ||
| 513 | continue; | ||
| 511 | 514 | ||
| 512 | /* Ignore escaped characters, except comment-enders. */ | 515 | /* Ignore escaped characters, except comment-enders. */ |
| 513 | if (code != Sendcomment && char_quoted (from, from_byte)) | 516 | if (code != Sendcomment && char_quoted (from, from_byte)) |
| @@ -539,8 +542,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p | |||
| 539 | } | 542 | } |
| 540 | 543 | ||
| 541 | if (code == Scomment) | 544 | if (code == Scomment) |
| 542 | /* FIXME: we should also check that the comstyle is correct | 545 | /* We've already checked that it is the relevant comstyle. */ |
| 543 | if the Scomment is a single-char. */ | ||
| 544 | { | 546 | { |
| 545 | if (comnested && --nesting <= 0 && parity == 0 && !string_lossage) | 547 | if (comnested && --nesting <= 0 && parity == 0 && !string_lossage) |
| 546 | /* nested comments have to be balanced, so we don't need to | 548 | /* nested comments have to be balanced, so we don't need to |
| @@ -634,7 +636,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p | |||
| 634 | *charpos_ptr = from; | 636 | *charpos_ptr = from; |
| 635 | *bytepos_ptr = from_byte; | 637 | *bytepos_ptr = from_byte; |
| 636 | 638 | ||
| 637 | return from; | 639 | return (from == comment_end) ? -1 : from; |
| 638 | } | 640 | } |
| 639 | 641 | ||
| 640 | DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, | 642 | DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, |
| @@ -1795,6 +1797,8 @@ between them, return t; otherwise return nil.") | |||
| 1795 | INC_BOTH (from, from_byte); | 1797 | INC_BOTH (from, from_byte); |
| 1796 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 1798 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 1797 | } | 1799 | } |
| 1800 | /* FIXME: here we ignore 2-char endcomments while we don't | ||
| 1801 | when going backwards. */ | ||
| 1798 | } | 1802 | } |
| 1799 | while (code == Swhitespace || code == Sendcomment); | 1803 | while (code == Swhitespace || code == Sendcomment); |
| 1800 | 1804 | ||
| @@ -1904,10 +1908,17 @@ between them, return t; otherwise return nil.") | |||
| 1904 | { | 1908 | { |
| 1905 | found = back_comment (from, from_byte, stop, comnested, comstyle, | 1909 | found = back_comment (from, from_byte, stop, comnested, comstyle, |
| 1906 | &out_charpos, &out_bytepos); | 1910 | &out_charpos, &out_bytepos); |
| 1907 | if (found != -1) | 1911 | if (found == -1) |
| 1908 | from = out_charpos, from_byte = out_bytepos; | 1912 | { |
| 1913 | /* Failure: we have to skip the one or two chars of the | ||
| 1914 | not-quite-endcomment. */ | ||
| 1915 | if (SYNTAX(c) != code) | ||
| 1916 | /* It was a two-char Sendcomment. */ | ||
| 1917 | INC_BOTH (from, from_byte); | ||
| 1918 | goto leave; | ||
| 1919 | } | ||
| 1909 | /* We have skipped one comment. */ | 1920 | /* We have skipped one comment. */ |
| 1910 | break; | 1921 | from = out_charpos, from_byte = out_bytepos; |
| 1911 | } | 1922 | } |
| 1912 | else if (code != Swhitespace && code != Scomment) | 1923 | else if (code != Swhitespace && code != Scomment) |
| 1913 | { | 1924 | { |
| @@ -2227,6 +2238,12 @@ scan_lists (from, count, depth, sexpflag) | |||
| 2227 | break; | 2238 | break; |
| 2228 | found = back_comment (from, from_byte, stop, comnested, comstyle, | 2239 | found = back_comment (from, from_byte, stop, comnested, comstyle, |
| 2229 | &out_charpos, &out_bytepos); | 2240 | &out_charpos, &out_bytepos); |
| 2241 | /* FIXME: if found == -1, then it really wasn't a comment-end. | ||
| 2242 | For single-char Sendcomment, we can't do much about it apart | ||
| 2243 | from skipping the char. | ||
| 2244 | For 2-char endcomments, we could try again, taking both | ||
| 2245 | chars as separate entities, but it's a lot of trouble | ||
| 2246 | for very little gain, so we don't bother either. -sm */ | ||
| 2230 | if (found != -1) | 2247 | if (found != -1) |
| 2231 | from = out_charpos, from_byte = out_bytepos; | 2248 | from = out_charpos, from_byte = out_bytepos; |
| 2232 | break; | 2249 | break; |