summaryrefslogtreecommitdiff
path: root/src/tc-format.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-02-10 15:27:06 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-02-10 15:27:06 +0100
commit7501bff8432444b7ae8e7f3d9289c0d61f3f0b64 (patch)
treebd53603f464c3747e897a8996158a0fef7b41bc3 /src/tc-format.c
parent0f124df68d87c9073f76efeff1a901a69b1f3e13 (diff)
parent9e9336185f86bd97ff22f54e4d561c2cccccecf5 (diff)
Merge branch 'release/debian/4.10-1'debian/4.10-1
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;
}