summaryrefslogtreecommitdiff
path: root/intl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-31 03:10:13 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-31 03:10:13 +0000
commitcdfb970dd9c20861d7fdac16435d70792b8a027a (patch)
treedfa5497c0b5b06408284073aa184688091b065c4 /intl
parent42fea164a2f975da1b1bb687bf1a50506b59a668 (diff)
downloadglibc-cdfb970dd9c20861d7fdac16435d70792b8a027a.tar.gz
Update.
* locale/findlocale.c (free_mem): We can remove NODELETE marked data, just not the C locale data. * intl/tst-gettext.c: Use setlocale() in addition to setting envvar. * intl/tst-gettext.sh: Copy locale data if necessary. * intl/Makefile (generated-dirs): Add localedir. * intl/dcigettext.c (guess_category_value): For libc always use the setlocale() method. * intl/Makefile: Add rules to build, run and, distribute tst-gettext2. * intl/tst-gettext2.c: New file. * intl/tst-gettext2.sh: New file. * intl/tstlang1.po: New file. * intl/tstlang2.po: New file. Patch by Andreas Jaeger <aj@suse.de>. 2000-10-26 GOTO Masanori <gotom@debian.or.jp> * intl/locale.alias: Add ja_JP.ujis alias. 2000-10-30 Ulrich Drepper <drepper@redhat.com>
Diffstat (limited to 'intl')
-rw-r--r--intl/Makefile15
-rw-r--r--intl/dcigettext.c2
-rw-r--r--intl/locale.alias1
-rw-r--r--intl/tst-gettext.c27
-rwxr-xr-xintl/tst-gettext.sh18
-rw-r--r--intl/tst-gettext2.c68
-rw-r--r--intl/tst-gettext2.sh54
-rw-r--r--intl/tstlang1.po13
-rw-r--r--intl/tstlang2.po13
9 files changed, 192 insertions, 19 deletions
diff --git a/intl/Makefile b/intl/Makefile
index ed9ff28106..e2df29cb93 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -26,9 +26,9 @@ routines = bindtextdom dcgettext dgettext gettext \
l10nflist explodename plural
distribute = gettext.h gettextP.h hash-string.h loadinfo.h locale.alias \
plural.y po2test.sed tst-gettext.sh tst-translit.sh \
- translit.po
+ translit.po tst-gettext2.sh tstlang1.po tstlang2.po
-test-srcs := tst-gettext tst-translit
+test-srcs := tst-gettext tst-translit tst-gettext2
tests = tst-ngettext
before-compile = $(objpfx)msgs.h
@@ -36,7 +36,7 @@ before-compile = $(objpfx)msgs.h
install-others = $(inst_msgcatdir)/locale.alias
generated = msgs.h mtrace-tst-gettext tst-gettext.mtrace
-generated-dirs := domaindir
+generated-dirs := domaindir localedir
plural.c: plural.y
$(YACC) $(YFLAGS) $@ $^
@@ -50,16 +50,18 @@ include ../Rules
ifeq (no,$(cross-compiling))
ifeq (yes,$(build-shared))
ifneq ($(strip $(MSGFMT)),:)
-.PHONY: do-gettext-test do-translit-test
-tests: $(objpfx)mtrace-tst-gettext do-translit-test
+tests: $(objpfx)mtrace-tst-gettext $(objpfx)tst-translit.out \
+ $(objpfx)tst-gettext2.out
$(objpfx)mtrace-tst-gettext: $(objpfx)tst-gettext.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-gettext.mtrace > $@
$(objpfx)tst-gettext.out: tst-gettext.sh $(objpfx)tst-gettext
$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
$(objpfx)tst-gettext.mtrace
- do-translit-test: $(objpfx)tst-translit.out
$(objpfx)tst-translit.out: tst-translit.sh $(objpfx)tst-translit
$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+$(objpfx)tst-gettext2.out: tst-gettext2.sh $(objpfx)tst-gettext2
+ $(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
+ $(objpfx)tst-gettext
endif
endif
endif
@@ -69,6 +71,7 @@ $(objpfx)msgs.h: po2test.sed ../po/de.po
sed -f $^ > $@
CFLAGS-tst-gettext.c = -DTESTSTRS_H=\"$(objpfx)msgs.h\"
+CFLAGS-tst-gettext2.c = -DOBJPFX=\"$(objpfx)\"
CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\"
$(objpfx)tst-translit.out: $(objpfx)tst-gettext.out
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index 7d7081dbe8..c47cccf512 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1079,7 +1079,7 @@ guess_category_value (category, categoryname)
/* `LANGUAGE' is not set. So we have to proceed with the POSIX
methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
systems this can be done by the `setlocale' function itself. */
-#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
+#if defined _LIBC || (defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL)
return setlocale (category, NULL);
#else
/* Setting of LC_ALL overwrites all other. */
diff --git a/intl/locale.alias b/intl/locale.alias
index 799405aef3..d6fa49636f 100644
--- a/intl/locale.alias
+++ b/intl/locale.alias
@@ -52,6 +52,7 @@ italian it_IT.ISO-8859-1
japanese ja_JP.eucJP
japanese.euc ja_JP.eucJP
ja_JP ja_JP.eucJP
+ja_JP.ujis ja_JP.eucJP
japanese.sjis ja_JP.SJIS
korean ko_KR.eucKR
korean.euc ko_KR.eucKR
diff --git a/intl/tst-gettext.c b/intl/tst-gettext.c
index cfd2d5fc53..a83b1d25bd 100644
--- a/intl/tst-gettext.c
+++ b/intl/tst-gettext.c
@@ -106,6 +106,7 @@ main (int argc, char *argv[])
/* Now the same tests with LC_ALL deciding. */
unsetenv ("LANGUAGE");
setenv ("LC_ALL", "existing-locale", 1);
+ setlocale (LC_ALL, "");
puts ("test `gettext' with LC_ALL set");
/* This is the name of the existing domain with a catalog for the
LC_MESSAGES category. */
@@ -119,13 +120,13 @@ main (int argc, char *argv[])
LC_MESSAGES category. We leave this value set for the `dgettext'
and `dcgettext' tests. */
textdomain ("non-existing-domain");
- puts ("test `gettext' with LANGUAGE set");
+ puts ("test `gettext' with LC_ALL deciding");
if (negative_gettext_test () != 0)
{
puts ("FAILED");
result = 1;
}
- puts ("test `dgettext' with LANGUAGE set");
+ puts ("test `dgettext' with LC_ALL deciding");
if (positive_dgettext_test ("existing-domain") != 0)
{
puts ("FAILED");
@@ -135,8 +136,11 @@ main (int argc, char *argv[])
/* Now the same tests with LC_MESSAGES deciding. */
unsetenv ("LC_ALL");
setenv ("LC_MESSAGES", "existing-locale", 1);
+ setlocale (LC_MESSAGES, "");
setenv ("LC_TIME", "existing-locale", 1);
+ setlocale (LC_TIME, "");
setenv ("LC_NUMERIC", "non-existing-locale", 1);
+ setlocale (LC_NUMERIC, "");
puts ("test `gettext' with LC_ALL set");
/* This is the name of the existing domain with a catalog for the
LC_MESSAGES category. */
@@ -150,33 +154,33 @@ main (int argc, char *argv[])
LC_MESSAGES category. We leave this value set for the `dgettext'
and `dcgettext' tests. */
textdomain ("non-existing-domain");
- puts ("test `gettext' with LANGUAGE set");
+ puts ("test `gettext' with LC_xxx deciding");
if (negative_gettext_test () != 0)
{
puts ("FAILED");
result = 1;
}
- puts ("test `dgettext' with LANGUAGE set");
+ puts ("test `dgettext' with LC_xxx deciding");
if (positive_dgettext_test ("existing-domain") != 0)
{
puts ("FAILED");
result = 1;
}
- puts ("test `dcgettext' with LANGUAGE set (LC_MESSAGES)");
+ puts ("test `dcgettext' with category == LC_MESSAGES");
if (positive_dcgettext_test ("existing-domain", LC_MESSAGES) != 0)
{
puts ("FAILED");
result = 1;
}
/* Try a different category. For this we also switch the domain. */
- puts ("test `dcgettext' with LANGUAGE set (LC_TIME)");
+ puts ("test `dcgettext' with LANGUAGE == LC_TIME");
if (positive_dcgettext_test ("existing-time-domain", LC_TIME) != 0)
{
puts ("FAILED");
result = 1;
}
/* This time use a category for which there is no catalog. */
- puts ("test `dcgettext' with LANGUAGE set (LC_NUMERIC)");
+ puts ("test `dcgettext' with LANGUAGE == LC_NUMERIC");
if (negative_dcgettext_test ("existing-domain", LC_NUMERIC) != 0)
{
puts ("FAILED");
@@ -186,10 +190,11 @@ main (int argc, char *argv[])
/* Now the same tests with LANG deciding. */
unsetenv ("LC_MESSAGES");
setenv ("LANG", "existing-locale", 1);
+ setlocale (LC_ALL, "");
/* This is the name of the existing domain with a catalog for the
LC_MESSAGES category. */
textdomain ("existing-domain");
- puts ("test `gettext' with LC_ALL set");
+ puts ("test `gettext' with LANG set");
if (positive_gettext_test () != 0)
{
puts ("FAILED");
@@ -199,19 +204,21 @@ main (int argc, char *argv[])
LC_MESSAGES category. We leave this value set for the `dgettext'
and `dcgettext' tests. */
textdomain ("non-existing-domain");
- puts ("test `gettext' with LANGUAGE set");
+ puts ("test `gettext' with LANG set");
if (negative_gettext_test () != 0)
{
puts ("FAILED");
result = 1;
}
- puts ("test `dgettext' with LANGUAGE set");
+ puts ("test `dgettext' with LANG set");
if (positive_dgettext_test ("existing-domain") != 0)
{
puts ("FAILED");
result = 1;
}
+ setlocale (LC_ALL, "C");
+
return result;
}
diff --git a/intl/tst-gettext.sh b/intl/tst-gettext.sh
index 42436fe5bf..c5898943d2 100755
--- a/intl/tst-gettext.sh
+++ b/intl/tst-gettext.sh
@@ -31,10 +31,24 @@ export LC_ALL
# Generate the test data.
test -d ${objpfx}domaindir || mkdir ${objpfx}domaindir
-# Create the locale directories.
+test -d ${objpfx}localedir || mkdir ${objpfx}localedir
+# Create the domain directories.
test -d ${objpfx}domaindir/existing-locale || mkdir ${objpfx}domaindir/existing-locale
test -d ${objpfx}domaindir/existing-locale/LC_MESSAGES || mkdir ${objpfx}domaindir/existing-locale/LC_MESSAGES
test -d ${objpfx}domaindir/existing-locale/LC_TIME || mkdir ${objpfx}domaindir/existing-locale/LC_TIME
+# Create the locale directories.
+test -d ${objpfx}localedir/existing-locale || {
+ mkdir ${objpfx}localedir/existing-locale
+ for f in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MONETARY NAME NUMEIRC PAPER TELEPHONE TIME; do
+ cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_$f \
+ ${objpfx}localedir/existing-locale
+ done
+}
+test -d ${objpfx}localedir/existing-locale/LC_MESSAGES || {
+ mkdir ${objpfx}localedir/existing-locale/LC_MESSAGES
+ cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_MESSAGES/SYS_LC_MESSAGES \
+ ${objpfx}localedir/existing-locale/LC_MESSAGES
+}
# Populate them.
msgfmt -o ${objpfx}domaindir/existing-locale/LC_MESSAGES/existing-domain.mo \
@@ -43,7 +57,7 @@ msgfmt -o ${objpfx}domaindir/existing-locale/LC_TIME/existing-time-domain.mo \
../po/de.po
# Now run the test.
-MALLOC_TRACE=$malloc_trace \
+MALLOC_TRACE=$malloc_trace LOCPATH=${objpfx}localedir:$LOCPATH \
${common_objpfx}elf/ld.so --library-path $common_objpfx \
${objpfx}tst-gettext > ${objpfx}tst-gettext.out ${objpfx}domaindir
diff --git a/intl/tst-gettext2.c b/intl/tst-gettext2.c
new file mode 100644
index 0000000000..0cc4cad84a
--- /dev/null
+++ b/intl/tst-gettext2.c
@@ -0,0 +1,68 @@
+/* Test of the gettext functions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ Contributed by Thorsten Kukuk <kukuk@suse.de> and
+ Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+#include <locale.h>
+#include <libintl.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+struct data_t {
+ const char *selection;
+ const char *description;
+};
+
+int data_cnt = 2;
+struct data_t strings[] =
+{{"String1", N_("First string for testing.")},
+ {"String2", N_("Another string for testing.")}
+};
+
+const int lang_cnt = 3;
+const char *lang[] = {"lang1", "lang2", "lang3"};
+
+int
+main (void)
+{
+ int i;
+
+ /* Clean up environment. */
+ unsetenv ("LANGUAGE");
+ unsetenv ("LC_ALL");
+ unsetenv ("LC_MESSAGES");
+ unsetenv ("LC_CTYPE");
+ unsetenv ("LANG");
+ unsetenv ("OUTPUT_CHARSET");
+
+ textdomain ("tstlang");
+
+ for (i = 0; i < lang_cnt; ++i)
+ {
+ int j;
+
+ setlocale (LC_ALL, lang[i]);
+ bindtextdomain ("tstlang", OBJPFX "domaindir");
+
+ for (j = 0; j < data_cnt; ++j)
+ printf ("%s - %s\n", strings[j].selection, _(strings[j].description));
+ }
+
+ return 0;
+}
diff --git a/intl/tst-gettext2.sh b/intl/tst-gettext2.sh
new file mode 100644
index 0000000000..2c1a2e10ca
--- /dev/null
+++ b/intl/tst-gettext2.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Test of gettext functions.
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB. If
+# not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+common_objpfx=$1
+objpfx=$2
+malloc_trace=$3
+
+GCONV_PATH=${common_objpfx}iconvdata
+export GCONV_PATH
+LOCPATH=${common_objpfx}localedata
+export LOCPATH
+LC_ALL=C
+export LC_ALL
+
+# Generate the test data.
+test -d ${objpfx}domaindir || mkdir ${objpfx}domaindir
+# Create the locale directories.
+test -d ${objpfx}domaindir/lang1 || mkdir ${objpfx}domaindir/lang1
+test -d ${objpfx}domaindir/lang2 || mkdir ${objpfx}domaindir/lang2
+test -d ${objpfx}domaindir/lang1/LC_MESSAGES || mkdir ${objpfx}domaindir/lang1/LC_MESSAGES
+test -d ${objpfx}domaindir/lang2/LC_MESSAGES || mkdir ${objpfx}domaindir/lang2/LC_MESSAGES
+
+# Populate them.
+msgfmt -o ${objpfx}domaindir/lang1/LC_MESSAGES/tstlang.mo \
+ tstlang1.po
+
+msgfmt -o ${objpfx}domaindir/lang2/LC_MESSAGES/tstlang.mo \
+ tstlang2.po
+
+
+# Now run the test.
+MALLOC_TRACE=$malloc_trace \
+${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${objpfx}tst-gettext2 > ${objpfx}tst-gettext2.out ${objpfx}domaindir
+
+exit $?
+
diff --git a/intl/tstlang1.po b/intl/tstlang1.po
new file mode 100644
index 0000000000..c411ce116f
--- /dev/null
+++ b/intl/tstlang1.po
@@ -0,0 +1,13 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=US-ASCII\n"
+"Content-Transfer-Encoding: 7-bit\n"
+
+#: tst-gettext2.c:33
+msgid "First string for testing."
+msgstr "Lang1: 1st string"
+
+#: tst-gettext2.c:34
+msgid "Another string for testing."
+msgstr "Lang1: 2nd string"
diff --git a/intl/tstlang2.po b/intl/tstlang2.po
new file mode 100644
index 0000000000..d1606c8ede
--- /dev/null
+++ b/intl/tstlang2.po
@@ -0,0 +1,13 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=US-ASCII\n"
+"Content-Transfer-Encoding: 7-bit\n"
+
+#: tst-gettext2.c:33
+msgid "First string for testing."
+msgstr "Lang2: 1st string"
+
+#: tst-gettext2.c:34
+msgid "Another string for testing."
+msgstr "Lang2: 2nd string"