From bb2b180ecc9d3e3dad063c87e9054ee0829ca9a8 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Sun, 26 Nov 2017 21:23:18 +0100 Subject: [PATCH] Fixed G-code export of custom G-code sections to not add a newline if the custom G-code already ends with a newline. --- xs/src/libslic3r/GCode.cpp | 5 ++++- xs/src/libslic3r/PlaceholderParser.cpp | 5 ----- 2 files changed, 4 insertions(+), 6 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"); } } diff --git a/xs/src/libslic3r/PlaceholderParser.cpp b/xs/src/libslic3r/PlaceholderParser.cpp index 655913d90..fbe8572d5 100644 --- a/xs/src/libslic3r/PlaceholderParser.cpp +++ b/xs/src/libslic3r/PlaceholderParser.cpp @@ -597,16 +597,11 @@ namespace client using namespace qi::labels; qi::alpha_type alpha; qi::alnum_type alnum; - qi::eol_type eol; - qi::eoi_type eoi; qi::eps_type eps; - qi::omit_type omit; qi::raw_type raw; qi::lit_type lit; qi::lexeme_type lexeme; - qi::skip_type skip; qi::no_skip_type no_skip; - qi::uint_type uint_; qi::real_parser strict_double; spirit::ascii::char_type char_; spirit::bool_type bool_;