changeset 16337:6bfd8dbd7d3c

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. (<LINE_COMMENT_START>{S}*{CCHAR}.*{NL}): Unput '\n' here if looking at end of line comment.
author John W. Eaton <jwe@octave.org>
date Tue, 19 Mar 2013 18:03:23 -0400
parents 0ce49f9fb171
children 8aeb5d5c3747
files libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll
diffstat 2 files changed, 6 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h	Tue Mar 19 17:28:53 2013 -0400
+++ b/libinterp/parse-tree/lex.h	Tue Mar 19 18:03:23 2013 -0400
@@ -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);
 
--- a/libinterp/parse-tree/lex.ll	Tue Mar 19 17:28:53 2013 -0400
+++ b/libinterp/parse-tree/lex.ll	Tue Mar 19 18:03:23 2013 -0400
@@ -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