# HG changeset patch # User John W. Eaton # Date 1363730603 14400 # Node ID 6bfd8dbd7d3c47236fc064d3d70e2d843d19a96a # Parent 0ce49f9fb1713c74bc988b7aa7a4b9707de5ef95 don't swallow statements that follow comment lines (bug #38549) * lex.h, lex.ll (finish_comment): Delete second arg, looking_at_continuation. Never unput '\n'. Change all callers. ({S}*{CCHAR}.*{NL}): Unput '\n' here if looking at end of line comment. diff --git a/libinterp/parse-tree/lex.h b/libinterp/parse-tree/lex.h --- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -526,8 +526,7 @@ void handle_continuation (void); - void finish_comment (octave_comment_elt::comment_type typ, - bool looking_at_continuation = false); + void finish_comment (octave_comment_elt::comment_type typ); bool have_continuation (bool trailing_comments_ok = true); diff --git a/libinterp/parse-tree/lex.ll b/libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -537,6 +537,9 @@ curr_lexer->finish_comment (octave_comment_elt::end_of_line); curr_lexer->pop_start_state (); + + curr_lexer->xunput ('\n'); + curr_lexer->input_line_number--; } } @@ -2116,7 +2119,7 @@ { comment_text = &yytxt[offset]; - finish_comment (octave_comment_elt::end_of_line, true); + finish_comment (octave_comment_elt::end_of_line); } decrement_promptflag (); @@ -2125,8 +2128,7 @@ } void -octave_base_lexer::finish_comment (octave_comment_elt::comment_type typ, - bool looking_at_continuation) +octave_base_lexer::finish_comment (octave_comment_elt::comment_type typ) { bool copyright = looks_like_copyright (comment_text); @@ -2142,13 +2144,6 @@ comment_text = ""; at_beginning_of_statement = true; - - if (! looking_at_continuation) - { - xunput ('\n'); - // Adjust for newline that was not really in the input stream. - input_line_number--; - } } // We have seen a backslash and need to find out if it should be