Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-11-26 23:23:18 +0300
committerbubnikv <bubnikv@gmail.com>2017-11-26 23:23:18 +0300
commitbb2b180ecc9d3e3dad063c87e9054ee0829ca9a8 (patch)
tree570823f8cbe73c5adf08d07174372459bb3d935b /xs/src/libslic3r/GCode.cpp
parentb54a15faa2304f9d4326379e3a13a368d3464418 (diff)
Fixed G-code export of custom G-code sections to not add a newline
if the custom G-code already ends with a newline.
Diffstat (limited to 'xs/src/libslic3r/GCode.cpp')
-rw-r--r--xs/src/libslic3r/GCode.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp
index 12444d1a5..3c406389e 100644
--- a/xs/src/libslic3r/GCode.cpp
+++ b/xs/src/libslic3r/GCode.cpp
@@ -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");
}
}