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