diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b473e3087..f7b60825d 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -2096,7 +2096,7 @@ MODULA3(): 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,16 +2214,18 @@ MODULA3(): 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")); - } - 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")); + 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")); + } } } @@ -2460,12 +2462,14 @@ MODULA3(): /* 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")); + } } } } diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 135cc89dc..9fc5e9c71 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1256,13 +1256,12 @@ public: 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_"); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 242db1df1..1662f3b55 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1638,8 +1638,8 @@ public: while (fgets(buffer, 4095, f)) { Printf(pragma_include, "%s", buffer); } + fclose(f); } - fclose(f); } } else { Swig_error(input_file, line_number, "Unrecognized pragma.\n"); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index dcf6699b1..56107e0c0 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1163,9 +1163,9 @@ public: 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) { diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 9e931a38d..ab13cb7fc 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1609,7 +1609,6 @@ void R::dispatchFunction(Node *n) { 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 @@ void R::dispatchFunction(Node *n) { 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); - } - if (!SwigType_ispointer(Getattr(p, "type"))) { - Printf(f->code, " && length(argv[[%d]]) == 1", - j+1); + j == 0 ? "" : " && ", + j+1, + tm); } + } + 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 @@ int R::functionWrapper(Node *n) { 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);