changeset 27760:16e83787f970

fix handling of full line comments at command prompt (bug #57208) * lex.ll (<LINE_COMMENT_START>{ANY_INCLUDING_NL}): Don't unput the ASCII 1 marker that may have been inserted by push_lexer::fill_flex_buffer.
author John W. Eaton <jwe@octave.org>
date Sun, 01 Dec 2019 19:51:35 -0600
parents 992e702ef0d7
children 223981108144
files libinterp/parse-tree/lex.ll
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Sat Nov 23 11:47:16 2019 +0100
+++ b/libinterp/parse-tree/lex.ll	Sun Dec 01 19:51:35 2019 -0600
@@ -792,13 +792,18 @@
   }
 
 %{
-// End of a series of full-line comments.
+// End of a series of full-line because some other character was
+// found on the input stream.
 %}
 
 <LINE_COMMENT_START>{ANY_INCLUDING_NL} {
     curr_lexer->lexer_debug ("<LINE_COMMENT_START>{ANY_INCLUDING_NL}");
 
-    curr_lexer->xunput (yytext[0]);
+    // Restore all characters except the ASCII 1 marker that was
+    // inserted by push_lexer::fill_flex_buffer.
+
+    if (yytext[0] != '\001')
+      curr_lexer->xunput (yytext[0]);
 
     curr_lexer->finish_comment (octave::comment_elt::full_line);
 
@@ -3756,9 +3761,15 @@
   {
     int status = 0;
 
+    // If the input buffer is empty or we are at the end of the buffer,
+    // insert ASCII 1 as a marker for subsequent rules.
+
     if (m_input_buf.empty () && ! m_input_buf.at_eof ())
       m_input_buf.fill (std::string (1, static_cast<char> (1)), false);
 
+    // Note that the copy_chunk function may append a newline character
+    // to the input.
+
     if (! m_input_buf.empty ())
       status = m_input_buf.copy_chunk (buf, max_size);
     else