summaryrefslogtreecommitdiff
path: root/src/tc-format.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-01-29 16:17:52 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-01-29 16:17:52 +0100
commitcd47bd564d7fc6177ba2e231d76bf352978409b8 (patch)
tree7465150c86969e66a90e4b960bb3537485205842 /src/tc-format.c
parent6c88f3bab0b743487b367712fa1ec27d1f87389e (diff)
parentbfef0924f58eab930bdd826ac0132786abc32220 (diff)
Update upstream source from tag 'upstream/4.10'
Update to upstream version '4.10' with Debian dir 3c0b972fcc05149f237318f1a516c1c6bee6ce20
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;
}