#include "help.h"
#include "test.h"
-static size_t printbuf_size;
-static char *printbuf;
-
void *realloc_nofail(void *ptr, size_t size)
{
void *p;
return realloc_nofail(NULL, size);
}
-void test_print_decl(struct cdecl *decl)
-{
- size_t rc;
-
-retry:
- rc = cdecl_declare(printbuf, printbuf_size, decl);
- if (rc >= printbuf_size) {
- printbuf_size = rc + 1;
- printbuf = realloc_nofail(printbuf, printbuf_size);
- goto retry;
- }
-
- printf("%s\n", printbuf);
-}
-
-void test_explain_decl(struct cdecl *decl)
-{
- size_t rc;
-
-retry:
- rc = cdecl_explain(printbuf, printbuf_size, decl);
- if (rc >= printbuf_size) {
- printbuf_size = rc + 1;
- printbuf = realloc_nofail(printbuf, printbuf_size);
- goto retry;
- }
-
- printf("%s\n", printbuf);
-}
-
bool strict_strtoul(unsigned long *val, const char *str, int base)
{
char *end;
return true;
}
-void test_print_version(const char *program)
-{
- printf("%s (%s) %s\n", program, PACKAGE_NAME, PACKAGE_VERSION);
- puts("Copyright (C) 2023 Nick Bowler.");
- puts("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.");
- puts("This is free software: you are free to change and redistribute it.");
- puts("There is NO WARRANTY, to the extent permitted by law.");
-}
-
void test_print_options(const struct option *lopts)
{
const struct option *opt;