diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-11 18:45:14 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-11 18:48:42 +0200 |
| commit | 8a3d3684acd4f13da57e39060ed2a88e625a1d2d (patch) | |
| tree | efe816b88b3767f7d3aa07f72b99bf33db88dde9 /fluid | |
| parent | e5fbfcbec1fb06dc29393a70594317904610a426 (diff) | |
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
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Function_Type.cxx | 19 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 2 | ||||
| -rw-r--r-- | fluid/code.cxx | 16 | ||||
| -rw-r--r-- | fluid/widget_panel.cxx | 2 | ||||
| -rw-r--r-- | fluid/widget_panel.fl | 3 |
5 files changed, 34 insertions, 8 deletions
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); } } } diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 6512ae317..7b008f092 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -874,8 +874,10 @@ int write_declare(const char *, ...) __fl_attr((__format__ (__printf__, 1, 2))); int is_id(char); const char* unique_id(void* o, const char*, const char*, const char*); void write_c(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2))); +void write_cc(const char *, int, const char*, const char*); void vwrite_c(const char* format, va_list args); void write_h(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2))); +void write_hc(const char *, int, const char*, const char*); void write_cstring(const char *); void write_cstring(const char *,int length); void write_cdata(const char *,int length); diff --git a/fluid/code.cxx b/fluid/code.cxx index b782ee35f..7b156f57e 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -283,6 +283,14 @@ void write_c(const char* format,...) { va_end(args); } +// write code (c) of size (n) to C file, with optional comment (com) w/o trailing space +void write_cc(const char *indent, int n, const char *c, const char *com) { + if (*com) + write_c("%s%.*s; %s\n", indent, n, c, com); + else + write_c("%s%.*s;\n", indent, n, c); +} + void write_h(const char* format,...) { if (varused_test) return; va_list args; @@ -291,6 +299,14 @@ void write_h(const char* format,...) { va_end(args); } +// write code (c) of size (n) to H file, with optional comment (com) w/o trailing space +void write_hc(const char *indent, int n, const char* c, const char *com) { + if (*com) + write_h("%s%.*s; %s\n", indent, n, c, com); + else + write_h("%s%.*s;\n", indent, n, c); +} + #include <FL/filename.H> int write_number; int write_sourceview; diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx index 0695342ab..f6a7caf38 100644 --- a/fluid/widget_panel.cxx +++ b/fluid/widget_panel.cxx @@ -413,7 +413,7 @@ ive to the origin at construction time"); } // Fl_Group* o { // This is a special button that grabs keystrokes directly Shortcut_Button* o = new Shortcut_Button(95, 210, 310, 20, "Shortcut:"); - o->tooltip("The shortcut key for the widget.\nUse 'Backspace' key to clear."); + o->tooltip("The shortcut key for the widget.\nUse \'Backspace\' key to clear."); o->box(FL_DOWN_BOX); o->color(FL_BACKGROUND2_COLOR); o->selection_color(FL_BACKGROUND2_COLOR); diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl index 87d8e53d0..5ad384d95 100644 --- a/fluid/widget_panel.fl +++ b/fluid/widget_panel.fl @@ -362,7 +362,8 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 1 te label {Shortcut:} callback shortcut_in_cb comment {This is a special button that grabs keystrokes directly} - tooltip {The shortcut key for the widget.\nUse 'Backspace' key to clear.} xywh {95 210 310 20} box DOWN_BOX color 7 selection_color 7 labelfont 1 labelsize 11 align 4 + tooltip {The shortcut key for the widget. +Use 'Backspace' key to clear.} xywh {95 210 310 20} box DOWN_BOX color 7 selection_color 7 labelfont 1 labelsize 11 align 4 code0 {\#include "Shortcut_Button.h"} class Shortcut_Button } |
