From 3702edc89dddcbc63166a543c3ae24ffceebdaaf Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 19 Feb 1999 14:53:04 +0000 Subject: Added comment parsing in _c_check(). git-svn-id: file:///fltk/svn/fltk/trunk@304 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/Fl_Function_Type.cxx | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'fluid') diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index dac17f78a..3b19bdb64 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Function_Type.cxx,v 1.14 1999/02/19 14:33:22 mike Exp $" +// "$Id: Fl_Function_Type.cxx,v 1.15 1999/02/19 14:53:04 mike Exp $" // // C function type code for the Fast Light Tool Kit (FLTK). // @@ -32,7 +32,6 @@ //////////////////////////////////////////////////////////////// // quick check of any C code for legality, returns an error message -// these currently require comments to parse correctly! static char buffer[128]; // for error messages @@ -58,15 +57,36 @@ const char *_c_check(const char * & c, int type) { if (!type) return 0; sprintf(buffer, "missing %c", type); return buffer; + case '/': + // Skip comments as needed... + if (*c == '/') { + while (*c != '\n' && *c) c++; + } else if (*c == '*') { + c++; + while ((*c != '*' || c[1] != '/') && *c) c++; + if (*c == '*') c+=2; + else { + return "unterminated /* ... */ comment"; + } + } + break; case '{': if (type==')') goto UNEXPECTED; - d = _c_check(c,'}'); if (d) return d; break; + d = _c_check(c,'}'); + if (d) return d; + break; case '(': - d = _c_check(c,')'); if (d) return d; break; + d = _c_check(c,')'); + if (d) return d; + break; case '\"': - d = _q_check(c,'\"'); if (d) return d; break; + d = _q_check(c,'\"'); + if (d) return d; + break; case '\'': - d = _q_check(c,'\''); if (d) return d; break; + d = _q_check(c,'\''); + if (d) return d; + break; case '}': case ')': case '#': @@ -709,5 +729,5 @@ void Fl_Class_Type::write_code2() { } // -// End of "$Id: Fl_Function_Type.cxx,v 1.14 1999/02/19 14:33:22 mike Exp $". +// End of "$Id: Fl_Function_Type.cxx,v 1.15 1999/02/19 14:53:04 mike Exp $". // -- cgit v1.2.3