]> git.draconx.ca Git - dxcommon.git/blob - t/nls/gettext.h
help_print_optstring: New table-based implementation.
[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 /*
18  * We don't need a real snprintf for testing help functionality; substitute
19  * using vsprintf to ease testing on C89 implementations.
20  */
21 #define help_do_snprintf help_do_snprintf
22 static inline int help_do_snprintf(char *buf, size_t n, const char *fmt, ...)
23 {
24         va_list ap;
25         int ret;
26
27         va_start(ap, fmt);
28         ret = vsprintf(buf, fmt, ap);
29         va_end(ap);
30
31         return ret;
32 }
33
34 /*
35  * Do nothing, but try to tickle a crash if a bogus string argument is
36  * passed as the real functions dereference the provided pointers.
37  */
38 #define gettext(s) (*(volatile char *)s, s)
39 #define pgettext_expr(c, s) (*(volatile char *)c + *(volatile char *)s, s)
40
41 #endif