1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21: #include <langinfo.h>
22: #include <libintl.h>
23: #include <locale.h>
24: #include <stdio.h>
25: #include <stdlib.h>
26: #include <string.h>
27:
28:
29: int
30: main (void)
31: {
32: const char *strs[2] = { "singular", "plural" };
33: unsigned long int i;
34: int res = 0;
35:
36:
37: setenv ("LANGUAGE", "C", 1);
38: unsetenv ("OUTPUT_CHARSET");
39:
40: for (i = 0; i < 30; ++i)
41: {
42: char *tr;
43:
44: tr = ngettext (strs[0], strs[1], i);
45: #define TEST \
46: do \
47: if (tr != strs[i != 1]) \
48: { \
49: if (strcmp (tr, strs[i != 1]) == 0) \
50: printf ("%lu: correct string, wrong pointer (%s)\n", i, tr); \
51: else \
52: printf ("%lu: wrong result (%s)\n", i, tr); \
53: res = 1; \
54: } \
55: while (0)
56: TEST;
57:
58: tr = dngettext ("messages", strs[0], strs[1], i);
59: TEST;
60:
61: tr = dcngettext ("messages", strs[0], strs[1], i, LC_MESSAGES);
62: TEST;
63: }
64:
65: return res;
66: }