]> git.draconx.ca Git - cdecl99.git/blobdiff - src/explain.c
libcdecl: Simplify internal specifier printing functions.
[cdecl99.git] / src / explain.c
index 0d9c95740ca03ece599a610c881db74ccdcc540e..877d6db511363437253a6f9b912aa85199a8dfd9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Render C declarations as English.
- *  Copyright © 2011, 2021 Nick Bowler
+ *  Copyright © 2011, 2021, 2023 Nick Bowler
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "cdecl.h"
 #include "cdecl-internal.h"
 
+static size_t explain_pre_specs(char *buf, size_t n, struct cdecl_declspec *s)
+{
+       return cdecl__explain_specs(buf, n, s, CDECL_SPEC_FUNC|CDECL_SPEC_STOR);
+}
+
+static size_t explain_post_specs(char *buf, size_t n, struct cdecl_declspec *s)
+{
+       return cdecl__explain_specs(buf, n, s, CDECL_SPEC_QUAL|CDECL_SPEC_TYPE);
+}
+
 /*
  * Renders the start of the thing being declared.  If top is true, print
  * the "declare" or "type" keywords at the front, as appropriate.
@@ -98,13 +108,13 @@ static size_t explain_decl(char *buf, size_t n, struct cdecl *decl, bool top)
        rc = explain_prologue(buf, n, decl->declarators, top);
        ret += cdecl__advance(&buf, &n, rc);
 
-       rc = cdecl__explain_pre_specs(buf, n, decl->specifiers);
+       rc = explain_pre_specs(buf, n, decl->specifiers);
        ret += cdecl__advance(&buf, &n, rc);
 
        rc = explain_declarators(buf, n, decl->declarators);
        ret += cdecl__advance(&buf, &n, rc);
 
-       return ret + cdecl__explain_post_specs(buf, n, decl->specifiers);
+       return ret + explain_post_specs(buf, n, decl->specifiers);
 }
 
 static size_t explain_function(char *buf, size_t n, struct cdecl_function *f)