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,10 +264,13 @@ inline void write(FILE *file, const std::string &what)
fwrite(what.data(), 1, what.size(), file); 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) inline void writeln(FILE *file, const std::string &what)
{ {
if (! what.empty()) { if (! what.empty()) {
write(file, what); write(file, what);
if (what.back() != '\n')
fprintf(file, "\n"); fprintf(file, "\n");
} }
} }

View File

@ -597,16 +597,11 @@ namespace client
using namespace qi::labels; using namespace qi::labels;
qi::alpha_type alpha; qi::alpha_type alpha;
qi::alnum_type alnum; qi::alnum_type alnum;
qi::eol_type eol;
qi::eoi_type eoi;
qi::eps_type eps; qi::eps_type eps;
qi::omit_type omit;
qi::raw_type raw; qi::raw_type raw;
qi::lit_type lit; qi::lit_type lit;
qi::lexeme_type lexeme; qi::lexeme_type lexeme;
qi::skip_type skip;
qi::no_skip_type no_skip; qi::no_skip_type no_skip;
qi::uint_type uint_;
qi::real_parser<double, strict_real_policies_without_nan_inf> strict_double; qi::real_parser<double, strict_real_policies_without_nan_inf> strict_double;
spirit::ascii::char_type char_; spirit::ascii::char_type char_;
spirit::bool_type bool_; spirit::bool_type bool_;