From 8406ab7c2c940614edd924f88a206d57a65f1f18 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 7 Oct 2005 03:41:07 +0000 Subject: [PATCH] Fix functions of the form "name(void)" --- mxmldoc.c | 37 ++++++++++++++++++++++++++++--------- test/function.cxx | 11 +++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/mxmldoc.c b/mxmldoc.c index 9b7543f..84bb0fc 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -363,6 +363,11 @@ add_variable(mxml_node_t *parent, /* I - Parent node */ *bufptr; /* Pointer into buffer */ +#ifdef DEBUG + fprintf(stderr, "add_variable(parent=%p, name=\"%s\", type=%p)\n", + parent, name, type); +#endif /* DEBUG */ + /* * Range check input... */ @@ -932,8 +937,16 @@ scan_file(const char *filename, /* I - Filename */ if (function && type && !parens) { - variable = add_variable(function, "argument", type); - type = NULL; + /* + * Check for "void" argument... + */ + + if (type->child && type->child->next) + variable = add_variable(function, "argument", type); + else + mxmlDelete(type); + + type = NULL; } if (parens > 0) @@ -1557,17 +1570,23 @@ scan_file(const char *filename, /* I - Filename */ * Argument definition... */ - mxmlNewText(type, type->child != NULL && - type->last_child->value.text.string[0] != '(' && - type->last_child->value.text.string[0] != '*', - buffer); + if (strcmp(buffer, "void")) + { + mxmlNewText(type, type->child != NULL && + type->last_child->value.text.string[0] != '(' && + type->last_child->value.text.string[0] != '*', + buffer); #ifdef DEBUG - fprintf(stderr, "Argument: <<<< %s >>>\n", buffer); + fprintf(stderr, "Argument: <<<< %s >>>\n", buffer); #endif /* DEBUG */ - variable = add_variable(function, "argument", type); - type = NULL; + variable = add_variable(function, "argument", type); + } + else + mxmlDelete(type); + + type = NULL; } else if (type->child && !function && (ch == ';' || ch == ',')) { diff --git a/test/function.cxx b/test/function.cxx index df5e8fb..5a16722 100644 --- a/test/function.cxx +++ b/test/function.cxx @@ -74,3 +74,14 @@ foo_default_int(int one, /* I - Integer */ return (2); } + + +/* + * 'foo_void_func()' - Function taking no arguments. + */ + +void +foo_void_func(void) +{ + puts("foo_void_func()"); +}