static char *buf;
struct cdecl *decl;
+ struct cdecl_declarator *d;
size_t rc;
decl = cdecl_parse_decl(arg);
if (!decl)
goto out;
+ for (d = decl->declarators; d; d = d->next) {
+ struct cdecl decl_tmp = {
+ .specifiers = decl->specifiers,
+ .declarators = d,
+ };
+
retry:
- rc = cdecl_explain(buf, bufsz, decl);
- if (rc >= bufsz) {
- char *tmp;
-
- tmp = realloc(buf, rc + 1);
- if (!tmp) {
- fprintf(stderr, "failed to allocate memory\n");
- goto out;
+ rc = cdecl_explain(buf, bufsz, &decl_tmp);
+ if (rc >= bufsz) {
+ char *tmp;
+
+ tmp = realloc(buf, rc + 1);
+ if (!tmp) {
+ fprintf(stderr, "failed to allocate memory\n");
+ goto out;
+ }
+
+ buf = tmp;
+ bufsz = rc + 1;
+ goto retry;
}
- buf = tmp;
- bufsz = rc + 1;
- goto retry;
+ printf("%s\n", buf);
}
-
- printf("%s\n", buf);
out:
cdecl_free(decl);
return 1;