Index: lldb/source/Core/IOHandler.cpp =================================================================== --- lldb/source/Core/IOHandler.cpp +++ lldb/source/Core/IOHandler.cpp @@ -372,7 +372,11 @@ Optional got_line = SplitLine(m_line_buffer); - if (!got_line && !m_input_sp) { + if (got_line) { + goto gotLine; + } + + if (!m_input_sp) { // No more input file, we are done... SetIsDone(true); return false; @@ -381,24 +385,8 @@ FILE *in = GetInputFILE(); char buffer[256]; - if (!got_line && !in && m_input_sp) { - // there is no FILE*, fall back on just reading bytes from the stream. - while (!got_line) { - size_t bytes_read = sizeof(buffer); - Status error = m_input_sp->Read((void *)buffer, bytes_read); - if (error.Success() && !bytes_read) { - got_line = SplitLineEOF(m_line_buffer); - break; - } - if (error.Fail()) - break; - m_line_buffer += StringRef(buffer, bytes_read); - got_line = SplitLine(m_line_buffer); - } - } - - if (!got_line && in) { - while (!got_line) { + if (in) { + do { char *r = fgets(buffer, sizeof(buffer), in); #ifdef _WIN32 // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED @@ -422,16 +410,32 @@ } m_line_buffer += buffer; got_line = SplitLine(m_line_buffer); - } + } while (!got_line); + } else { + // there is no FILE*, fall back on just reading bytes from the stream. + do { + size_t bytes_read = sizeof(buffer); + Status error = m_input_sp->Read((void *)buffer, bytes_read); + if (error.Success() && !bytes_read) { + got_line = SplitLineEOF(m_line_buffer); + break; + } + if (error.Fail()) + return false; + m_line_buffer += StringRef(buffer, bytes_read); + got_line = SplitLine(m_line_buffer); + } while (!got_line); } if (got_line) { + gotLine: line = got_line.getValue(); if (m_data_recorder) m_data_recorder->Record(line, true); + return true; } - return (bool)got_line; + return false; } #if LLDB_ENABLE_LIBEDIT