• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1/* Test program, used by the format-c-3 test.
2   Copyright (C) 2002 Free Software Foundation, Inc.
3
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 3 of the License, or
7   (at your option) any later version.
8
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.
13
14   You should have received a copy of the GNU General Public License
15   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17#ifdef HAVE_CONFIG_H
18# include "config.h"
19#endif
20
21#include <locale.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#ifdef HAVE_INTTYPES_H
26# include <inttypes.h>
27#endif
28#include "xsetenv.h"
29
30/* Make sure we use the included libintl, not the system's one. */
31#undef _LIBINTL_H
32#include "libgnuintl.h"
33
34#define _(string) gettext (string)
35
36/* Fallback definition.  */
37#if !defined PRId8 || PRI_MACROS_BROKEN
38# undef PRId8
39# define PRId8 "d"
40#endif
41
42int
43main (int argc, char *argv[])
44{
45  unsigned char n = 5;
46  const char *s;
47  const char *c1;
48  const char *c2;
49  char buf[100];
50
51  xsetenv ("LC_ALL", argv[1], 1);
52  if (setlocale (LC_ALL, "") == NULL)
53    {
54      fprintf (stderr, "Couldn't set locale.\n");
55      exit (1);
56    }
57
58  textdomain ("fc3");
59  bindtextdomain ("fc3", ".");
60
61  s = gettext ("father of %"PRId8" children");
62  c1 = "Vater von %"; c2 = " Kindern";
63
64  if (!(strlen (s) > strlen (c1) + strlen (c2)
65	&& memcmp (s, c1, strlen (c1)) == 0
66	&& memcmp (s + strlen (s) - strlen (c2), c2, strlen (c2)) == 0))
67    {
68      fprintf (stderr, "String not translated.\n");
69      exit (1);
70    }
71  if (strchr (s, '<') != NULL || strchr (s, '>') != NULL)
72    {
73      fprintf (stderr, "Translation contains <...> markers.\n");
74      exit (1);
75    }
76  sprintf (buf, s, n);
77  if (strcmp (buf, "Vater von 5 Kindern") != 0)
78    {
79      fprintf (stderr, "printf of translation wrong.\n");
80      exit (1);
81    }
82  return 0;
83}
84