Avoid an access violation if malloc failes.
[glibc.git] / intl / tst-gettext2.c
blob1174e8b4cc6c1fe7c40dae3ec7d59dac4aec83f6
1 /* Test of the gettext functions.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 Contributed by Thorsten Kukuk <kukuk@suse.de> and
4 Andreas Jaeger <aj@suse.de>, 2000.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include <locale.h>
23 #include <libintl.h>
24 #include <stdlib.h>
25 #include <stdio.h>
27 struct data_t
29 const char *selection;
30 const char *description;
33 int data_cnt = 2;
34 struct data_t strings[] =
36 { "String1", N_("First string for testing.") },
37 { "String2", N_("Another string for testing.") }
40 const int lang_cnt = 3;
41 const char *lang[] = {"lang1", "lang2", "lang3"};
43 int
44 main (void)
46 int i;
48 /* Clean up environment. */
49 unsetenv ("LANGUAGE");
50 unsetenv ("LC_ALL");
51 unsetenv ("LC_MESSAGES");
52 unsetenv ("LC_CTYPE");
53 unsetenv ("LANG");
54 unsetenv ("OUTPUT_CHARSET");
56 textdomain ("tstlang");
58 for (i = 0; i < lang_cnt; ++i)
60 int j;
62 if (setlocale (LC_ALL, lang[i]) == NULL)
63 setlocale (LC_ALL, "C");
64 bindtextdomain ("tstlang", OBJPFX "domaindir");
66 for (j = 0; j < data_cnt; ++j)
67 printf ("%s - %s\n", strings[j].selection,
68 gettext (strings[j].description));
71 return 0;