# HG changeset patch # User William Astle # Date 1379215623 21600 # Node ID 310df72c641d7a188281f4fbeaa23786731099fb # Parent 83fcc1ed6ad6028c6e58a7b8875a4359b5f0e2e8 Handle () surrounding macro args on invocation diff -r 83fcc1ed6ad6 -r 310df72c641d lwcc/preproc.c --- a/lwcc/preproc.c Sat Sep 14 20:04:38 2013 -0600 +++ b/lwcc/preproc.c Sat Sep 14 21:27:03 2013 -0600 @@ -774,7 +774,8 @@ struct expand_e *e; struct token **exparglist = NULL; int i; - + int pcount; + s = symtab_find(pp, mname); if (!s) return 0; @@ -827,6 +828,7 @@ while (t -> ttype != TOK_CPAREN) { + pcount = 0; if (t -> ttype == TOK_EOF) { preproc_throw_error(pp, "Unexpected EOF in macro call"); @@ -834,7 +836,11 @@ } if (t -> ttype == TOK_EOL) continue; - if (t -> ttype == TOK_COMMA) + if (t -> ttype == TOK_OPAREN) + pcount++; + else if (t -> ttype == TOK_CPAREN && pcount) + pcount--; + if (t -> ttype == TOK_COMMA && pcount == 0) { if (!(s -> vargs) || (nargs > s -> nargs)) {