1*946379e7Schristos /* Test program, used by the format-c-3 test.
2*946379e7Schristos Copyright (C) 2002 Free Software Foundation, Inc.
3*946379e7Schristos
4*946379e7Schristos This program is free software; you can redistribute it and/or modify
5*946379e7Schristos it under the terms of the GNU General Public License as published by
6*946379e7Schristos the Free Software Foundation; either version 2, or (at your option)
7*946379e7Schristos any later version.
8*946379e7Schristos
9*946379e7Schristos This program is distributed in the hope that it will be useful,
10*946379e7Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
11*946379e7Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12*946379e7Schristos GNU General Public License for more details.
13*946379e7Schristos
14*946379e7Schristos You should have received a copy of the GNU General Public License
15*946379e7Schristos along with this program; if not, write to the Free Software Foundation,
16*946379e7Schristos Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17*946379e7Schristos
18*946379e7Schristos #ifdef HAVE_CONFIG_H
19*946379e7Schristos # include "config.h"
20*946379e7Schristos #endif
21*946379e7Schristos
22*946379e7Schristos #include <locale.h>
23*946379e7Schristos #include <stdio.h>
24*946379e7Schristos #include <stdlib.h>
25*946379e7Schristos #include <string.h>
26*946379e7Schristos #ifdef HAVE_INTTYPES_H
27*946379e7Schristos # include <inttypes.h>
28*946379e7Schristos #endif
29*946379e7Schristos #include "xsetenv.h"
30*946379e7Schristos
31*946379e7Schristos /* Make sure we use the included libintl, not the system's one. */
32*946379e7Schristos #undef _LIBINTL_H
33*946379e7Schristos #include "libgnuintl.h"
34*946379e7Schristos
35*946379e7Schristos #define _(string) gettext (string)
36*946379e7Schristos
37*946379e7Schristos /* Fallback definition. */
38*946379e7Schristos #if !defined PRId8 || PRI_MACROS_BROKEN
39*946379e7Schristos # undef PRId8
40*946379e7Schristos # define PRId8 "d"
41*946379e7Schristos #endif
42*946379e7Schristos
43*946379e7Schristos int
main(int argc,char * argv[])44*946379e7Schristos main (int argc, char *argv[])
45*946379e7Schristos {
46*946379e7Schristos unsigned char n = 5;
47*946379e7Schristos const char *s;
48*946379e7Schristos const char *c1;
49*946379e7Schristos const char *c2;
50*946379e7Schristos char buf[100];
51*946379e7Schristos
52*946379e7Schristos xsetenv ("LC_ALL", argv[1], 1);
53*946379e7Schristos if (setlocale (LC_ALL, "") == NULL)
54*946379e7Schristos {
55*946379e7Schristos fprintf (stderr, "Couldn't set locale.\n");
56*946379e7Schristos exit (1);
57*946379e7Schristos }
58*946379e7Schristos
59*946379e7Schristos textdomain ("fc3");
60*946379e7Schristos bindtextdomain ("fc3", ".");
61*946379e7Schristos
62*946379e7Schristos s = gettext ("father of %"PRId8" children");
63*946379e7Schristos c1 = "Vater von %"; c2 = " Kindern";
64*946379e7Schristos
65*946379e7Schristos if (!(strlen (s) > strlen (c1) + strlen (c2)
66*946379e7Schristos && memcmp (s, c1, strlen (c1)) == 0
67*946379e7Schristos && memcmp (s + strlen (s) - strlen (c2), c2, strlen (c2)) == 0))
68*946379e7Schristos {
69*946379e7Schristos fprintf (stderr, "String not translated.\n");
70*946379e7Schristos exit (1);
71*946379e7Schristos }
72*946379e7Schristos if (strchr (s, '<') != NULL || strchr (s, '>') != NULL)
73*946379e7Schristos {
74*946379e7Schristos fprintf (stderr, "Translation contains <...> markers.\n");
75*946379e7Schristos exit (1);
76*946379e7Schristos }
77*946379e7Schristos sprintf (buf, s, n);
78*946379e7Schristos if (strcmp (buf, "Vater von 5 Kindern") != 0)
79*946379e7Schristos {
80*946379e7Schristos fprintf (stderr, "printf of translation wrong.\n");
81*946379e7Schristos exit (1);
82*946379e7Schristos }
83*946379e7Schristos return 0;
84*946379e7Schristos }
85