Skip to content

Commit

Permalink
Don't append a semicolon to callback function code when the last line
Browse files Browse the repository at this point in the history
is blank or is a preprocessor directive.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1856 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Dec 17, 2001
1 parent d7ee0df commit 12e9d23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES
@@ -1,5 +1,8 @@
CHANGES IN FLTK 1.1.0b8

- Updated FLUID to only append a trailing semicolon to
code lines in a callback (so "#include" and friends
will work...)
- The Fl_Color_Chooser widget now supports keyboard
navigation.
- Fixed button and valuator widgets to call Fl::focus()
Expand Down
13 changes: 10 additions & 3 deletions fluid/Fl_Menu_Type.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_Type.cxx,v 1.16.2.12.2.2 2001/10/30 17:40:02 easysw Exp $"
// "$Id: Fl_Menu_Type.cxx,v 1.16.2.12.2.3 2001/12/17 01:02:16 easysw Exp $"
//
// Menu item code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -149,7 +149,14 @@ void Fl_Menu_Item_Type::write_static() {
write_c(", %s", ut);
if (use_v) write_c(" v");
write_c(") {\n %s", callback());
if (*(d-1) != ';') write_c(";");
if (*(d-1) != ';') {
const char *p = strrchr(callback(), '\n');
if (p) p ++;
else p = callback();
// Only add trailing semicolon if the last line is not a preprocessor
// statement...
if (*p != '#' && *p) write_c(";");
}
write_c("\n}\n");
if (k) {
write_c("void %s::%s(Fl_Menu_* o, %s v) {\n", k, cn, ut);
Expand Down Expand Up @@ -460,5 +467,5 @@ void shortcut_in_cb(Shortcut_Button* i, void* v) {
}

//
// End of "$Id: Fl_Menu_Type.cxx,v 1.16.2.12.2.2 2001/10/30 17:40:02 easysw Exp $".
// End of "$Id: Fl_Menu_Type.cxx,v 1.16.2.12.2.3 2001/12/17 01:02:16 easysw Exp $".
//
13 changes: 10 additions & 3 deletions fluid/Fl_Widget_Type.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.8 2001/11/25 16:38:11 easysw Exp $"
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.9 2001/12/17 01:02:16 easysw Exp $"
//
// Widget type code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -1423,7 +1423,14 @@ void Fl_Widget_Type::write_static() {
write_c(", %s", ut);
if (use_v) write_c(" v");
write_c(") {\n %s", callback());
if (*(d-1) != ';') write_c(";");
if (*(d-1) != ';') {
const char *p = strrchr(callback(), '\n');
if (p) p ++;
else p = callback();
// Only add trailing semicolon if the last line is not a preprocessor
// statement...
if (*p != '#' && *p) write_c(";");
}
write_c("\n}\n");
if (k) {
write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut);
Expand Down Expand Up @@ -1963,5 +1970,5 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) {
}

//
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.8 2001/11/25 16:38:11 easysw Exp $".
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.9 2001/12/17 01:02:16 easysw Exp $".
//

0 comments on commit 12e9d23

Please sign in to comment.