}
void
-_token_print (token_t *token)
+_glcpp_parser_print_token (glcpp_parser_t *parser, token_t *token)
{
if (token->type < 256) {
printf ("%c", token->type);
list = xtalloc (ctx, token_list_t);
list->head = NULL;
list->tail = NULL;
+ list->non_space_tail = NULL;
return list;
}
}
list->tail = node;
+ if (token->type != SPACE)
+ list->non_space_tail = node;
}
void
}
list->tail = tail->tail;
+ list->non_space_tail = tail->non_space_tail;
+}
+
+void
+_token_list_trim_trailing_space (token_list_t *list)
+{
+ token_node_t *tail, *next;
+
+ if (list->non_space_tail) {
+ tail = list->non_space_tail->next;
+ list->non_space_tail->next = NULL;
+ list->tail = list->non_space_tail;
+
+ while (tail) {
+ next = tail->next;
+ talloc_free (tail);
+ tail = next;
+ }
+ }
}
void
/* We only expand identifiers */
if (token->type != IDENTIFIER) {
- _token_print (token);
+ _glcpp_parser_print_token (parser, token);
return 0;
}
if (node->token->type == ',' &&
paren_count == 1)
{
+ if (argument)
+ _token_list_trim_trailing_space (argument);
argument = NULL;
}
else {
if (list == NULL)
return;
+ _token_list_trim_trailing_space (list);
+
for (node = list->head; node; node = node->next) {
if (_glcpp_parser_print_expanded_token (parser, node->token))
_glcpp_parser_print_expanded_function (parser, &node);