]> git.draconx.ca Git - dxcommon.git/blob - t/nls/gettext.h
help_print_optstring: Don't depend on snprintf.
[dxcommon.git] / t / nls / gettext.h
1 /*
2  * Copyright © 2023 Nick Bowler
3  *
4  * Stub gettext macros for test purposes.
5  *
6  * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7  * This is free software: you are free to do what the fuck you want to.
8  * There is NO WARRANTY, to the extent permitted by law.
9  */
10
11 #ifndef TEST_NLS_GETTEXT_H_
12 #define TEST_NLS_GETTEXT_H_
13
14 #include <stdio.h>
15 #include <stdarg.h>
16
17 #define gettext(s) (s)
18 #define pgettext_expr(a, s) (s)
19
20 /*
21  * We don't need a real snprintf for testing help functionality; substitute
22  * using vsprintf to ease testing on C89 implementations.
23  */
24 #define help_do_snprintf help_do_snprintf
25 static inline int help_do_snprintf(char *buf, size_t n, const char *fmt, ...)
26 {
27         va_list ap;
28         int ret;
29
30         va_start(ap, fmt);
31         ret = vsprintf(buf, fmt, ap);
32         va_end(ap);
33
34         return ret;
35 }
36
37 #endif