size_t cdecl__advance(char **buf, size_t *n, size_t amount);
size_t cdecl__explain_specs(char *buf, size_t n, struct cdecl_declspec *s,
unsigned mask);
-size_t cdecl__explain_pre_specs(char *buf, size_t n, struct cdecl_declspec *s);
-size_t cdecl__explain_post_specs(char *buf, size_t n, struct cdecl_declspec *s);
#endif
/*
* Render C declarations.
- * 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 declare_specs(char *buf, size_t n, struct cdecl_declspec *s)
-{
- size_t ret = 0, rc;
-
- if (!s)
- return 0;
-
- rc = cdecl__explain_pre_specs(buf, n, s);
- ret += cdecl__advance(&buf, &n, rc);
-
- rc = cdecl__explain_post_specs(buf, n, s);
- return ret + rc;
-}
-
static size_t
declare_declarator(char *buf, size_t n, struct cdecl_declarator *d);
{
size_t ret = 0, rc;
- rc = declare_specs(buf, n, decl->specifiers);
+ rc = cdecl__explain_specs(buf, n, decl->specifiers, -1);
if (decl->declarators->type != CDECL_DECL_NULL)
ret += cdecl__advance(&buf, &n, rc);
else
/*
* 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.
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)
/*
* Helper functions for outputting text.
- * 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
return ret + rc;
}
-
-/* Renders the storage-class and function specifiers in canonical form. */
-size_t cdecl__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);
-}
-
-/* Renders the type qualifiers and type specifiers in canonical form. */
-size_t cdecl__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);
-}