# HG changeset patch # User John W. Eaton # Date 1582143688 18000 # Node ID 2a186f34eb96831a458b87aac8c99f258424ecd5 # Parent b0f94905509717e8677475ef9236b83f76f0524e in push lexer, don't insert NL with ASCII 1 marker (bug #57859) * lex.ll (push_lexer::fill_flex_buffer): Avoid inserting newline character in buffer after ASCII 1 marker used to tell lexer to get more input. diff -r b0f949055097 -r 2a186f34eb96 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Mon Feb 17 17:37:20 2020 +0100 +++ b/libinterp/parse-tree/lex.ll Wed Feb 19 15:21:28 2020 -0500 @@ -3798,19 +3798,30 @@ { 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 (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); + { + // If the input buffer is empty or we are at the end of the + // buffer, insert ASCII 1 as a marker for subsequent rules. + // Don't insert a newline character in this case. Instead of + // calling input_buffer::fill followed immediately by + // input_buffer::copy_chunk, simply insert the marker directly + // in BUF. + + assert (max_size > 0); + + buf[0] = static_cast (1); + status = 1; + } else - status = YY_NULL; + { + // 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 + status = YY_NULL; + } return status; }