Support loading files that do not end with a EOL sequence

- do not drop the last line of such files from TextLoader
- add a flag to TextLoader to indicate if the loaded file ended with a
  EOL sequence
This commit is contained in:
josh committed 2016-07-24 12:22:03 -04:00
1 parent 89e8dc5de3
commit 7093560a94
3 files changed
+32 -10

No files matched your search

+10 -3
View File
@@ -60,16 +60,23 @@ void TextLoader::load_buffer(uint8_t * buffer, size_t size)
if (crlf && (n_lf > 0u))
{
m_line_endings = LINE_ENDING_CRLF;
m_lines = lines[LINE_ENDING_CRLF];
}
else if ((n_cr > 0u) && (n_lf == 0u))
{
m_line_endings = LINE_ENDING_CR;
m_lines = lines[LINE_ENDING_CR];
}
else
{
m_line_endings = LINE_ENDING_LF;
m_lines = lines[LINE_ENDING_LF];
}
m_lines = lines[m_line_endings];
/* Check if there is a line that was not terminated by a EOL sequence at
* the end of the file. */
if (line_start[m_line_endings] < size)
{
m_lines->push_back(LineIndexPair(&buffer[line_start[m_line_endings]], size - line_start[m_line_endings]));
m_eol_at_eof = false;
}
}