Fixed G-code export of custom G-code sections to not add a newline

if the custom G-code already ends with a newline.
This commit is contained in:
bubnikv 2017-11-26 21:23:18 +01:00
parent b54a15faa2
commit bb2b180ecc
2 changed files with 4 additions and 6 deletions

View file

@ -264,11 +264,14 @@ inline void write(FILE *file, const std::string &what)
fwrite(what.data(), 1, what.size(), file);
}
// Write a string into a file. Add a newline, if the string does not end with a newline already.
// Used to export a custom G-code section processed by the PlaceholderParser.
inline void writeln(FILE *file, const std::string &what)
{
if (! what.empty()) {
write(file, what);
fprintf(file, "\n");
if (what.back() != '\n')
fprintf(file, "\n");
}
}