summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-25 17:41:07 -0700
committerCarl Worth <cworth@cworth.org>2010-05-25 17:41:07 -0700
commitc7581c2e6e6897eddc55c537c92417b813a8b81e (patch)
treef1b5a6ea97e3aa069802a981efd04bdc3221e2d1
parent9ce18cf9837bee379dfd0f52a3df005c1797e544 (diff)
Ignore separating whitespace at the beginning of a macro argument.
This causes test 16 to pass. Tests 17-20 are also passing now, (though they would probably have passed before this change and simply weren't being run yet).
-rw-r--r--glcpp-parse.y20
1 files changed, 11 insertions, 9 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y
index eb93bad85d..ec966580fc 100644
--- a/glcpp-parse.y
+++ b/glcpp-parse.y
@@ -743,7 +743,6 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret)
token_list_t *argument;
token_node_t *node = *node_ret, *last;
int paren_count;
- int arg_count;
last = node;
node = node->next;
@@ -757,9 +756,7 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret)
argument = NULL;
- paren_count = 0;
- arg_count = 0;
- do {
+ for (paren_count = 0; node; last = node, node = node->next) {
if (node->token->type == '(')
{
paren_count++;
@@ -767,6 +764,11 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret)
else if (node->token->type == ')')
{
paren_count--;
+ if (paren_count == 0) {
+ last = node;
+ node = node->next;
+ break;
+ }
}
else if (node->token->type == ',' &&
paren_count == 1)
@@ -775,16 +777,16 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret)
}
else {
if (argument == NULL) {
+ /* Don't treat initial whitespace as
+ * part of the arguement. */
+ if (node->token->type == SPACE)
+ continue;
argument = _token_list_create (arguments);
_argument_list_append (arguments, argument);
}
_token_list_append (argument, node->token);
}
-
- last = node;
- node = node->next;
-
- } while (node && paren_count);
+ }
if (node && paren_count)
return FUNCTION_UNBALANCED_PARENTHESES;