+ *(--p) = 0;
+ while (val > 0) {
+ *(--p) = '0' + val % 10;
+ val /= 10;
+ }
+
+ return cdecl__emit(dst, p);
+}
+
+static void explain_spec(struct output_state *dst, struct cdecl_declspec *s)
+{
+ size_t rc;
+
+ rc = cdecl__emit(dst, spec_string(s->type));
+ if (s->ident) {
+ cdecl__emit(dst, " " + !rc);
+ cdecl__emit(dst, s->ident);
+ }
+}
+
+/*
+ * Render a list of declaration specifiers. Only the declaration specifiers
+ * listed in mask, which is the bitwise OR of the desired specifier kinds, are
+ * printed.
+ */
+const char *cdecl__emit_specs(struct output_state *dst,
+ struct cdecl_declspec *s,
+ unsigned mask)
+{
+ const char *sep = " ";
+ int empty = 1;
+
+ for (; s; s = s->next) {
+ if (!(s->type & mask))
+ continue;
+
+ cdecl__emit(dst, sep + empty);
+ explain_spec(dst, s);
+ empty = 0;
+ }