From a04c2e28e731039cf154041423fa5a3f71618d2d Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sun, 12 May 2002 01:02:17 +0000 Subject: [PATCH] Default argument patch from Fabien Constantini. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2207 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ fluid/Fl_Function_Type.cxx | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 52da1824a..2ba39f8d2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ CHANGES IN FLTK 1.1.0rc2 - Portability fixes. + - FLUID now properly handles default argument parameters + properly. - Fixed WM_PAINT handling under WIN32 - didn't validate the correct region that was drawn. - Fl_Multiline_Output would insert the enter key. diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 661379cc7..8d232c6c2 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.4 2002/05/04 05:28:11 easysw Exp $" +// "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.5 2002/05/12 01:02:17 easysw Exp $" // // C function type code for the Fast Light Tool Kit (FLTK). // @@ -257,7 +257,29 @@ void Fl_Function_Type::write_code1() { *sptr = '\0'; write_h("%s;\n", s); - write_c("%s::%s {\n", k, name()); + // skip all function default param. init in body: + int skips=0; + int nc=0,level=0; + for (sptr=s,nptr=(char*)name(); *nptr; nc++,nptr++) { + if (!skips && *nptr=='(') level++; + else if (!skips && *nptr==')') level--; + + if ( *nptr=='"' && !(nc && *(nptr-1)=='\\') ) + skips = skips ? 0 : 1; + if(!skips && level==1 && *nptr =='=' && + !(nc && *(nptr-1)=='\'') ) // ignore '=' case + while(*++nptr && (skips || *(nptr-1)=='\'' || + (*nptr!=',' && (*nptr!=')' || level!=1) ))) { + if ( *nptr=='"' && *(nptr-1)!='\\' ) + skips = skips ? 0 : 1; + if (!skips && *nptr=='(') level++; + else if (!skips && *nptr==')') level--; + } + *sptr++ = *nptr; + } + *sptr = '\0'; + + write_c("%s::%s {\n", k, s); } else { if (public_) { if (cdecl_) @@ -680,5 +702,5 @@ void Fl_Class_Type::write_code2() { } // -// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.4 2002/05/04 05:28:11 easysw Exp $". +// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.5 2002/05/12 01:02:17 easysw Exp $". //