summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-08-04 22:15:20 -0400
committerOri Bernstein <ori@eigenstate.org>2014-08-04 22:15:20 -0400
commitb8c37ce00d060d934f58b1b01bdbbbe27dc159f0 (patch)
treeeb089f5f8e7bf245c2923669bdd23b58a4a01ac3
parent545ee279bf3bee642c0cc97c2fef4a699f96393f (diff)
downloadmc-b8c37ce00d060d934f58b1b01bdbbbe27dc159f0.tar.gz
Better formatting for fmtunion
-rw-r--r--parse/type.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/parse/type.c b/parse/type.c
index dd895dc..d71a52c 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -444,10 +444,13 @@ static int fmtunion(char *buf, size_t len, Type *t)
p += snprintf(p, end - p, "union ");
for (i = 0; i < t->nmemb; i++) {
name = namestr(t->udecls[i]->name);
- if (t->udecls[i]->etype)
+ if (t->udecls[i]->etype) {
ty = tystr(t->udecls[i]->etype);
- p += snprintf(p, end - p, "`%s %s; ", name, ty);
- free(ty);
+ p += snprintf(p, end - p, "`%s %s; ", name, ty);
+ free(ty);
+ } else {
+ p += snprintf(p, end - p, "`%s; ", name);
+ }
}
p += snprintf(p, end - p, ";;");
return p - buf;