* 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>
This commit is contained in:
Ulrich Drepper 2000-10-31 03:10:13 +00:00
parent 42fea164a2
commit cdfb970dd9
12 changed files with 224 additions and 28 deletions

View File

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

View File

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

View File

@ -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. */

View File

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

View File

@ -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;
}

View File

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

68
intl/tst-gettext2.c Normal file
View File

@ -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
intl/tst-gettext2.sh Normal file
View File

@ -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
intl/tstlang1.po Normal file
View File

@ -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
intl/tstlang2.po Normal file
View File

@ -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"

View File

@ -187,7 +187,7 @@ any pthreads function until it has been reinitialized.
@findex pthread_attr_setscope
@comment pthread.h
@comment POSIX
@deftypefun int pthread_attr_set@var{attr} (pthread_attr_t *@var{obj}, int @var{value})
@deftypefun int pthread_attr_setattr (pthread_attr_t *@var{obj}, int @var{value})
Set attribute @var{attr} to @var{value} in the attribute object pointed
to by @var{obj}. See below for a list of possible attributes and the
values they can take.
@ -204,7 +204,7 @@ below.
@findex pthread_attr_getscope
@comment pthread.h
@comment POSIX
@deftypefun int pthread_attr_get@var{attr} (const pthread_attr_t *@var{obj}, int *@var{value})
@deftypefun int pthread_attr_getattr (const pthread_attr_t *@var{obj}, int *@var{value})
Store the current setting of @var{attr} in @var{obj} into the variable
pointed to by @var{value}.
@ -558,7 +558,7 @@ The default type is ``fast''.
Variables of type @code{pthread_mutex_t} can also be initialized
statically, using the constants @code{PTHREAD_MUTEX_INITIALIZER} (for
timed mutexes), @code{PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP} (for
recursive mutexes), @code{PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP}
recursive mutexes), @code{PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP}
(for fast mutexes(, and @code{PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP}
(for error checking mutexes).
@ -700,8 +700,8 @@ This function always returns 0.
LinuxThreads supports only one mutex attribute: the mutex type, which is
either @code{PTHREAD_MUTEX_ADAPTIVE_NP} for ``fast'' mutexes,
@code{PTHREAD_MUTEX_RECURSIVE_NP} for ``recursive'' mutexes,
@code{PTHREAD_MUTEX_TIMED_NP} for ``timed'' mutexes, or
@code{PTHREAD_MUTEX_RECURSIVE_NP} for ``recursive'' mutexes,
@code{PTHREAD_MUTEX_TIMED_NP} for ``timed'' mutexes, or
@code{PTHREAD_MUTEX_ERRORCHECK_NP} for ``error checking'' mutexes. As
the @code{NP} suffix indicates, this is a non-portable extension to the
POSIX standard and should not be employed in portable programs.
@ -728,12 +728,12 @@ The default mutex type is ``timed'', that is, @code{PTHREAD_MUTEX_TIMED_NP}.
@var{attr} to the value specified by @var{type}.
If @var{type} is not @code{PTHREAD_MUTEX_ADAPTIVE_NP},
@code{PTHREAD_MUTEX_RECURSIVE_NP}, @code{PTHREAD_MUTEX_TIMED_NP}, or
@code{PTHREAD_MUTEX_RECURSIVE_NP}, @code{PTHREAD_MUTEX_TIMED_NP}, or
@code{PTHREAD_MUTEX_ERRORCHECK_NP}, this function will return
@code{EINVAL} and leave @var{attr} unchanged.
The standard Unix98 identifiers @code{PTHREAD_MUTEX_DEFAULT},
@code{PTHREAD_MUTEX_NORMAL}, @code{PTHREAD_MUTEX_RECURSIVE},
The standard Unix98 identifiers @code{PTHREAD_MUTEX_DEFAULT},
@code{PTHREAD_MUTEX_NORMAL}, @code{PTHREAD_MUTEX_RECURSIVE},
and @code{PTHREAD_MUTEX_ERRORCHECK} are also permitted.
@end deftypefun

View File

@ -253,7 +253,7 @@ free_mem (void)
struct loaded_l10nfile *here = runp;
struct locale_data *data = (struct locale_data *) runp->data;
if (data != NULL && data->usage_count != UNDELETABLE)
if (data != NULL && data != _nl_C[category])
_nl_unload_locale (data);
runp = runp->next;
free ((char *) here->filename);