Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ulrich Drepper committed Oct 31, 2000
1 parent 42fea16 commit cdfb970
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 28 deletions.
23 changes: 23 additions & 0 deletions ChangeLog
@@ -1,3 +1,26 @@
2000-10-30 Ulrich Drepper <drepper@redhat.com>

* 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>

* locale/findlocale.c (_nl_find_locale): Don't store normalized
Expand Down
15 changes: 9 additions & 6 deletions intl/Makefile
Expand Up @@ -26,17 +26,17 @@ 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

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) $@ $^
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion intl/dcigettext.c
Expand Up @@ -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. */
Expand Down
1 change: 1 addition & 0 deletions intl/locale.alias
Expand Up @@ -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
Expand Down
27 changes: 17 additions & 10 deletions intl/tst-gettext.c
Expand Up @@ -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. */
Expand All @@ -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");
Expand All @@ -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. */
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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;
}

Expand Down
18 changes: 16 additions & 2 deletions intl/tst-gettext.sh
Expand Up @@ -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 \
Expand All @@ -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

Expand Down
68 changes: 68 additions & 0 deletions 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;
}
54 changes: 54 additions & 0 deletions 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 $?

13 changes: 13 additions & 0 deletions 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"
13 changes: 13 additions & 0 deletions 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"

0 comments on commit cdfb970

Please sign in to comment.