Fixed visualization of G-code in G-code viewer after 07e7e11590
The line end positions were not extracted correctly from G-code
imported into a stand-alone G-code viewer.
This commit is contained in:
Vojtech Bubnik 2021-10-18 15:46:13 +02:00
parent dac810951d
commit c313e6793a

View File

@ -152,7 +152,7 @@ bool GCodeReader::parse_file_raw_internal(const std::string &filename, ParseLine
auto it_end = it; auto it_end = it;
for (; it_end != it_bufend && ! (eol = *it_end == '\r' || *it_end == '\n'); ++ it_end) for (; it_end != it_bufend && ! (eol = *it_end == '\r' || *it_end == '\n'); ++ it_end)
if (*it_end == '\n') if (*it_end == '\n')
line_end_callback((it_end - buffer.begin()) + 1); line_end_callback(file_pos + (it_end - buffer.begin()) + 1);
// End of line is indicated also if end of file was reached. // End of line is indicated also if end of file was reached.
eol |= eof && it_end == it_bufend; eol |= eof && it_end == it_bufend;
if (eol) { if (eol) {
@ -173,7 +173,7 @@ bool GCodeReader::parse_file_raw_internal(const std::string &filename, ParseLine
if (it != it_bufend && *it == '\r') if (it != it_bufend && *it == '\r')
++ it; ++ it;
if (it != it_bufend && *it == '\n') { if (it != it_bufend && *it == '\n') {
line_end_callback((it - buffer.begin()) + 1); line_end_callback(file_pos + (it - buffer.begin()) + 1);
++ it; ++ it;
} }
} }