X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/225fb0d496bd8f9fcbc2f800819a83c71d763a61..b9d67c6ec4c59b204883dfbf346e3b7fca54a84b:/src/output.c?ds=sidebyside diff --git a/src/output.c b/src/output.c index b33816a..4590a5c 100644 --- a/src/output.c +++ b/src/output.c @@ -43,17 +43,15 @@ size_t cdecl__emit(struct output_state *dst, const char *src) return cdecl__advance(dst, rc); } -static size_t explain_spec(struct output_state *dst, struct cdecl_declspec *s) +static void explain_spec(struct output_state *dst, struct cdecl_declspec *s) { - size_t ret; + size_t rc; - ret = cdecl__emit(dst, spec_string(s->type)); + rc = cdecl__emit(dst, spec_string(s->type)); if (s->ident) { - ret += cdecl__emit(dst, " " + !ret); - ret += cdecl__emit(dst, s->ident); + cdecl__emit(dst, " " + !rc); + cdecl__emit(dst, s->ident); } - - return ret; } /* @@ -61,19 +59,21 @@ static size_t explain_spec(struct output_state *dst, struct cdecl_declspec *s) * listed in mask, which is the bitwise OR of the desired specifier kinds, are * printed. */ -size_t cdecl__emit_specs(struct output_state *dst, - struct cdecl_declspec *s, - unsigned mask) +const char *cdecl__emit_specs(struct output_state *dst, + struct cdecl_declspec *s, + unsigned mask) { - size_t ret = 0; + const char *sep = " "; + int empty = 1; for (; s; s = s->next) { if (!(s->type & mask)) continue; - ret += cdecl__emit(dst, " " + !ret); - ret += explain_spec(dst, s); + cdecl__emit(dst, sep + empty); + explain_spec(dst, s); + empty = 0; } - return ret; + return sep + empty; }