# HG changeset patch # User Karl Heuer # Date 762586275 0 # Node ID 2dbc79d0119131999099d58300e643e53d6b1ee0 # Parent fefa088fc7f9508ba8e4e5ec248be3e2f880fd82 (Fforward_comment): Do the right thing at eob. diff -r fefa088fc7f9 -r 2dbc79d01191 src/syntax.c --- a/src/syntax.c Wed Mar 02 05:29:01 1994 +0000 +++ b/src/syntax.c Wed Mar 02 05:31:15 1994 +0000 @@ -599,8 +599,13 @@ while (count1 > 0) { stop = ZV; - while (from < stop) + do { + if (from == stop) + { + SET_PT (from); + return Qnil; + } c = FETCH_CHAR (from); code = SYNTAX (c); from++; @@ -617,45 +622,40 @@ comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); from++; } - - if (code == Scomment) - { - while (1) - { - if (from == stop) - { - immediate_quit = 0; - SET_PT (from); - return Qnil; - } - c = FETCH_CHAR (from); - if (SYNTAX (c) == Sendcomment - && SYNTAX_COMMENT_STYLE (c) == comstyle) - /* we have encountered a comment end of the same style - as the comment sequence which began this comment - section */ - break; - from++; - if (from < stop && SYNTAX_COMEND_FIRST (c) - && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) - && SYNTAX_COMMENT_STYLE (c) == comstyle) - /* we have encountered a comment end of the same style - as the comment sequence which began this comment - section */ - { from++; break; } - } - /* We have skipped one comment. */ - break; - } - else if (code != Swhitespace && code != Sendcomment) + } + while (code == Swhitespace || code == Sendcomment); + if (code != Scomment) + { + immediate_quit = 0; + SET_PT (from - 1); + return Qnil; + } + /* We're at the start of a comment. */ + while (1) + { + if (from == stop) { immediate_quit = 0; - SET_PT (from - 1); + SET_PT (from); return Qnil; } + c = FETCH_CHAR (from); + if (SYNTAX (c) == Sendcomment + && SYNTAX_COMMENT_STYLE (c) == comstyle) + /* we have encountered a comment end of the same style + as the comment sequence which began this comment + section */ + break; + from++; + if (from < stop && SYNTAX_COMEND_FIRST (c) + && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) + && SYNTAX_COMMENT_STYLE (c) == comstyle) + /* we have encountered a comment end of the same style + as the comment sequence which began this comment + section */ + { from++; break; } } - - /* End of comment reached */ + /* We have skipped one comment. */ count1--; }