From 8a3d3684acd4f13da57e39060ed2a88e625a1d2d Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 11 Jul 2020 18:45:14 +0200 Subject: Fluid: fix "trailing whitespace" errors (#100) Fluid would write trailing whitespace at some points when generating .cxx and .h files from .fl files. This was an old issue but became obvious since we removed trailing whitespace from source and header files recently. This commit fixes all whitespace errors in files generated from .fl files in the FLTK repository, i.e. in fluid/, src/, and test/ folders. I can't guarantee that I found all possible whitespace errors, but this commit: Fixes #100 --- fluid/Fl_Function_Type.cxx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'fluid/Fl_Function_Type.cxx') diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index d39e2164d..f6e8f5b29 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -500,10 +500,16 @@ void Fl_Code_Type::write_code1() { while( (pch=strchr(c,'\n')) ) { int line_len = pch - c; - write_c("%s%.*s\n", ind, line_len, c); + if (line_len < 1) + write_c("\n"); + else + write_c("%s%.*s\n", ind, line_len, c); c = pch+1; } - write_c("%s%s\n", ind, c); + if (*c) + write_c("%s%s\n", ind, c); + else + write_c("\n"); } void Fl_Code_Type::write_code2() {} @@ -738,23 +744,24 @@ void Fl_Decl_Type::write_code1() { if (class_name(1)) { write_public(public_); write_comment_h(" "); - write_h(" %.*s; %s\n", (int)(e-c), c, csc); + write_hc(" ", int(e-c), c, csc); } else { if (public_) { if (static_) write_h("extern "); else write_comment_h(); - write_h("%.*s; %s\n", (int)(e-c), c, csc); + write_hc("", int(e-c), c, csc); + if (static_) { write_comment_c(); - write_c("%.*s; %s\n", (int)(e-c), c, csc); + write_cc("", int(e-c), c, csc); } } else { write_comment_c(); if (static_) write_c("static "); - write_c("%.*s; %s\n", (int)(e-c), c, csc); + write_cc("", int(e-c), c, csc); } } } -- cgit v1.2.3