diff options
Diffstat (limited to '5.20/dcl.c')
-rw-r--r-- | 5.20/dcl.c | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -26,47 +26,45 @@ void dirdcl(void) dcl(); if (tokentype != ')') warn("missing )"); - } else if (tokentype == ')' || tokentype == ',') { + } else if (tokentype == ')') { prevtoken = YES; } else if (tokentype == NAME) { - strcpy(name, token); + if (!strlen(name)) + strcpy(name, token); } else { + printf("%c - %d : ", tokentype, tokentype); warn("expected () or name or (dcl)"); } while ((type = gettoken()) == PARENS || type == BRACKETS || - type == '(' || type == ',') { + type == '(') { if (type == PARENS) { strncat(out, " function returning", OUTLEN - 1); } else if (type == '(') { - strncat(out, " function expecting", OUTLEN - 1); + strncat(out, "function expecting", OUTLEN - 1); parmdcl(); strncat(out, " and returning", OUTLEN - 1); - } else if (type == ',') { - parmdcl(); - strncat(out, ",", OUTLEN - 1); } else { strncat(out, " array", OUTLEN - 1); strncat(out, token, OUTLEN - 1); strncat(out, " of", OUTLEN - 1); } } - - if (tokentype == '\n') - prevtoken = YES; } void parmdcl(void) { char parmdt[MAXTOKEN]; - parmdt[0] = '\0'; - while (gettoken() == NAME && isdatatyp()) { - strncat(parmdt, " ", MAXTOKEN - 1); - strncat(parmdt, token, MAXTOKEN - 1); - } + do { + strncpy(parmdt, (tokentype == ',') ? "," : "", MAXTOKEN - 1); + while (gettoken() == NAME && isdtspec()) { + strncat(parmdt, " ", MAXTOKEN - 1); + strncat(parmdt, token, MAXTOKEN - 1); + } - prevtoken = YES; - dcl(); - strncat(out, parmdt, OUTLEN - 1); + prevtoken = YES; + dcl(); + strncat(out, parmdt, OUTLEN - 1); + } while (tokentype == ','); } |