]> git.draconx.ca Git - cdecl99.git/commitdiff
Fix rendering of non-prototype function declarations.
authorNick Bowler <nbowler@draconx.ca>
Thu, 14 Jul 2011 23:21:55 +0000 (19:21 -0400)
committerNick Bowler <nbowler@draconx.ca>
Mon, 18 Jul 2011 23:23:51 +0000 (19:23 -0400)
When there are no parameters, the closing parenthesis was not printed.
Fix that up.

src/declare.c

index bc8af4ad6c6b0afceab9495e441befefa996659b..90a593d327e4493942086f4779d1e25accebba70 100644 (file)
@@ -96,16 +96,15 @@ static size_t declare_function(char *buf, size_t n, struct cdecl_function *f)
                rc = declare_decl(buf, n, p);
                ret += cdecl__advance_(&buf, &n, rc);
 
+               rc = 0;
                if (p->next)
                        rc = snprintf(buf, n, ", ");
                else if (f->variadic)
-                       rc = snprintf(buf, n, ", ...)");
-               else
-                       rc = snprintf(buf, n, ")");
+                       rc = snprintf(buf, n, ", ...");
                ret += cdecl__advance_(&buf, &n, rc);
        }
 
-       return ret;
+       return ret + snprintf(buf, n, ")");
 }
 
 static size_t