code style: fix inconsistent NULL pointer comparisons
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12137 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
07ca3eb9f8
commit
95a3eb5a7d
12 changed files with 216 additions and 219 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -114,7 +114,7 @@ static String *memberfunction_name = 0;
|
|||
|
||||
extern "C" {
|
||||
static int has_classname(Node *class_node) {
|
||||
return Getattr(class_node, "guile:goopsclassname") != NULL;
|
||||
return Getattr(class_node, "guile:goopsclassname") ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ public:
|
|||
}
|
||||
|
||||
// set default value for primsuffix
|
||||
if (primsuffix == NULL)
|
||||
if (!primsuffix)
|
||||
primsuffix = NewString("primitive");
|
||||
|
||||
//goops support can only be enabled if passive or module linkage is used
|
||||
|
|
@ -628,7 +628,7 @@ public:
|
|||
if (maybe_delimiter && Len(output) > 0 && Len(tm) > 0) {
|
||||
Printv(output, maybe_delimiter, NIL);
|
||||
}
|
||||
const String *pn = (name == NULL) ? (const String *) Getattr(p, "name") : name;
|
||||
const String *pn = !name ? (const String *) Getattr(p, "name") : name;
|
||||
String *pt = Getattr(p, "type");
|
||||
Replaceall(tm, "$name", pn); // legacy for $parmname
|
||||
Replaceall(tm, "$type", SwigType_str(pt, 0));
|
||||
|
|
@ -781,7 +781,7 @@ public:
|
|||
if (strcmp("void", Char(pt)) != 0) {
|
||||
Node *class_node = Swig_symbol_clookup_check(pb, Getattr(n, "sym:symtab"),
|
||||
has_classname);
|
||||
String *goopsclassname = (class_node == NULL) ? NULL : Getattr(class_node, "guile:goopsclassname");
|
||||
String *goopsclassname = !class_node ? NULL : Getattr(class_node, "guile:goopsclassname");
|
||||
/* do input conversion */
|
||||
if (goopsclassname) {
|
||||
Printv(method_signature, " (", argname, " ", goopsclassname, ")", NIL);
|
||||
|
|
|
|||
|
|
@ -2996,7 +2996,7 @@ void Language::dumpSymbols() {
|
|||
|
||||
Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
|
||||
Hash *symbols = Getattr(symtabs, scope ? scope : "");
|
||||
if (symbols == NULL) {
|
||||
if (!symbols) {
|
||||
return NULL;
|
||||
}
|
||||
return Getattr(symbols, s);
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,7 @@ MODULA3():
|
|||
Parm *p;
|
||||
attachParameterNames(n, "tmap:name", "c:wrapname", "m3arg%d");
|
||||
bool gencomma = false;
|
||||
for (p = skipIgnored(l, "in"); p != NULL; p = skipIgnored(p, "in")) {
|
||||
for (p = skipIgnored(l, "in"); p; p = skipIgnored(p, "in")) {
|
||||
|
||||
String *arg = Getattr(p, "c:wrapname");
|
||||
{
|
||||
|
|
@ -1545,7 +1545,7 @@ MODULA3():
|
|||
Parm *p;
|
||||
writeArgState state;
|
||||
attachParameterNames(n, "tmap:rawinname", "modula3:rawname", "arg%d");
|
||||
for (p = skipIgnored(l, "m3rawintype"); p != NULL; p = skipIgnored(p, "m3rawintype")) {
|
||||
for (p = skipIgnored(l, "m3rawintype"); p; p = skipIgnored(p, "m3rawintype")) {
|
||||
|
||||
/* Get argument passing mode, should be one of VALUE, VAR, READONLY */
|
||||
String *mode = Getattr(p, "tmap:m3rawinmode");
|
||||
|
|
@ -1928,7 +1928,7 @@ MODULA3():
|
|||
} else if (Strcmp(code, "unsafe") == 0) {
|
||||
unsafe_module = true;
|
||||
} else if (Strcmp(code, "library") == 0) {
|
||||
if (targetlibrary != NULL) {
|
||||
if (targetlibrary) {
|
||||
Delete(targetlibrary);
|
||||
}
|
||||
targetlibrary = Copy(strvalue);
|
||||
|
|
|
|||
|
|
@ -1599,7 +1599,7 @@ public:
|
|||
tm = Getattr(n, "feature:director:except");
|
||||
}
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Printf(w->code, "if (result == NULL) {\n");
|
||||
Printf(w->code, "if (!result) {\n");
|
||||
Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n");
|
||||
Replaceall(tm, "$error", "error");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
|
|||
|
|
@ -1244,7 +1244,7 @@ public:
|
|||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p != NULL) {
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ public:
|
|||
if (no_pmfile) {
|
||||
f_pm = NewString(0);
|
||||
} else {
|
||||
if (pmfile == NULL) {
|
||||
if (!pmfile) {
|
||||
char *m = Char(module) + Len(module);
|
||||
while (m != Char(module)) {
|
||||
if (*m == ':') {
|
||||
|
|
|
|||
|
|
@ -1206,7 +1206,7 @@ public:
|
|||
}
|
||||
if (!pname_cstr) {
|
||||
// Unnamed parameter, e.g. int foo(int);
|
||||
} else if (pname == NULL) {
|
||||
} else if (!pname) {
|
||||
pname = NewString(pname_cstr);
|
||||
} else {
|
||||
size_t len = strlen(pname_cstr);
|
||||
|
|
@ -1290,7 +1290,7 @@ public:
|
|||
if (errno || *p) {
|
||||
Clear(value);
|
||||
Append(value, "?");
|
||||
} else if (strchr(Char(value), '.') == NULL) {
|
||||
} else if (strchr(Char(value), '.') == 0) {
|
||||
// Ensure value is a double constant, not an integer one.
|
||||
Append(value, ".0");
|
||||
double val2 = strtod(Char(value), &p);
|
||||
|
|
@ -2496,7 +2496,7 @@ done:
|
|||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p != NULL) {
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1073,7 +1073,7 @@ public:
|
|||
|
||||
bool have_docstring(Node *n) {
|
||||
String *str = Getattr(n, "feature:docstring");
|
||||
return (str != NULL && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
|
||||
return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -1085,7 +1085,7 @@ public:
|
|||
|
||||
String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) {
|
||||
String *str = Getattr(n, "feature:docstring");
|
||||
bool have_ds = (str != NULL && Len(str) > 0);
|
||||
bool have_ds = (str && Len(str) > 0);
|
||||
bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
|
||||
const char *triple_double = use_triple ? "\"\"\"" : "";
|
||||
String *autodoc = NULL;
|
||||
|
|
@ -1101,7 +1101,7 @@ public:
|
|||
|
||||
if (have_auto) {
|
||||
autodoc = make_autodoc(n, ad_type);
|
||||
have_auto = (autodoc != NULL && Len(autodoc) > 0);
|
||||
have_auto = (autodoc && Len(autodoc) > 0);
|
||||
}
|
||||
// If there is more than one line then make docstrings like this:
|
||||
//
|
||||
|
|
@ -1116,14 +1116,14 @@ public:
|
|||
doc = NewString("");
|
||||
Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), "\n", pythoncode(str, indent), indent, triple_double, NIL);
|
||||
} else if (!have_auto && have_ds) { // only docstring
|
||||
if (Strchr(str, '\n') == NULL) {
|
||||
if (Strchr(str, '\n') == 0) {
|
||||
doc = NewStringf("%s%s%s", triple_double, str, triple_double);
|
||||
} else {
|
||||
doc = NewString("");
|
||||
Printv(doc, triple_double, "\n", pythoncode(str, indent), indent, triple_double, NIL);
|
||||
}
|
||||
} else if (have_auto && !have_ds) { // only autodoc
|
||||
if (Strchr(autodoc, '\n') == NULL) {
|
||||
if (Strchr(autodoc, '\n') == 0) {
|
||||
doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double);
|
||||
} else {
|
||||
doc = NewString("");
|
||||
|
|
@ -1361,7 +1361,7 @@ public:
|
|||
{
|
||||
// Only do the autodoc if there isn't a docstring for the class
|
||||
String *str = Getattr(n, "feature:docstring");
|
||||
if (str == NULL || Len(str) == 0) {
|
||||
if (!str || Len(str) == 0) {
|
||||
if (CPlusPlus) {
|
||||
Printf(doc, "Proxy of C++ %s class", real_classname);
|
||||
} else {
|
||||
|
|
@ -1557,7 +1557,7 @@ public:
|
|||
|
||||
bool have_pythonprepend(Node *n) {
|
||||
String *str = Getattr(n, "feature:pythonprepend");
|
||||
return (str != NULL && Len(str) > 0);
|
||||
return (str && Len(str) > 0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -1584,7 +1584,7 @@ public:
|
|||
String *str = Getattr(n, "feature:pythonappend");
|
||||
if (!str)
|
||||
str = Getattr(n, "feature:addtofunc");
|
||||
return (str != NULL && Len(str) > 0);
|
||||
return (str && Len(str) > 0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -2741,7 +2741,7 @@ public:
|
|||
Printf(f_directors_h, " if (!method) {\n");
|
||||
Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n");
|
||||
Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n");
|
||||
Printf(f_directors_h, " if (method == NULL) {\n");
|
||||
Printf(f_directors_h, " if (!method) {\n");
|
||||
Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname);
|
||||
Printf(f_directors_h, " msg += method_name;\n");
|
||||
Printf(f_directors_h, " Swig::DirectorMethodException::raise(msg.c_str());\n");
|
||||
|
|
@ -2904,7 +2904,7 @@ public:
|
|||
Printf(f_shadow, ":\n");
|
||||
if (have_docstring(n)) {
|
||||
String *str = docstring(n, AUTODOC_CLASS, tab4);
|
||||
if (str != NULL && Len(str))
|
||||
if (str && Len(str))
|
||||
Printv(f_shadow, tab4, str, "\n", NIL);
|
||||
}
|
||||
if (!modern) {
|
||||
|
|
@ -3723,7 +3723,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p != NULL) {
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -3910,13 +3910,13 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
if (tm)
|
||||
tm = Copy(tm);
|
||||
}
|
||||
Append(w->code, "if (result == NULL) {\n");
|
||||
Append(w->code, "if (!result) {\n");
|
||||
Append(w->code, " PyObject *error = PyErr_Occurred();\n");
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Replaceall(tm, "$error", "error");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
} else {
|
||||
Append(w->code, " if (error != NULL) {\n");
|
||||
Append(w->code, " if (error) {\n");
|
||||
Printf(w->code, " Swig::DirectorMethodException::raise(\"Error detected when calling '%s.%s'\");\n", classname, pyname);
|
||||
Append(w->code, " }\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2514,7 +2514,7 @@ int R::membervariableHandler(Node *n) {
|
|||
|
||||
int status(Language::membervariableHandler(n));
|
||||
|
||||
if(opaqueClassDeclaration == NULL && debugMode)
|
||||
if(!opaqueClassDeclaration && debugMode)
|
||||
Printf(stderr, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
|
||||
processing_member_access_function = 0;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ private:
|
|||
|
||||
bool have_docstring(Node *n) {
|
||||
String *str = Getattr(n, "feature:docstring");
|
||||
return (str != NULL && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
|
||||
return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -244,7 +244,7 @@ private:
|
|||
String *docstring(Node *n, autodoc_t ad_type) {
|
||||
|
||||
String *str = Getattr(n, "feature:docstring");
|
||||
bool have_ds = (str != NULL && Len(str) > 0);
|
||||
bool have_ds = (str && Len(str) > 0);
|
||||
bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc"));
|
||||
String *autodoc = NULL;
|
||||
String *doc = NULL;
|
||||
|
|
@ -259,7 +259,7 @@ private:
|
|||
|
||||
if (have_auto) {
|
||||
autodoc = make_autodoc(n, ad_type);
|
||||
have_auto = (autodoc != NULL && Len(autodoc) > 0);
|
||||
have_auto = (autodoc && Len(autodoc) > 0);
|
||||
}
|
||||
// If there is more than one line then make docstrings like this:
|
||||
//
|
||||
|
|
@ -272,14 +272,14 @@ private:
|
|||
doc = NewString("");
|
||||
Printv(doc, "\n", autodoc, "\n", str, NIL);
|
||||
} else if (!have_auto && have_ds) { // only docstring
|
||||
if (Strchr(str, '\n') == NULL) {
|
||||
if (Strchr(str, '\n') == 0) {
|
||||
doc = NewString(str);
|
||||
} else {
|
||||
doc = NewString("");
|
||||
Printv(doc, str, NIL);
|
||||
}
|
||||
} else if (have_auto && !have_ds) { // only autodoc
|
||||
if (Strchr(autodoc, '\n') == NULL) {
|
||||
if (Strchr(autodoc, '\n') == 0) {
|
||||
doc = NewStringf("%s", autodoc);
|
||||
} else {
|
||||
doc = NewString("");
|
||||
|
|
@ -618,7 +618,7 @@ private:
|
|||
{
|
||||
// Only do the autodoc if there isn't a docstring for the class
|
||||
String *str = Getattr(n, "feature:docstring");
|
||||
if (counter == 0 && (str == NULL || Len(str) == 0)) {
|
||||
if (counter == 0 && (str == 0 || Len(str) == 0)) {
|
||||
if (CPlusPlus) {
|
||||
Printf(doc, " Proxy of C++ %s class", full_name);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1092,7 +1092,7 @@ String *Swig_string_strip(String *s) {
|
|||
} else {
|
||||
const char *cs = Char(s);
|
||||
const char *ce = Strchr(cs, ']');
|
||||
if (*cs != '[' || ce == NULL) {
|
||||
if (*cs != '[' || !ce) {
|
||||
ns = NewString(s);
|
||||
} else {
|
||||
String *fmt = NewStringf("%%.%ds", ce-cs-1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue