From bfef0924f58eab930bdd826ac0132786abc32220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 29 Jan 2023 16:17:51 +0100 Subject: New upstream version 4.10 --- src/tc-format.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/tc-format.c') 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 #include #include @@ -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; } -- cgit v1.2.3