gcode: keep line endins in post processing (#8092)

Some portions of GCode (like BTT_TFT thumbnails)  has to be CRLF in
order to work correctly. However, gcode post processor was ignoring
input line endings style emitting '\n' (LF) into post-processed output.
This commit is contained in:
Dima Buzdyk 2025-01-20 08:34:03 +06:00 committed by GitHub
parent 2ea2ab08de
commit 330ac879c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5018,9 +5018,18 @@ void GCodeProcessor::run_post_process()
// End of line is indicated also if end of file was reached.
eol |= eof && it_end == it_bufend;
gcode_line.insert(gcode_line.end(), it, it_end);
it = it_end;
// append EOL.
if (it != it_bufend && *it == '\r') {
gcode_line += *it++;
}
if (it != it_bufend && *it == '\n') {
gcode_line += *it++;
}
if (eol) {
++line_id;
gcode_line += "\n";
const unsigned int internal_g1_lines_counter = export_lines.update(gcode_line, line_id, g1_lines_counter);
// replace placeholder lines
bool processed = process_placeholders(gcode_line);
@ -5057,12 +5066,6 @@ void GCodeProcessor::run_post_process()
export_lines.write(out, 1.1f * max_backtrace_time, m_result, out_path);
gcode_line.clear();
}
// Skip EOL.
it = it_end;
if (it != it_bufend && *it == '\r')
++it;
if (it != it_bufend && *it == '\n')
++it;
}
if (eof)
break;