From: <wsf...@us...> - 2012-11-20 23:29:41
|
Revision: 13924 http://swig.svn.sourceforge.net/swig/?rev=13924&view=rev Author: wsfulton Date: 2012-11-20 23:29:35 +0000 (Tue, 20 Nov 2012) Log Message: ----------- Remove unnecessary null checks or fix potential null dereferences Modified Paths: -------------- trunk/Source/Modules/modula3.cxx trunk/Source/Modules/ocaml.cxx trunk/Source/Modules/perl5.cxx trunk/Source/Modules/python.cxx trunk/Source/Modules/r.cxx Modified: trunk/Source/Modules/modula3.cxx =================================================================== --- trunk/Source/Modules/modula3.cxx 2012-11-20 23:29:07 UTC (rev 13923) +++ trunk/Source/Modules/modula3.cxx 2012-11-20 23:29:35 UTC (rev 13924) @@ -2096,7 +2096,7 @@ stem += Len(pat.prefix); } String *newname; - if (Strcmp(srcstyle, "underscore") == 0) { + if (srcstyle && Strcmp(srcstyle, "underscore") == 0) { if (newprefix != NIL) { String *newstem = nameToModula3(stem, true); newname = NewStringf("%s%s", newprefix, newstem); @@ -2214,17 +2214,19 @@ List *baselist = Getattr(n, "bases"); if (baselist != NIL) { Iterator base = First(baselist); - c_baseclassname = Getattr(base.item, "name"); - baseclass = Copy(getProxyName(c_baseclassname)); - if (baseclass) { - c_baseclass = SwigType_namestr(Getattr(base.item, "name")); + if (base.item) { + c_baseclassname = Getattr(base.item, "name"); + baseclass = Copy(getProxyName(c_baseclassname)); + if (baseclass) { + c_baseclass = SwigType_namestr(Getattr(base.item, "name")); + } + base = Next(base); + if (base.item != NIL) { + Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", + name, Getattr(base.item, "name")); + } } - base = Next(base); - if (base.item != NIL) { - Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", - name, Getattr(base.item, "name")); - } } bool derived = baseclass && getProxyName(c_baseclassname); @@ -2460,12 +2462,14 @@ /* Look for the first (principal?) base class - Modula 3 does not support multiple inheritance */ Iterator base = First(baselist); - Append(baseclassname, Getattr(base.item, "sym:name")); - base = Next(base); - if (base.item != NIL) { - Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", - proxy_class_name, Getattr(base.item, "name")); + if (base.item) { + Append(baseclassname, Getattr(base.item, "sym:name")); + base = Next(base); + if (base.item) { + Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", + proxy_class_name, Getattr(base.item, "name")); + } } } } Modified: trunk/Source/Modules/ocaml.cxx =================================================================== --- trunk/Source/Modules/ocaml.cxx 2012-11-20 23:29:07 UTC (rev 13923) +++ trunk/Source/Modules/ocaml.cxx 2012-11-20 23:29:35 UTC (rev 13924) @@ -1256,13 +1256,12 @@ Printv(qtype, name, NIL); } - if (const_enum && name && !Getattr(seen_enumvalues, name)) { + if (const_enum && qtype && name && !Getattr(seen_enumvalues, name)) { Setattr(seen_enumvalues, name, "true"); SetFlag(n, "feature:immutable"); Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used - if (qtype) - Setattr(n, "qualified:name", SwigType_namestr(qtype)); + Setattr(n, "qualified:name", SwigType_namestr(qtype)); String *evname = SwigType_manglestr(qtype); Insert(evname, 0, "SWIG_ENUM_"); Modified: trunk/Source/Modules/perl5.cxx =================================================================== --- trunk/Source/Modules/perl5.cxx 2012-11-20 23:29:07 UTC (rev 13923) +++ trunk/Source/Modules/perl5.cxx 2012-11-20 23:29:35 UTC (rev 13924) @@ -1638,8 +1638,8 @@ while (fgets(buffer, 4095, f)) { Printf(pragma_include, "%s", buffer); } + fclose(f); } - fclose(f); } } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); Modified: trunk/Source/Modules/python.cxx =================================================================== --- trunk/Source/Modules/python.cxx 2012-11-20 23:29:07 UTC (rev 13923) +++ trunk/Source/Modules/python.cxx 2012-11-20 23:29:35 UTC (rev 13924) @@ -1163,9 +1163,9 @@ autodoc_l autodoc_level(String *autodoc) { autodoc_l dlevel = NO_AUTODOC; - if (autodoc) { - char *c = Char(autodoc); - if (c && isdigit(c[0])) { + char *c = Char(autodoc); + if (c) { + if (isdigit(c[0])) { dlevel = (autodoc_l) atoi(c); } else { if (strcmp(c, "extended") == 0) { Modified: trunk/Source/Modules/r.cxx =================================================================== --- trunk/Source/Modules/r.cxx 2012-11-20 23:29:07 UTC (rev 13923) +++ trunk/Source/Modules/r.cxx 2012-11-20 23:29:35 UTC (rev 13924) @@ -1609,7 +1609,6 @@ String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0); if (tmcheck) { - String *tmp = NewString(""); Printf(tmp, "argv[[%d]]", j+1); Replaceall(tmcheck, "$arg", tmp); @@ -1626,32 +1625,34 @@ tmcheck); p = Getattr(p, "tmap:in:next"); continue; - } - if (DohStrcmp(tm,"numeric")==0) { + } + if (tm) { + if (Strcmp(tm,"numeric")==0) { Printf(f->code, "%sis.numeric(argv[[%d]])", - j == 0 ? "" : " && ", - j+1); + j == 0 ? "" : " && ", + j+1); } - else if (DohStrcmp(tm,"integer")==0) { + else if (Strcmp(tm,"integer")==0) { Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", - j == 0 ? "" : " && ", - j+1, j+1); + j == 0 ? "" : " && ", + j+1, j+1); } - else if (DohStrcmp(tm,"character")==0) { + else if (Strcmp(tm,"character")==0) { Printf(f->code, "%sis.character(argv[[%d]])", - j == 0 ? "" : " && ", - j+1); + j == 0 ? "" : " && ", + j+1); } else { Printf(f->code, "%sextends(argtypes[%d], '%s')", - j == 0 ? "" : " && ", - j+1, - tm); + j == 0 ? "" : " && ", + j+1, + tm); } - if (!SwigType_ispointer(Getattr(p, "type"))) { - Printf(f->code, " && length(argv[[%d]]) == 1", - j+1); - } + } + if (!SwigType_ispointer(Getattr(p, "type"))) { + Printf(f->code, " && length(argv[[%d]]) == 1", + j+1); + } p = Getattr(p, "tmap:in:next"); } Printf(f->code, ") { f <- %s%s; }\n", sfname, overname); @@ -1845,18 +1846,21 @@ String *lname = Getattr(p,"lname"); // R keyword renaming - if (name && Swig_name_warning(p, 0, name, 0)) - name = 0; - - /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then - we need to remove that prefix. */ - while (Strstr(name, "::")) { - //XXX need to free. - name = NewStringf("%s", Strchr(name, ':') + 2); - if (debugMode) - Printf(stdout, "+++ parameter name with :: in it %s\n", name); + if (name) { + if (Swig_name_warning(p, 0, name, 0)) { + name = 0; + } else { + /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then + we need to remove that prefix. */ + while (Strstr(name, "::")) { + //XXX need to free. + name = NewStringf("%s", Strchr(name, ':') + 2); + if (debugMode) + Printf(stdout, "+++ parameter name with :: in it %s\n", name); + } + } } - if (Len(name) == 0) + if (!name || Len(name) == 0) name = NewStringf("s_arg%d", i+1); name = replaceInitialDash(name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2012-11-23 07:38:11
|
Revision: 13932 http://swig.svn.sourceforge.net/swig/?rev=13932&view=rev Author: wsfulton Date: 2012-11-23 07:38:00 +0000 (Fri, 23 Nov 2012) Log Message: ----------- Remove some unused code and pointless variable assignments Modified Paths: -------------- trunk/Source/Modules/csharp.cxx trunk/Source/Modules/d.cxx trunk/Source/Modules/java.cxx trunk/Source/Modules/lang.cxx trunk/Source/Modules/octave.cxx trunk/Source/Modules/php.cxx trunk/Source/Modules/python.cxx trunk/Source/Modules/r.cxx trunk/Source/Modules/ruby.cxx Modified: trunk/Source/Modules/csharp.cxx =================================================================== --- trunk/Source/Modules/csharp.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/csharp.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -925,7 +925,7 @@ if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { canThrow(n, "throws", p); } } @@ -3747,7 +3747,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); Modified: trunk/Source/Modules/d.cxx =================================================================== --- trunk/Source/Modules/d.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/d.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -1695,7 +1695,7 @@ if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { canThrow(n, "throws", p); } } @@ -2224,7 +2224,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); Modified: trunk/Source/Modules/java.cxx =================================================================== --- trunk/Source/Modules/java.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/java.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -1016,7 +1016,7 @@ if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { addThrows(n, "tmap:throws", p); } } @@ -3631,7 +3631,7 @@ SwigType *adjustedreturntype = covariant ? covariant : returntype; Parm *adjustedreturntypeparm = NewParmNode(adjustedreturntype, n); - if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0)) + if (Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0) && (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) { // Note that in the case of polymorphic (covariant) return types, the @@ -3658,7 +3658,7 @@ } String *jdesc = NULL; - if ((tm = Swig_typemap_lookup("directorin", tp, "", 0)) + if (Swig_typemap_lookup("directorin", tp, "", 0) && (jdesc = Getattr(tp, "tmap:directorin:descriptor"))) { // Objects marshalled passing a Java class across JNI boundary use jobject - the nouse flag indicates this @@ -3911,7 +3911,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { addThrows(n, "tmap:throws", p); if (gencomma++) { Modified: trunk/Source/Modules/lang.cxx =================================================================== --- trunk/Source/Modules/lang.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/lang.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -1134,7 +1134,6 @@ int Language::callbackfunctionHandler(Node *n) { Swig_require("callbackfunctionHandler", n, "name", "*sym:name", "*type", "?value", NIL); - String *symname = Getattr(n, "sym:name"); String *type = Getattr(n, "type"); String *name = Getattr(n, "name"); String *parms = Getattr(n, "parms"); Modified: trunk/Source/Modules/octave.cxx =================================================================== --- trunk/Source/Modules/octave.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/octave.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -1319,7 +1319,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); Modified: trunk/Source/Modules/php.cxx =================================================================== --- trunk/Source/Modules/php.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/php.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -1177,11 +1177,6 @@ if (!o) { // This "overloaded method" is really just one with default args. really_overloaded = false; - if (l != full_parmlist) { - l = full_parmlist; - if (wrapperType == memberfn) - l = nextSibling(l); - } } } @@ -2472,7 +2467,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); Modified: trunk/Source/Modules/python.cxx =================================================================== --- trunk/Source/Modules/python.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/python.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -4583,7 +4583,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); Modified: trunk/Source/Modules/r.cxx =================================================================== --- trunk/Source/Modules/r.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/r.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -572,7 +572,7 @@ Parm *p = parms; for (i = 0; p; p = nextSibling(p), ++i) { String *arg = Getattr(p, "name"); - String *lname = NewString(""); + String *lname; if (!arg && Cmp(Getattr(p, "type"), "void")) { lname = NewStringf("s_arg%d", i+1); Modified: trunk/Source/Modules/ruby.cxx =================================================================== --- trunk/Source/Modules/ruby.cxx 2012-11-23 07:36:10 UTC (rev 13931) +++ trunk/Source/Modules/ruby.cxx 2012-11-23 07:38:00 UTC (rev 13932) @@ -737,10 +737,6 @@ String *autodoc = Getattr(n, "feature:autodoc"); autodoc_l dlevel = autodoc_level(autodoc); - symname = Getattr(n, "sym:name"); - if ( Getattr( special_methods, symname ) ) - symname = Getattr( special_methods, symname ); - switch (dlevel) { case NO_AUTODOC: case NAMES_AUTODOC: @@ -3093,7 +3089,7 @@ if (throw_parm_list) Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { - if ((tm = Getattr(p, "tmap:throws"))) { + if (Getattr(p, "tmap:throws")) { if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wsf...@us...> - 2012-12-02 13:37:17
|
Revision: 13945 http://swig.svn.sourceforge.net/swig/?rev=13945&view=rev Author: wsfulton Date: 2012-12-02 13:37:10 +0000 (Sun, 02 Dec 2012) Log Message: ----------- Correct prefix handling - bug introduced in rev 13886 Revision Links: -------------- http://swig.svn.sourceforge.net/swig/?rev=13886&view=rev Modified Paths: -------------- trunk/Source/Modules/guile.cxx trunk/Source/Modules/mzscheme.cxx trunk/Source/Modules/ocaml.cxx Modified: trunk/Source/Modules/guile.cxx =================================================================== --- trunk/Source/Modules/guile.cxx 2012-12-02 13:36:40 UTC (rev 13944) +++ trunk/Source/Modules/guile.cxx 2012-12-02 13:37:10 UTC (rev 13945) @@ -280,7 +280,7 @@ // Make sure `prefix' ends in an underscore if (prefix) { const char *px = Char(prefix); - if (px[Len(prefix)] != '_') + if (px[Len(prefix) - 1] != '_') Printf(prefix, "_"); } Modified: trunk/Source/Modules/mzscheme.cxx =================================================================== --- trunk/Source/Modules/mzscheme.cxx 2012-12-02 13:36:40 UTC (rev 13944) +++ trunk/Source/Modules/mzscheme.cxx 2012-12-02 13:37:10 UTC (rev 13945) @@ -101,10 +101,9 @@ } // If a prefix has been specified make sure it ends in a '_' (not actually used!) - if (prefix) { const char *px = Char(prefix); - if (px[Len(prefix)] != '_') + if (px[Len(prefix) - 1] != '_') Printf(prefix, "_"); } else prefix = NewString("swig_"); Modified: trunk/Source/Modules/ocaml.cxx =================================================================== --- trunk/Source/Modules/ocaml.cxx 2012-12-02 13:36:40 UTC (rev 13944) +++ trunk/Source/Modules/ocaml.cxx 2012-12-02 13:37:10 UTC (rev 13945) @@ -130,10 +130,9 @@ } // If a prefix has been specified make sure it ends in a '_' (not actually used!) - if (prefix) { const char *px = Char(prefix); - if (px[Len(prefix)] != '_') + if (px[Len(prefix) - 1] != '_') Printf(prefix, "_"); } else prefix = NewString("swig_"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |