No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-c-5-prg.c
blob14d52fd280e412f521d29b0d3ac3ce1dd39bd625
1 /* Test program, used by the format-c-5 test.
2 Copyright (C) 2004 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 #include "xsetenv.h"
28 /* For %Id to work, we need the real setlocale(), not the fake one. */
29 #if !(__GLIBC__ >= 2)
30 # include "setlocale.c"
31 #endif
33 /* Make sure we use the included libintl, not the system's one. */
34 #undef _LIBINTL_H
35 #include "libgnuintl.h"
37 #define _(string) gettext (string)
39 int
40 main (int argc, char *argv[])
42 int n = 5;
43 const char *en;
44 const char *s;
45 const char *expected_translation;
46 const char *expected_result;
47 char buf[100];
49 xsetenv ("LC_ALL", argv[1], 1);
50 if (setlocale (LC_ALL, "") == NULL)
52 fprintf (stderr, "Couldn't set locale.\n");
53 exit (77);
56 textdomain ("fc5");
57 bindtextdomain ("fc5", ".");
59 s = gettext ("father of %d children");
60 en = "father of %d children";
61 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
62 expected_translation = "Vater von %Id Kindern";
63 expected_result = "Vater von \xdb\xb5 Kindern";
64 #else
65 expected_translation = "Vater von %d Kindern";
66 expected_result = "Vater von 5 Kindern";
67 #endif
69 if (strcmp (s, en) == 0)
71 fprintf (stderr, "String untranslated.\n");
72 exit (1);
74 if (strcmp (s, expected_translation) != 0)
76 fprintf (stderr, "String incorrectly translated.\n");
77 exit (1);
79 sprintf (buf, s, n);
80 if (strcmp (buf, expected_result) != 0)
82 fprintf (stderr, "printf of translation wrong.\n");
83 exit (1);
85 return 0;