summaryrefslogtreecommitdiff
path: root/src/tc-format.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tc-format.c')
-rw-r--r--src/tc-format.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/tc-format.c b/src/tc-format.c
index ad067ee..ed8e6d4 100644
--- a/src/tc-format.c
+++ b/src/tc-format.c
@@ -1,11 +1,4 @@
-/*
- * formatter test program
- * Copyright by Jan Engelhardt
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the WTF Public License version 2 or
- * (at your option) any later version.
- */
+// SPDX-License-Identifier: MIT
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,7 +48,7 @@ static const char *const fmt2_strings[] = {
NULL,
};
-static void t_format(int argc)
+static int t_format(int argc)
{
struct HXformat_map *fmt = HXformat_init();
const char *const *s;
@@ -70,9 +63,14 @@ static void t_format(int argc)
HXformat_add(fmt, "TWOARG", "a, b", HXTYPE_STRING | HXFORMAT_IMMED);
++argc;
printf("# HXformat2\n");
- for (s = fmt2_strings; *s != NULL; ++s)
- HXformat_fprintf(fmt, stdout, *s);
+ for (s = fmt2_strings; *s != NULL; ++s) {
+ char buf[80];
+ if (HXformat_sprintf(fmt, buf, ARRAY_SIZE(buf), *s) < 0 ||
+ HXformat_fprintf(fmt, stdout, *s) < 0)
+ return EXIT_FAILURE;
+ }
HXformat_free(fmt);
+ return EXIT_SUCCESS;
}
int main(int argc, const char **argv)
@@ -84,7 +82,7 @@ int main(int argc, const char **argv)
fprintf(stderr, "HX_init: %s\n", strerror(-ret));
return EXIT_FAILURE;
}
- t_format(argc);
+ ret = t_format(argc);
HX_exit();
- return EXIT_SUCCESS;
+ return ret;
}