* locale/Makefile (distribute): Add iso-639.def and iso-3166.def.
	Change charset.h to charmap.h.
	(categories): Add new categories.  Leave out collate for now.
	Update build rules.
	* locale/categories.def: Add definitions for new categories.
	* locale/langinfo.h: Likewise.
	* locale/locale.h: Likewise.
	* locale/C-address.c: New file.
	* locale/C-identification.c: New file.
	* locale/C-measurement.c: New file.
	* locale/C-name.c: New file.
	* locale/C-paper.c: New file.
	* locale/C-telephone.c: New file.
	* locale/lc-address.c: Likewise.
	* locale/lc-identification.c: Likewise.
	* locale/lc-measurement.c: Likewise.
	* locale/lc-name.c: Likewise.
	* locale/lc-paper.c: Likewise.
	* locale/lc-telephone.c: Likewise.
	* locale/C-ctype.c: Update for locale rewrite.
	* locale/C-messages.c: Likewise.
	* locale/C-monetary.c: Likewise.
	* locale/C-time.c: Likewise.
	* locale/lc-collate.c: Likewise.
	* locale/lc-ctype.c: Likewise.
	* locale/lc-monetary.c: Likewise.
	* locale/lc-time.c: Likewise.
	* locale/localeinfo.h: Likewise.
	* locale/newlocale.c: Likewise.
	* locale/setlocale.c: Likewise.
	* locale/weight.h: Likewise.
	* locale/findlocale.c: Unconditionally use mmap.
	Handle new categories.
	* locale/loadlocale.c: Likewise.
	* locale/iso-3166.def: New file.
	* locale/iso-639.def: New file.
	* locale/programs/charmap-kw.gperf: Add new keywords.
	* locale/programs/locfile-kw.gperf: Likewise.
	* locale/programs/locfile-token.h: Define new tokens.
	* locale/programs/charmap.c: Rewrite to handle multibyte charsets.
	* locale/programs/charmap.h: New file.
	* locale/programs/charset.h: Removed.
	* locale/programs/config.h: Add __LC_LAST.
	* locale/programs/lc-address.c: New file.
	* locale/programs/lc-identification.c: New file.
	* locale/programs/lc-measurement.c: New file.
	* locale/programs/lc-name.c: New file.
	* locale/programs/lc-paper.c: New file.
	* locale/programs/lc-telephone.c: New file.
	* locale/programs/lc-collate.c: Update for locale rewrite.
	* locale/programs/lc-ctype.c: Likewise.
	* locale/programs/lc-messages.c: Likewise.
	* locale/programs/lc-monetary.c: Likewise.
	* locale/programs/lc-numeric.c: Likewise.
	* locale/programs/lc-time.c: Likewise.
	* locale/programs/locale.c: Likewise.
	* locale/programs/localedef.c: Likewise.
	* locale/programs/locfile.c: Likewise.
	* locale/programs/repertoire.c: Likewise.
	* locale/programs/repertoire.h: Likewise.
	* locale/programs/locfile.c: Update prototypes.
	Update handle_copy definition.
	* locale/programs/linereader.c: Add handling of wide char strings and
	new definition file syntax.
	* locale/programs/linereader.h (struct token): Add elements for wide
	character strings.
	* locale/programs/locale-spec.c: Disable handling of collation
	elements for now.
	* locale/programs/simple-hash.h: Cleanup.
	* locale/programs/stringtrans.h: Handle quite of end of line.
	* string/strcoll.c: Fall back on strcmp for now.
	* string/strxfrm.c: Fall back on strncpy/strlen for now.
	* time/strftime.c: Use new wide character data for wcsftime.
	* time/strptime.c: Remove _nl_C_LC_TIME declaration.
	* wctype/cname-lookup.h: Update for new LC_CTYPE data.
This commit is contained in:
Ulrich Drepper 1999-08-31 07:04:41 +00:00
parent 1d1740d6b1
commit 4b10dd6c19
70 changed files with 11991 additions and 3897 deletions

View File

@ -1,5 +1,81 @@
1999-08-30 Ulrich Drepper <drepper@cygnus.com>
* locale/Makefile (distribute): Add iso-639.def and iso-3166.def.
Change charset.h to charmap.h.
(categories): Add new categories. Leave out collate for now.
Update build rules.
* locale/categories.def: Add definitions for new categories.
* locale/langinfo.h: Likewise.
* locale/locale.h: Likewise.
* locale/C-address.c: New file.
* locale/C-identification.c: New file.
* locale/C-measurement.c: New file.
* locale/C-name.c: New file.
* locale/C-paper.c: New file.
* locale/C-telephone.c: New file.
* locale/lc-address.c: Likewise.
* locale/lc-identification.c: Likewise.
* locale/lc-measurement.c: Likewise.
* locale/lc-name.c: Likewise.
* locale/lc-paper.c: Likewise.
* locale/lc-telephone.c: Likewise.
* locale/C-ctype.c: Update for locale rewrite.
* locale/C-messages.c: Likewise.
* locale/C-monetary.c: Likewise.
* locale/C-time.c: Likewise.
* locale/lc-collate.c: Likewise.
* locale/lc-ctype.c: Likewise.
* locale/lc-monetary.c: Likewise.
* locale/lc-time.c: Likewise.
* locale/localeinfo.h: Likewise.
* locale/newlocale.c: Likewise.
* locale/setlocale.c: Likewise.
* locale/weight.h: Likewise.
* locale/findlocale.c: Unconditionally use mmap.
Handle new categories.
* locale/loadlocale.c: Likewise.
* locale/iso-3166.def: New file.
* locale/iso-639.def: New file.
* locale/programs/charmap-kw.gperf: Add new keywords.
* locale/programs/locfile-kw.gperf: Likewise.
* locale/programs/locfile-token.h: Define new tokens.
* locale/programs/charmap.c: Rewrite to handle multibyte charsets.
* locale/programs/charmap.h: New file.
* locale/programs/charset.h: Removed.
* locale/programs/config.h: Add __LC_LAST.
* locale/programs/lc-address.c: New file.
* locale/programs/lc-identification.c: New file.
* locale/programs/lc-measurement.c: New file.
* locale/programs/lc-name.c: New file.
* locale/programs/lc-paper.c: New file.
* locale/programs/lc-telephone.c: New file.
* locale/programs/lc-collate.c: Update for locale rewrite.
* locale/programs/lc-ctype.c: Likewise.
* locale/programs/lc-messages.c: Likewise.
* locale/programs/lc-monetary.c: Likewise.
* locale/programs/lc-numeric.c: Likewise.
* locale/programs/lc-time.c: Likewise.
* locale/programs/locale.c: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locfile.c: Likewise.
* locale/programs/repertoire.c: Likewise.
* locale/programs/repertoire.h: Likewise.
* locale/programs/locfile.c: Update prototypes.
Update handle_copy definition.
* locale/programs/linereader.c: Add handling of wide char strings and
new definition file syntax.
* locale/programs/linereader.h (struct token): Add elements for wide
character strings.
* locale/programs/locale-spec.c: Disable handling of collation
elements for now.
* locale/programs/simple-hash.h: Cleanup.
* locale/programs/stringtrans.h: Handle quite of end of line.
* string/strcoll.c: Fall back on strcmp for now.
* string/strxfrm.c: Fall back on strncpy/strlen for now.
* time/strftime.c: Use new wide character data for wcsftime.
* time/strptime.c: Remove _nl_C_LC_TIME declaration.
* wctype/cname-lookup.h: Update for new LC_CTYPE data.
* sysdeps/i386/Makefile [csu]: Define CFLAGS-initfini.s to force
compiling for i386 to avoid i686-like GOT pointer computation.

47
locale/C-address.c Normal file
View File

@ -0,0 +1,47 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <endian.h>
#include "localeinfo.h"
/* This table's entries are taken from ISO 14652, the table in section
4.10 "LC_ADDRESS". */
const struct locale_data _nl_C_LC_ADDRESS =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
12,
{
{ string: "%a%N%f%N%d%N%b%N%s %h %e %r%N%C-%z %T%N%c%N" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" }
}
};

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
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
@ -29,28 +29,28 @@
is set to always return 0 and the conversion arrays return EOF. */
const char _nl_C_LC_CTYPE_class[768] =
/* 0x80 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x86 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x8c */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x92 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x98 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x9e */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xa4 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xaa */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xb0 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xb6 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xbc */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xc2 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xc8 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xce */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xd4 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xda */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xe0 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xe6 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xec */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xf2 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xf8 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xfe */ "\000\000" "\000\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x80 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x86 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x8c */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x92 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x98 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x9e */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xa4 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xaa */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xb0 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xb6 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xbc */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xc2 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xc8 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xce */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xd4 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xda */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xe0 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xe6 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xec */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xf2 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xf8 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xfe */ "\002\000" "\000\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x04 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\003\040"
/* 0x0a */ "\002\040" "\002\040" "\002\040" "\002\040" "\002\000" "\002\000"
/* 0x10 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
@ -71,28 +71,28 @@ const char _nl_C_LC_CTYPE_class[768] =
/* 0x6a */ "\010\306" "\010\306" "\010\306" "\010\306" "\010\306" "\010\306"
/* 0x70 */ "\010\306" "\010\306" "\010\306" "\010\306" "\010\306" "\010\306"
/* 0x76 */ "\010\306" "\010\306" "\010\306" "\010\306" "\010\306" "\004\300"
/* 0x7c */ "\004\300" "\004\300" "\004\300" "\002\000" "\000\000" "\000\000"
/* 0x82 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x88 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x8e */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x94 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x9a */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xa0 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xa6 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xac */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xb2 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xb8 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xbe */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xc4 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xca */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xd0 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xd6 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xdc */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xe2 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xe8 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xee */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xf4 */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0xfa */ "\000\000" "\000\000" "\000\000" "\000\000" "\000\000" "\000\000"
/* 0x7c */ "\004\300" "\004\300" "\004\300" "\002\000" "\002\000" "\002\000"
/* 0x82 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x88 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x8e */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x94 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0x9a */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xa0 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xa6 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xac */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xb2 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xb8 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xbe */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xc4 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xca */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xd0 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xd6 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xdc */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xe2 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xe8 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xee */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xf4 */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
/* 0xfa */ "\002\000" "\002\000" "\002\000" "\002\000" "\002\000" "\002\000"
;
const char _nl_C_LC_CTYPE_class32[1024] =
/* 0x00 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
@ -137,50 +137,50 @@ const char _nl_C_LC_CTYPE_class32[1024] =
/* 0x75 */ "\000\000\010\306" "\000\000\010\306" "\000\000\010\306"
/* 0x78 */ "\000\000\010\306" "\000\000\010\306" "\000\000\010\306"
/* 0x7b */ "\000\000\004\300" "\000\000\004\300" "\000\000\004\300"
/* 0x7e */ "\000\000\004\300" "\000\000\002\000" "\000\000\000\000"
/* 0x81 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x84 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x87 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x8a */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x8d */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x90 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x93 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x96 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x99 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x9c */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0x9f */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xa2 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xa5 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xa8 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xab */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xae */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xb1 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xb4 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xb7 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xba */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xbd */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xc0 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xc3 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xc6 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xc9 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xcc */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xcf */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xd2 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xd5 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xd8 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xdb */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xde */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xe1 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xe4 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xe7 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xea */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xed */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xf0 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xf3 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xf6 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xf9 */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xfc */ "\000\000\000\000" "\000\000\000\000" "\000\000\000\000"
/* 0xff */ "\000\000\000\000"
/* 0x7e */ "\000\000\004\300" "\000\000\002\000" "\000\000\002\000"
/* 0x81 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x84 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x87 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x8a */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x8d */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x90 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x93 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x96 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x99 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x9c */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0x9f */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xa2 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xa5 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xa8 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xab */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xae */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xb1 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xb4 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xb7 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xba */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xbd */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xc0 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xc3 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xc6 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xc9 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xcc */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xcf */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xd2 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xd5 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xd8 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xdb */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xde */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xe1 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xe4 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xe7 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xea */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xed */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xf0 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xf3 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xf6 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xf9 */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xfc */ "\000\000\002\000" "\000\000\002\000" "\000\000\002\000"
/* 0xff */ "\000\000\002\000"
;
const u_int32_t _nl_C_LC_CTYPE_toupper[384] =
{
@ -364,10 +364,115 @@ const struct locale_data _nl_C_LC_CTYPE =
#endif
{ word: 256 }, { word: 1 },
{ string: "upper\0" "lower\0" "alpha\0" "digit\0" "xdigit\0" "space\0"
"print\0" "graph\0" "blank\0" "cntrl\0" "punct\0" "alnum\0" },
{ string: "tolower\0" "toupper\0" },
"print\0" "graph\0" "blank\0" "cntrl\0" "punct\0" "alnum\0"
"left_to_right\0" "right_to_left\0" "num_terminator\0"
"num_separator\0" "segment_separator\0" "block_separator\0"
"direction_control\0" "sym_swap_layout\0" "char_shape_selector\0"
"num_share_selector\0" "non_spacing\0" "non_spacing_level3\0"
"r_connect\0" "no_connect\0" "no_connect-space\0"
"vowel_connect\0" },
{ string: "tolower\0" "toupper\0" "tosymmetric\0" },
{ string: _nl_C_LC_CTYPE_width },
{ word: 1 },
{ string: "ANSI_X3.4-1968" }
{ string: "ANSI_X3.4-1968" },
{ word: 1 },
{ string: "0" },
{ string: "1" },
{ string: "2" },
{ string: "3" },
{ string: "4" },
{ string: "5" },
{ string: "6" },
{ string: "7" },
{ string: "8" },
{ string: "9" },
#if BYTE_ORDER == LITTLE_ENDIAN
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
#endif
{ wstr: (uint32_t *) L"0" },
{ wstr: (uint32_t *) L"1" },
{ wstr: (uint32_t *) L"2" },
{ wstr: (uint32_t *) L"3" },
{ wstr: (uint32_t *) L"4" },
{ wstr: (uint32_t *) L"5" },
{ wstr: (uint32_t *) L"6" },
{ wstr: (uint32_t *) L"7" },
{ wstr: (uint32_t *) L"8" },
{ wstr: (uint32_t *) L"9" },
#if BYTE_ORDER == BIG_ENDIAN
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
{ wstr: (uint32_t *) L"" },
#endif
{ string: "0" },
{ string: "1" },
{ string: "2" },
{ string: "3" },
{ string: "4" },
{ string: "5" },
{ string: "6" },
{ string: "7" },
{ string: "8" },
{ string: "9" },
#if BYTE_ORDER == LITTLE_ENDIAN
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
#endif
{ word: L'0' },
{ word: L'1' },
{ word: L'2' },
{ word: L'3' },
{ word: L'4' },
{ word: L'5' },
{ word: L'6' },
{ word: L'7' },
{ word: L'8' },
{ word: L'9' },
#if BYTE_ORDER == BIG_ENDIAN
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
{ word: L'\0' },
#endif
{ word: 0 },
{ word: 0 },
{ word: 0 },
{ word: 0 },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" }
}
};

54
locale/C-identification.c Normal file
View File

@ -0,0 +1,54 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <endian.h>
#include "localeinfo.h"
/* This table's entries are taken from ISO 14652, the table in section
4.12 "LC_IDENTIFICATION". */
const struct locale_data _nl_C_LC_IDENTIFICATION =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
15,
{
{ string: "ISO/IEC 14652 i18n FDCC-set" },
{ string: "ISO/IEC JTC1/SC22/WG20 - internationalization" },
{ string: "C/o Keld Simonsen, Skt. Jorgens Alle 8, DK-1615 Kobenhavn V" },
{ string: "Keld Simonsen" },
{ string: "keld@dkuug.dk" },
{ string: "+45 3122-6543" },
{ string: "+45 3325-6543" },
{ string: "" },
{ string: "ISO" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "1.0" },
{ string: "1997-12-20" },
{ string: "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0"
"i18n:1999\0" "i18n:1999\0" "\0" "i18n:1999\0"
"i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0"
"i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0"
"i18n:1999" }
}
};

36
locale/C-measurement.c Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <endian.h>
#include "localeinfo.h"
/* This table's entries are taken from ISO 14652, the table in section
4.12 "LC_MEASUREMENT". */
const struct locale_data _nl_C_LC_MEASUREMENT =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
1,
{
{ string: "\1" }
}
};

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@ -33,7 +33,7 @@ const struct locale_data _nl_C_LC_MESSAGES =
{
{ string: "^[yY]" },
{ string: "^[nN]" },
{ string: "yes" },
{ string: "no" }
{ string: "" },
{ string: "" }
}
};

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@ -20,7 +20,8 @@
#include "localeinfo.h"
/* This table's entries are taken from POSIX.2 Table 2-9
``LC_MONETARY Category Definition in the POSIX Locale''. */
``LC_MONETARY Category Definition in the POSIX Locale'',
with additions from ISO 14652, section 4.4. */
#ifdef __CHAR_UNSIGNED__
static const char not_available[] = "\377";
#else
@ -32,7 +33,7 @@ const struct locale_data _nl_C_LC_MONETARY =
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
15,
49,
{
{ string: "" },
{ string: "" },
@ -48,6 +49,34 @@ const struct locale_data _nl_C_LC_MONETARY =
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available }
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: "" },
{ string: "" },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ string: not_available },
{ word: 10101 },
{ word: 99991231 },
{ word: 10101 },
{ word: 99991231 },
{ word: 1 },
{ word: 1 }
}
};

41
locale/C-name.c Normal file
View File

@ -0,0 +1,41 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <endian.h>
#include "localeinfo.h"
/* This table's entries are taken from ISO 14652, the table in section
4.9 "LC_NAME". */
const struct locale_data _nl_C_LC_NAME =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
6,
{
{ string: "%p%t%g%t%m%t%f" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" }
}
};

39
locale/C-paper.c Normal file
View File

@ -0,0 +1,39 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <endian.h>
#include "localeinfo.h"
/* This table's entries are taken from ISO 14652, the table in section
4.8 "LC_PAPER". */
const struct locale_data _nl_C_LC_PAPER =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
4,
{
{ word: 297 },
{ word: 297 },
{ word: 210 },
{ word: 210 }
}
};

39
locale/C-telephone.c Normal file
View File

@ -0,0 +1,39 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <endian.h>
#include "localeinfo.h"
/* This table's entries are taken from ISO 14652, the table in section
4.11 "LC_TELEPHONE". */
const struct locale_data _nl_C_LC_TELEPHONE =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
4,
{
{ string: "+%c %a %l" },
{ string: "" },
{ string: "" },
{ string: "" }
}
};

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
@ -20,14 +20,15 @@
#include "localeinfo.h"
/* This table's entries are taken from POSIX.2 Table 2-11
``LC_TIME Category Definition in the POSIX Locale''. */
``LC_TIME Category Definition in the POSIX Locale'',
with additions from ISO 14652, section 4.6. */
const struct locale_data _nl_C_LC_TIME =
{
_nl_C_name,
NULL, 0, 0, /* no file mapped */
UNDELETABLE,
104,
62,
{
{ string: "Sun" },
{ string: "Mon" },
@ -80,58 +81,65 @@ const struct locale_data _nl_C_LC_TIME =
{ string: "" },
{ string: "" },
{ word: 0 },
{ word: 0 },
{ string: "" },
{ string: "" },
{ wstr: L"Sun" },
{ wstr: L"Mon" },
{ wstr: L"Tue" },
{ wstr: L"Wed" },
{ wstr: L"Thu" },
{ wstr: L"Fri" },
{ wstr: L"Sat" },
{ wstr: L"Sunday" },
{ wstr: L"Monday" },
{ wstr: L"Tuesday" },
{ wstr: L"Wednesday" },
{ wstr: L"Thursday" },
{ wstr: L"Friday" },
{ wstr: L"Saturday" },
{ wstr: L"Jan" },
{ wstr: L"Feb" },
{ wstr: L"Mar" },
{ wstr: L"Apr" },
{ wstr: L"May" },
{ wstr: L"Jun" },
{ wstr: L"Jul" },
{ wstr: L"Aug" },
{ wstr: L"Sep" },
{ wstr: L"Oct" },
{ wstr: L"Nov" },
{ wstr: L"Dec" },
{ wstr: L"January" },
{ wstr: L"February" },
{ wstr: L"March" },
{ wstr: L"April" },
{ wstr: L"May" },
{ wstr: L"June" },
{ wstr: L"July" },
{ wstr: L"August" },
{ wstr: L"September" },
{ wstr: L"October" },
{ wstr: L"November" },
{ wstr: L"December" },
{ wstr: L"AM" },
{ wstr: L"PM" },
{ wstr: L"%a %b %e %H:%M:%S %Y" },
{ wstr: L"%m/%d/%y" },
{ wstr: L"%H:%M:%S" },
{ wstr: L"%I:%M:%S %p" },
{ string: NULL },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ string: "" },
{ wstr: (const uint32_t *) L"Sun" },
{ wstr: (const uint32_t *) L"Mon" },
{ wstr: (const uint32_t *) L"Tue" },
{ wstr: (const uint32_t *) L"Wed" },
{ wstr: (const uint32_t *) L"Thu" },
{ wstr: (const uint32_t *) L"Fri" },
{ wstr: (const uint32_t *) L"Sat" },
{ wstr: (const uint32_t *) L"Sunday" },
{ wstr: (const uint32_t *) L"Monday" },
{ wstr: (const uint32_t *) L"Tuesday" },
{ wstr: (const uint32_t *) L"Wednesday" },
{ wstr: (const uint32_t *) L"Thursday" },
{ wstr: (const uint32_t *) L"Friday" },
{ wstr: (const uint32_t *) L"Saturday" },
{ wstr: (const uint32_t *) L"Jan" },
{ wstr: (const uint32_t *) L"Feb" },
{ wstr: (const uint32_t *) L"Mar" },
{ wstr: (const uint32_t *) L"Apr" },
{ wstr: (const uint32_t *) L"May" },
{ wstr: (const uint32_t *) L"Jun" },
{ wstr: (const uint32_t *) L"Jul" },
{ wstr: (const uint32_t *) L"Aug" },
{ wstr: (const uint32_t *) L"Sep" },
{ wstr: (const uint32_t *) L"Oct" },
{ wstr: (const uint32_t *) L"Nov" },
{ wstr: (const uint32_t *) L"Dec" },
{ wstr: (const uint32_t *) L"January" },
{ wstr: (const uint32_t *) L"February" },
{ wstr: (const uint32_t *) L"March" },
{ wstr: (const uint32_t *) L"April" },
{ wstr: (const uint32_t *) L"May" },
{ wstr: (const uint32_t *) L"June" },
{ wstr: (const uint32_t *) L"July" },
{ wstr: (const uint32_t *) L"August" },
{ wstr: (const uint32_t *) L"September" },
{ wstr: (const uint32_t *) L"October" },
{ wstr: (const uint32_t *) L"November" },
{ wstr: (const uint32_t *) L"December" },
{ wstr: (const uint32_t *) L"AM" },
{ wstr: (const uint32_t *) L"PM" },
{ wstr: (const uint32_t *) L"%a %b %e %H:%M:%S %Y" },
{ wstr: (const uint32_t *) L"%m/%d/%y" },
{ wstr: (const uint32_t *) L"%H:%M:%S" },
{ wstr: (const uint32_t *) L"%I:%M:%S %p" },
{ wstr: NULL },
{ wstr: (const uint32_t *) L"" },
{ wstr: (const uint32_t *) L"" },
{ wstr: (const uint32_t *) L"" },
{ wstr: (const uint32_t *) L"" },
{ wstr: (const uint32_t *) L"" },
{ string: "\7" },
{ word: 19971130 },
{ word: 19971130 },
{ string: "\7" },
{ string: "\1" },
{ string: "\7" },
{ string: "\1" },
{ string: "" }
}
};

View File

@ -1,4 +1,4 @@
# Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
# Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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
@ -22,22 +22,26 @@
subdir := locale
headers = locale.h langinfo.h xlocale.h
distribute = localeinfo.h categories.def iso-4217.def weight.h \
strlen-hash.h \
distribute = localeinfo.h categories.def iso-639.def iso-3166.def \
iso-4217.def weight.h strlen-hash.h \
$(addprefix programs/, \
locale.c localedef.c \
$(localedef-modules:=.c) $(locale-modules:=.c) \
$(lib-modules:=.c) config.h simple-hash.h \
charmap-kw.gperf charmap-kw.h locfile-token.h \
locfile-kw.gperf locfile-kw.h linereader.h \
locales.h locfile.h stringtrans.h charset.h \
locales.h locfile.h stringtrans.h charmap.h \
repertoire.h)
routines = setlocale findlocale loadlocale localeconv nl_langinfo \
mb_cur_max codeset_name \
newlocale duplocale freelocale
categories = ctype messages monetary numeric time collate
#categories = ctype messages monetary numeric time collate paper name \
# address telephone measurement versions
categories = ctype messages monetary numeric time paper name \
address telephone measurement identification collate
aux = $(categories:%=lc-%) $(categories:%=C-%) SYS_libc C_name
others = localedef locale
# XXX For testing this is now others-static instead of others.
others-static = localedef locale
install-bin = localedef locale
extra-objs = $(localedef-modules:=.o) $(locale-modules:=.o) \
$(lib-modules:=.o)
@ -52,14 +56,14 @@ vpath %.c programs
vpath %.h programs
vpath %.gperf programs
localedef-modules := $(categories:%=ld-%) charmap charset linereader \
locfile stringtrans repertoire
localedef-modules := $(categories:%=ld-%) charmap linereader locfile \
repertoire
locale-modules := locale-spec
lib-modules := simple-hash xmalloc xstrdup
GPERF = gperf
GPERFFLAGS = -acCgopt -k1,2,5,$$
GPERFFLAGS = -acCgopt -k1,2,5,9,$$ -L ANSI-C
include ../Rules
@ -73,13 +77,13 @@ $(objpfx)localedef $(objpfx)locale: $(lib-modules:%=$(objpfx)%.o)
localepath = "$(localedir):$(i18ndir)"
locale-CPPFLAGS := -DLOCALE_PATH='$(localepath)' \
-DLOCALEDIR='"$(localedir)"' \
-DLOCALE_ALIAS_PATH='"$(localedir):$(i18ndir)"' \
-DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
-DREPERTOIREMAP_PATH='"$(i18ndir)/repertoiremaps"' \
-DLOCSRCDIR='"$(i18ndir)/locales"' -DHAVE_CONFIG_H \
-Iprograms
CPPFLAGS := -DLOCALE_PATH='$(localepath)' \
-DLOCALEDIR='"$(localedir)"' \
-DLOCALE_ALIAS_PATH='"$(localedir):$(i18ndir)"' \
-DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
-DREPERTOIREMAP_PATH='"$(i18ndir)/repertoiremaps"' \
-DLOCSRCDIR='"$(i18ndir)/locales"' -DHAVE_CONFIG_H \
-Iprograms $(CPPFLAGS)
CFLAGS-charmap.c = -Wno-write-strings -Wno-char-subscripts
CFLAGS-locfile.c = -Wno-write-strings -Wno-char-subscripts

View File

@ -1,5 +1,5 @@
/* Definition of all available locale categories and their items. -*- C -*-
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
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
@ -21,8 +21,7 @@
The general format of the descriptions is like this:
DEFINE_CATEGORY (ID, name, ( items ), setlocale-postload,
locale-input, locale-check, locale-output)
DEFINE_CATEGORY (ID, name, ( items ), setlocale-postload)
where items itself is an array of entries in the form
@ -43,28 +42,28 @@ DEFINE_CATEGORY
(
LC_COLLATE, "LC_COLLATE",
(
DEFINE_ELEMENT (_NL_COLLATE_NRULES, "collate-nrules", std, word)
DEFINE_ELEMENT (_NL_COLLATE_RULES, "collate-rules", std, string)
DEFINE_ELEMENT (_NL_COLLATE_HASH_SIZE, "collate-hash-size", std, word)
DEFINE_ELEMENT (_NL_COLLATE_NRULES, "collate-nrules", std, word)
DEFINE_ELEMENT (_NL_COLLATE_RULES, "collate-rules", std, string)
DEFINE_ELEMENT (_NL_COLLATE_HASH_SIZE, "collate-hash-size", std, word)
DEFINE_ELEMENT (_NL_COLLATE_HASH_LAYERS, "collate-hash-layers", std, word)
DEFINE_ELEMENT (_NL_COLLATE_TABLE_EB, "collate-table-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_TABLE_EL, "collate-table-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_UNDEFINED, "collate-undefined", std, word)
DEFINE_ELEMENT (_NL_COLLATE_EXTRA_EB, "collate-extra-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_EXTRA_EL, "collate-extra-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_TABLEWC_EB, "collate-tablewc-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_TABLEWC_EL, "collate-tablewc-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_UNDEFINED_WC, "collate-undefined-wc", std, word)
DEFINE_ELEMENT (_NL_COLLATE_EXTRAWC_EB, "collate-extrawc-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_EXTRAWC_EL, "collate-extrawc-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_HASH_SIZE, "collate-elem-hash-size", std, word)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_HASH_EB, "collate-elem-hash-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_HASH_EL, "collate-elem-hash-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_STR_POOL, "collate-elem-str-pool", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_VAL_EB, "collate-elem-val-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_VAL_EL, "collate-elem-val-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_VAL_EB, "collate-elem-val-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_ELEM_VAL_EL, "collate-elem-val-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_HASH_SIZE, "collate-symb-hash-size", std, word)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_HASH_EB, "collate-symb-hash-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_HASH_EL, "collate-symb-hash-el", std, string)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_STR_POOL, "collate-symb-str-pool", std, string)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_CLASS_EB, "collate-symb-class-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_CLASS_EL, "collate-symb-class-el", std, string)
), _nl_postload_collate, collate_input, NULL, NULL)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_CLASSWC_EB, "collate-symb-classwc-eb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_SYMB_CLASSWC_EL, "collate-symb-classwc-el", std, string)
), _nl_postload_collate)
/* The actual definition of ctype is meaningless here. It is hard coded in
@ -74,44 +73,79 @@ DEFINE_CATEGORY
(
LC_CTYPE, "LC_CTYPE",
(
DEFINE_ELEMENT (_NL_CTYPE_CLASS, "ctype-class", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOUPPER_EB, "ctype-toupper-eb", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOLOWER_EB, "ctype-tolower-eb", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOUPPER_EL, "ctype-toupper-el", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOLOWER_EL, "ctype-tolower-el", std, string)
DEFINE_ELEMENT (_NL_CTYPE_CLASS32, "ctype-class32", std, string)
DEFINE_ELEMENT (_NL_CTYPE_NAMES_EB, "ctype-names-eb", std, string)
DEFINE_ELEMENT (_NL_CTYPE_NAMES_EL, "ctype-names-el", std, string)
DEFINE_ELEMENT (_NL_CTYPE_HASH_SIZE, "ctype-hash-size", std, word)
DEFINE_ELEMENT (_NL_CTYPE_HASH_LAYERS, "ctype-hash-layers", std, word)
DEFINE_ELEMENT (_NL_CTYPE_CLASS_NAMES, "ctype-class-names", std, stringlist)
DEFINE_ELEMENT (_NL_CTYPE_MAP_NAMES, "ctype-map-names", std, stringlist)
DEFINE_ELEMENT (_NL_CTYPE_WIDTH, "ctype-width", std, bytearray)
DEFINE_ELEMENT (_NL_CTYPE_MB_CUR_MAX, "ctype-mb-cur-max", std, word)
DEFINE_ELEMENT (_NL_CTYPE_CODESET_NAME, "charmap", std, string)
), _nl_postload_ctype, ctype_input, ctype_check, ctype_output)
DEFINE_ELEMENT (_NL_CTYPE_CLASS, "ctype-class", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOUPPER_EB, "ctype-toupper-eb", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOLOWER_EB, "ctype-tolower-eb", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOUPPER_EL, "ctype-toupper-el", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOLOWER_EL, "ctype-tolower-el", std, string)
DEFINE_ELEMENT (_NL_CTYPE_CLASS32, "ctype-class32", std, string)
DEFINE_ELEMENT (_NL_CTYPE_NAMES_EB, "ctype-names-eb", std, string)
DEFINE_ELEMENT (_NL_CTYPE_NAMES_EL, "ctype-names-el", std, string)
DEFINE_ELEMENT (_NL_CTYPE_HASH_SIZE_EB, "ctype-hash-size-eb", std, word)
DEFINE_ELEMENT (_NL_CTYPE_HASH_SIZE_EL, "ctype-hash-size-el", std, word)
DEFINE_ELEMENT (_NL_CTYPE_HASH_LAYERS_EB, "ctype-hash-layers-eb", std, word)
DEFINE_ELEMENT (_NL_CTYPE_HASH_LAYERS_EL, "ctype-hash-layers-el", std, word)
DEFINE_ELEMENT (_NL_CTYPE_CLASS_NAMES, "ctype-class-names", std, stringlist)
DEFINE_ELEMENT (_NL_CTYPE_MAP_NAMES, "ctype-map-names", std, stringlist)
DEFINE_ELEMENT (_NL_CTYPE_WIDTH, "ctype-width", std, bytearray)
DEFINE_ELEMENT (_NL_CTYPE_MB_CUR_MAX, "ctype-mb-cur-max", std, word)
DEFINE_ELEMENT (_NL_CTYPE_CODESET_NAME, "charmap", std, string)
), _nl_postload_ctype)
#if __BYTE_ORDER == __BIG_ENDIAN
# define _NL_MONETARY_CONVERSION_RATE _NL_MONETARY_CONVERSION_RATE_EB
#else
# define _NL_MONETARY_CONVERSION_RATE _NL_MONETARY_CONVERSION_RATE_EL
#endif
DEFINE_CATEGORY
(
LC_MONETARY, "LC_MONETARY",
(
DEFINE_ELEMENT (INT_CURR_SYMBOL, "int_curr_symbol", std, string)
DEFINE_ELEMENT (CURRENCY_SYMBOL, "currency_symbol", std, string)
DEFINE_ELEMENT (MON_DECIMAL_POINT, "mon_decimal_point", std, string)
DEFINE_ELEMENT (MON_THOUSANDS_SEP, "mon_thousands_sep", std, string)
DEFINE_ELEMENT (MON_GROUPING, "mon_grouping", std, bytearray)
DEFINE_ELEMENT (POSITIVE_SIGN, "positive_sign", std, string)
DEFINE_ELEMENT (NEGATIVE_SIGN, "negative_sign", std, string)
DEFINE_ELEMENT (INT_FRAC_DIGITS, "int_frac_digits", std, byte)
DEFINE_ELEMENT (FRAC_DIGITS, "frac_digits", std, byte)
DEFINE_ELEMENT (P_CS_PRECEDES, "p_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (P_SEP_BY_SPACE, "p_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (N_CS_PRECEDES, "n_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (N_SEP_BY_SPACE, "n_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (P_SIGN_POSN, "p_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (N_SIGN_POSN, "n_sign_posn", std, byte, 0, 4)
), NO_POSTLOAD, NULL, monetary_check, NULL)
DEFINE_ELEMENT (INT_CURR_SYMBOL, "int_curr_symbol", std, string)
DEFINE_ELEMENT (CURRENCY_SYMBOL, "currency_symbol", std, string)
DEFINE_ELEMENT (MON_DECIMAL_POINT, "mon_decimal_point", std, string)
DEFINE_ELEMENT (MON_THOUSANDS_SEP, "mon_thousands_sep", std, string)
DEFINE_ELEMENT (MON_GROUPING, "mon_grouping", std, bytearray)
DEFINE_ELEMENT (POSITIVE_SIGN, "positive_sign", std, string)
DEFINE_ELEMENT (NEGATIVE_SIGN, "negative_sign", std, string)
DEFINE_ELEMENT (INT_FRAC_DIGITS, "int_frac_digits", std, byte)
DEFINE_ELEMENT (FRAC_DIGITS, "frac_digits", std, byte)
DEFINE_ELEMENT (P_CS_PRECEDES, "p_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (P_SEP_BY_SPACE, "p_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (N_CS_PRECEDES, "n_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (N_SEP_BY_SPACE, "n_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (P_SIGN_POSN, "p_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (N_SIGN_POSN, "n_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_INT_P_CS_PRECEDES, "int_p_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (_NL_MONETARY_INT_P_SEP_BY_SPACE, "int_p_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (_NL_MONETARY_INT_N_CS_PRECEDES, "int_n_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (_NL_MONETARY_INT_N_SEP_BY_SPACE, "int_n_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (_NL_MONETARY_INT_P_SIGN_POSN, "int_p_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_INT_N_SIGN_POSN, "int_n_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_CURR_SYMBOL, "duo_int_curr_symbol", std, string)
DEFINE_ELEMENT (_NL_MONETARY_DUO_CURRENCY_SYMBOL, "duo_currency_symbol", std, string)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_FRAC_DIGITS, "duo_int_frac_digits", std, byte)
DEFINE_ELEMENT (_NL_MONETARY_DUO_FRAC_DIGITS, "duo_frac_digits", std, byte)
DEFINE_ELEMENT (_NL_MONETARY_DUO_P_CS_PRECEDES, "duo_p_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (_NL_MONETARY_DUO_P_SEP_BY_SPACE, "duo_p_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (_NL_MONETARY_DUO_N_CS_PRECEDES, "duo_n_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (_NL_MONETARY_DUO_N_SEP_BY_SPACE, "duo_n_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_P_CS_PRECEDES, "duo_int_p_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE, "duo_int_p_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_N_CS_PRECEDES, "duo_int_n_cs_precedes", std, byte, 0, 1)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE, "duo_int_n_sep_by_space", std, byte, 0, 2)
DEFINE_ELEMENT (_NL_MONETARY_DUO_P_SIGN_POSN, "duo_p_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_DUO_N_SIGN_POSN, "duo_n_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_P_SIGN_POSN, "duo_int_p_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_DUO_INT_N_SIGN_POSN, "duo_int_n_sign_posn", std, byte, 0, 4)
DEFINE_ELEMENT (_NL_MONETARY_UNO_VALID_FROM, "uno_valid_from", std, word)
DEFINE_ELEMENT (_NL_MONETARY_UNO_VALID_TO, "uno_valid_to", std, word)
DEFINE_ELEMENT (_NL_MONETARY_DUO_VALID_FROM, "duo_valid_from", std, word)
DEFINE_ELEMENT (_NL_MONETARY_DUO_VALID_TO, "duo_valid_to", std, word)
DEFINE_ELEMENT (_NL_MONETARY_CONVERSION_RATE_EB, "conversion_rate-eb", std, wordarray, 2, 2)
DEFINE_ELEMENT (_NL_MONETARY_CONVERSION_RATE_EL, "conversion_rate-el", std, wordarray, 2, 2)
), NO_POSTLOAD)
DEFINE_CATEGORY
@ -121,7 +155,7 @@ DEFINE_CATEGORY
DEFINE_ELEMENT (DECIMAL_POINT, "decimal_point", std, string)
DEFINE_ELEMENT (THOUSANDS_SEP, "thousands_sep", std, string)
DEFINE_ELEMENT (GROUPING, "grouping", std, bytearray)
), NO_POSTLOAD, NULL, numeric_check, NULL)
), NO_POSTLOAD)
DEFINE_CATEGORY
@ -143,34 +177,133 @@ DEFINE_CATEGORY
DEFINE_ELEMENT (ALT_DIGITS, "alt_digits", opt, stringarray, 0, 100)
DEFINE_ELEMENT (ERA_D_T_FMT, "era_d_t_fmt", opt, string)
DEFINE_ELEMENT (ERA_T_FMT, "era_t_fmt", opt, string)
DEFINE_ELEMENT (_NL_TIME_NUM_ALT_DIGITS, "time-num-alt-digits", opt, word)
DEFINE_ELEMENT (_NL_TIME_ERA_NUM_ENTRIES, "time-era-num-entries", opt, word)
DEFINE_ELEMENT (_NL_TIME_ERA_NUM_ENTRIES_EB, "time-era-num-entries-eb", opt, word)
DEFINE_ELEMENT (_NL_TIME_ERA_NUM_ENTRIES_EL, "time-era-num-entries-el", opt, word)
DEFINE_ELEMENT (_NL_TIME_ERA_ENTRIES_EB, "time-era-entries-eb", opt, string)
DEFINE_ELEMENT (_NL_TIME_ERA_ENTRIES_EL, "time-era-entries-el", opt, string)
DEFINE_ELEMENT (_NL_WABDAY_1, "wide-abday", std, stringarray, 7, 7)
DEFINE_ELEMENT (_NL_WDAY_1, "wide-day", std, stringarray, 7, 7)
DEFINE_ELEMENT (_NL_WABMON_1, "wide-abmon", std, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WMON_1, "wide-mon", std, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WAM_STR, "wide-am_pm", std, stringarray, 2, 2)
DEFINE_ELEMENT (_NL_WD_T_FMT, "wide-d_t_fmt", std, string)
DEFINE_ELEMENT (_NL_WD_FMT, "wide-d_fmt", std, string)
DEFINE_ELEMENT (_NL_WT_FMT, "wide-t_fmt", std, string)
DEFINE_ELEMENT (_NL_WT_FMT_AMPM, "wide-t_fmt_ampm", std, string)
DEFINE_ELEMENT (_NL_WERA, "wide-era", opt, stringarray)
DEFINE_ELEMENT (_NL_WERA_YEAR, "wide-era_year", opt, string)
DEFINE_ELEMENT (_NL_WERA_D_FMT, "wide-era_d_fmt", opt, string)
DEFINE_ELEMENT (_NL_WALT_DIGITS, "wide-alt_digits", opt, stringarray, 0, 100)
DEFINE_ELEMENT (_NL_WERA_D_T_FMT, "wide-era_d_t_fmt", opt, string)
DEFINE_ELEMENT (_NL_WERA_T_FMT, "wide-era_t_fmt", opt, string)
), _nl_postload_time, NULL, NULL, NULL)
DEFINE_ELEMENT (_NL_WABDAY_1_EB, "wide-abday-eb", std, stringarray, 7, 7)
DEFINE_ELEMENT (_NL_WABDAY_1_EL, "wide-abday-el", std, stringarray, 7, 7)
DEFINE_ELEMENT (_NL_WDAY_1_EB, "wide-day-eb", std, stringarray, 7, 7)
DEFINE_ELEMENT (_NL_WDAY_1_EL, "wide-day-el", std, stringarray, 7, 7)
DEFINE_ELEMENT (_NL_WABMON_1_EB, "wide-abmon-eb", std, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WABMON_1_EL, "wide-abmon-el", std, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WMON_1_EB, "wide-mon-eb", std, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WMON_1_EL, "wide-mon-el", std, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WAM_STR_EB, "wide-am_pm-eb", std, stringarray, 2, 2)
DEFINE_ELEMENT (_NL_WAM_STR_EL, "wide-am_pm-el", std, stringarray, 2, 2)
DEFINE_ELEMENT (_NL_WD_T_FMT_EB, "wide-d_t_fmt-eb", std, string)
DEFINE_ELEMENT (_NL_WD_T_FMT_EL, "wide-d_t_fmt-el", std, string)
DEFINE_ELEMENT (_NL_WD_FMT_EB, "wide-d_fmt-eb", std, string)
DEFINE_ELEMENT (_NL_WD_FMT_EL, "wide-d_fmt-el", std, string)
DEFINE_ELEMENT (_NL_WT_FMT_EB, "wide-t_fmt-eb", std, string)
DEFINE_ELEMENT (_NL_WT_FMT_EL, "wide-t_fmt-el", std, string)
DEFINE_ELEMENT (_NL_WT_FMT_AMPM_EB, "wide-t_fmt_ampm-eb", std, string)
DEFINE_ELEMENT (_NL_WT_FMT_AMPM_EL, "wide-t_fmt_ampm-el", std, string)
DEFINE_ELEMENT (_NL_WERA_YEAR_EB, "wide-era_year-eb", opt, string)
DEFINE_ELEMENT (_NL_WERA_YEAR_EL, "wide-era_year-el", opt, string)
DEFINE_ELEMENT (_NL_WERA_D_FMT_EB, "wide-era_d_fmt-eb", opt, string)
DEFINE_ELEMENT (_NL_WERA_D_FMT_EL, "wide-era_d_fmt-el", opt, string)
DEFINE_ELEMENT (_NL_WALT_DIGITS_EB, "wide-alt_digits-eb", opt, stringarray, 0, 100)
DEFINE_ELEMENT (_NL_WALT_DIGITS_EL, "wide-alt_digits-el", opt, stringarray, 0, 100)
DEFINE_ELEMENT (_NL_WERA_D_T_FMT_EB, "wide-era_d_t_fmt-eb", opt, string)
DEFINE_ELEMENT (_NL_WERA_D_T_FMT_EL, "wide-era_d_t_fmt-el", opt, string)
DEFINE_ELEMENT (_NL_WERA_T_FMT_EB, "wide-era_t_fmt-eb", opt, string)
DEFINE_ELEMENT (_NL_WERA_T_FMT_EL, "wide-era_t_fmt-el", opt, string)
DEFINE_ELEMENT (_NL_TIME_WEEK_NDAYS, "week-ndays", std, byte)
DEFINE_ELEMENT (_NL_TIME_WEEK_1STDAY, "week-1stday", std, word)
DEFINE_ELEMENT (_NL_TIME_WEEK_1STWEEK, "week-1stweek", std, byte)
DEFINE_ELEMENT (_NL_TIME_FIRST_WEEKDAY, "first_weekday", std, byte)
DEFINE_ELEMENT (_NL_TIME_FIRST_WORKDAY, "first_workday", std, byte)
DEFINE_ELEMENT (_NL_TIME_CAL_DIRECTION, "cal_direction", std, byte)
DEFINE_ELEMENT (_NL_TIME_TIMEZONE, "timezone", std, string)
), _nl_postload_time)
DEFINE_CATEGORY
(
LC_MESSAGES, "LC_MESSAGES",
(
DEFINE_ELEMENT (YESEXPR, "yesexpr", std, string)
DEFINE_ELEMENT (NOEXPR, "noexpr", std, string)
DEFINE_ELEMENT (__YESSTR, "yesstr", opt, string)
DEFINE_ELEMENT (__NOSTR, "nostr", opt, string)
), NO_POSTLOAD, NULL, messages_check, NULL)
DEFINE_ELEMENT (YESEXPR, "yesexpr", std, string)
DEFINE_ELEMENT (NOEXPR, "noexpr", std, string)
DEFINE_ELEMENT (YESSTR, "yesstr", opt, string)
DEFINE_ELEMENT (NOSTR, "nostr", opt, string)
), NO_POSTLOAD)
DEFINE_CATEGORY
(
LC_PAPER, "LC_PAPER",
(
DEFINE_ELEMENT (_NL_PAPER_HEIGHT_EB, "height-eb", std, word)
DEFINE_ELEMENT (_NL_PAPER_HEIGHT_EL, "height-el", std, word)
DEFINE_ELEMENT (_NL_PAPER_WIDTH_EB, "width-eb", std, word)
DEFINE_ELEMENT (_NL_PAPER_WIDTH_EL, "width-el", std, word)
), NO_POSTLOAD)
DEFINE_CATEGORY
(
LC_NAME, "LC_NAME",
(
DEFINE_ELEMENT (_NL_NAME_NAME_FMT, "name_fmt", std, string)
DEFINE_ELEMENT (_NL_NAME_NAME_GEN, "name_gen", std, string)
DEFINE_ELEMENT (_NL_NAME_NAME_MR, "name_mr", std, string)
DEFINE_ELEMENT (_NL_NAME_NAME_MRS, "name_mrs", std, string)
DEFINE_ELEMENT (_NL_NAME_NAME_MISS, "name_miss", std, string)
DEFINE_ELEMENT (_NL_NAME_NAME_MS, "name_ms", std, string)
), NO_POSTLOAD)
DEFINE_CATEGORY
(
LC_ADDRESS, "LC_ADDRESS",
(
DEFINE_ELEMENT (_NL_ADDRESS_POSTAL_FMT, "postal_fmt", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_NAME, "country_name", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_POST, "country_post", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_AB2, "country_ab2", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_AB3, "country_ab3", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_CAR, "country_car", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_NUM_EB, "country_num-eb", std, word)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_NUM_EL, "country_num-el", std, word)
DEFINE_ELEMENT (_NL_ADDRESS_COUNTRY_ISBN, "country_isbn", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_LANG_NAME, "lang_name", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_LANG_AB, "lang_ab", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_LANG_TERM, "lang_term", std, string)
DEFINE_ELEMENT (_NL_ADDRESS_LANG_LIB, "lang_lib", std, string)
), NO_POSTLOAD)
DEFINE_CATEGORY
(
LC_TELEPHONE, "LC_TELEPHONE",
(
DEFINE_ELEMENT (_NL_TELEPHONE_TEL_INT_FMT, "tel_int_fmt", std, string)
DEFINE_ELEMENT (_NL_TELEPHONE_TEL_DOM_FMT, "tel_dom_fmt", std, string)
DEFINE_ELEMENT (_NL_TELEPHONE_INT_SELECT, "int_select", std, string)
DEFINE_ELEMENT (_NL_TELEPHONE_INT_PREFIX, "int_prefix", std, string)
), NO_POSTLOAD)
DEFINE_CATEGORY
(
LC_MEASUREMENT, "LC_MEASUREMENT",
(
DEFINE_ELEMENT (_NL_MEASUREMENT_MEASUREMENT, "measurement", std, byte)
), NO_POSTLOAD)
DEFINE_CATEGORY
(
LC_IDENTIFICATION, "LC_IDENTIFICATION",
(
DEFINE_ELEMENT (_NL_IDENTIFICATION_TITLE, "title", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_SOURCE, "source", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_ADDRESS, "address", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_CONTACT, "contact", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_EMAIL, "email", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_TEL, "tel", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_FAX, "fax", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_LANGUAGE, "language", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_TERRITORY, "territory", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_AUDIENCE, "audience", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_APPLICATION, "applcation", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_ABBREVIATION, "abbreviation", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_REVISION, "revision", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_DATE, "date", std, string)
DEFINE_ELEMENT (_NL_IDENTIFICATION_CATEGORY, "category", std, stringarray, 13, 13)
), NO_POSTLOAD)

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
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
@ -21,9 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef _POSIX_MAPPED_FILES
# include <sys/mman.h>
#endif
#include <sys/mman.h>
#include "localeinfo.h"
@ -88,7 +86,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
loc_name = (char *) *name;
/* Make a writable copy of the locale name. */
loc_name = strdupa (loc_name);
loc_name = __strdup (loc_name);
/* LOCALE can consist of up to four recognized parts for the XPG syntax:
@ -137,6 +135,11 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
/* This means we are out of core. */
return NULL;
}
else
/* If the addressed locale is already available it should be
freed. If we would not do this switching back and force
between two locales would slowly eat up all memory. */
free ((void *) loc_name);
if (locale_file->decided == 0)
_nl_load_locale (locale_file, category);
@ -208,7 +211,6 @@ _nl_remove_locale (int locale, struct locale_data *data)
/* Free the name. */
free ((char *) data->name);
#ifdef _POSIX_MAPPED_FILES
/* Really delete the data. First delete the real data. */
if (data->mmaped)
{
@ -221,7 +223,6 @@ _nl_remove_locale (int locale, struct locale_data *data)
}
}
else
#endif /* _POSIX_MAPPED_FILES */
/* The memory was malloced. */
free ((void *) data->filedata);
@ -235,21 +236,21 @@ free_mem (void)
{
int category;
for (category = 0; category < LC_ALL; ++category)
{
struct loaded_l10nfile *runp = locale_file_list[category];
for (category = 0; category < __LC_LAST; ++category)
if (category != LC_ALL)
{
struct loaded_l10nfile *runp = locale_file_list[category];
while (runp != NULL)
{
struct loaded_l10nfile *here = runp;
struct locale_data *data = (struct locale_data *) runp->data;
while (runp != NULL)
{
struct loaded_l10nfile *here = runp;
struct locale_data *data = (struct locale_data *) runp->data;
if (data != NULL && data->usage_count != UNDELETABLE)
_nl_unload_locale (data);
runp = runp->next;
free ((char *) here->filename);
free (here);
}
}
if (data != NULL && data->usage_count != UNDELETABLE)
_nl_unload_locale (data);
runp = runp->next;
free (here);
}
}
}
text_set_element (__libc_subfreeres, free_mem);

245
locale/iso-3166.def Normal file
View File

@ -0,0 +1,245 @@
/*
* Defines the country codes and abbreviations according to ISO 3166.
* This is used in ld-address.c (address_finish).
*
* If you find something missing or wrong contact <bug-glibc@gnu.org>
*/
DEFINE_COUNTRY_CODE ("AFGHANISTAN", AF, AFG, 4)
DEFINE_COUNTRY_CODE ("ALBANIA", AL, ALB, 8)
DEFINE_COUNTRY_CODE ("ALGERIA", DZ, DZA, 12)
DEFINE_COUNTRY_CODE ("AMERICAN SAMOA", AS, ASM, 16)
DEFINE_COUNTRY_CODE ("ANDORRA", AD, AND, 20)
DEFINE_COUNTRY_CODE ("ANGOLA", AO, AGO, 24)
DEFINE_COUNTRY_CODE ("ANGUILLA", AI, AIA, 660)
DEFINE_COUNTRY_CODE ("ANTARCTICA", AQ, ATA, 10)
DEFINE_COUNTRY_CODE ("ANTIGUA AND BARBUDA", AG, ATG, 28)
DEFINE_COUNTRY_CODE ("ARGENTINA", AR, ARG, 32)
DEFINE_COUNTRY_CODE ("ARMENIA", AM, ARM, 51)
DEFINE_COUNTRY_CODE ("ARUBA", AW, ABW, 533)
DEFINE_COUNTRY_CODE ("AUSTRALIA", AU, AUS, 36)
DEFINE_COUNTRY_CODE ("AUSTRIA", AT, AUT, 40)
DEFINE_COUNTRY_CODE ("AZERBAIJAN", AZ, AZE, 31)
DEFINE_COUNTRY_CODE ("BAHAMAS", BS, BHS, 44)
DEFINE_COUNTRY_CODE ("BAHRAIN", BH, BHR, 48)
DEFINE_COUNTRY_CODE ("BANGLADESH", BD, BGD, 50)
DEFINE_COUNTRY_CODE ("BARBADOS", BB, BRB, 52)
DEFINE_COUNTRY_CODE ("BELARUS", BY, BLR, 112)
DEFINE_COUNTRY_CODE ("BELGIUM", BE, BEL, 56)
DEFINE_COUNTRY_CODE ("BELIZE", BZ, BLZ, 84)
DEFINE_COUNTRY_CODE ("BENIN", BJ, BEN, 204)
DEFINE_COUNTRY_CODE ("BERMUDA", BM, BMU, 60)
DEFINE_COUNTRY_CODE ("BHUTAN", BT, BTN, 64)
DEFINE_COUNTRY_CODE ("BOLIVIA", BO, BOL, 68)
DEFINE_COUNTRY_CODE ("BOSNIA AND HERZEGOWINA", BA, BIH, 70)
DEFINE_COUNTRY_CODE ("BOTSWANA", BW, BWA, 72)
DEFINE_COUNTRY_CODE ("BOUVET ISLAND", BV, BVT, 74)
DEFINE_COUNTRY_CODE ("BRAZIL", BR, BRA, 76)
DEFINE_COUNTRY_CODE ("BRITISH INDIAN OCEAN TERRITORY", IO, IOT, 86)
DEFINE_COUNTRY_CODE ("BRUNEI DARUSSALAM", BN, BRN, 96)
DEFINE_COUNTRY_CODE ("BULGARIA", BG, BGR, 100)
DEFINE_COUNTRY_CODE ("BURKINA FASO", BF, BFA, 854)
DEFINE_COUNTRY_CODE ("BURUNDI", BI, BDI, 108)
DEFINE_COUNTRY_CODE ("CAMBODIA", KH, KHM, 116)
DEFINE_COUNTRY_CODE ("CAMEROON", CM, CMR, 120)
DEFINE_COUNTRY_CODE ("CANADA", CA, CAN, 124)
DEFINE_COUNTRY_CODE ("CAPE VERDE", CV, CPV, 132)
DEFINE_COUNTRY_CODE ("CAYMAN ISLANDS", KY, CYM, 136)
DEFINE_COUNTRY_CODE ("CENTRAL AFRICAN REPUBLIC", CF, CAF, 140)
DEFINE_COUNTRY_CODE ("CHAD", TD, TCD, 148)
DEFINE_COUNTRY_CODE ("CHILE", CL, CHL, 152)
DEFINE_COUNTRY_CODE ("CHINA", CN, CHN, 156)
DEFINE_COUNTRY_CODE ("CHRISTMAS ISLAND", CX, CXR, 162)
DEFINE_COUNTRY_CODE ("COCOS (KEELING) ISLANDS", CC, CCK, 166)
DEFINE_COUNTRY_CODE ("COLOMBIA", CO, COL, 170)
DEFINE_COUNTRY_CODE ("COMOROS", KM, COM, 174)
DEFINE_COUNTRY_CODE ("CONGO", CG, COG, 178)
DEFINE_COUNTRY_CODE ("CONGO, THE DEMOCRATIC REPUBLIC OF THE", CD, COD, 180)
DEFINE_COUNTRY_CODE ("COOK ISLANDS", CK, COK, 184)
DEFINE_COUNTRY_CODE ("COSTA RICA", CR, CRI, 188)
DEFINE_COUNTRY_CODE ("COTE D'IVOIRE", CI, CIV, 384)
DEFINE_COUNTRY_CODE ("CROATIA (local name: Hrvatska)", HR, HRV, 191)
DEFINE_COUNTRY_CODE ("CUBA", CU, CUB, 192)
DEFINE_COUNTRY_CODE ("CYPRUS", CY, CYP, 196)
DEFINE_COUNTRY_CODE ("CZECH REPUBLIC", CZ, CZE, 203)
DEFINE_COUNTRY_CODE ("DENMARK", DK, DNK, 208)
DEFINE_COUNTRY_CODE ("DJIBOUTI", DJ, DJI, 262)
DEFINE_COUNTRY_CODE ("DOMINICA", DM, DMA, 212)
DEFINE_COUNTRY_CODE ("DOMINICAN REPUBLIC", DO, DOM, 214)
DEFINE_COUNTRY_CODE ("EAST TIMOR", TP, TMP, 626)
DEFINE_COUNTRY_CODE ("ECUADOR", EC, ECU, 218)
DEFINE_COUNTRY_CODE ("EGYPT", EG, EGY, 818)
DEFINE_COUNTRY_CODE ("EL SALVADOR", SV, SLV, 222)
DEFINE_COUNTRY_CODE ("EQUATORIAL GUINEA", GQ, GNQ, 226)
DEFINE_COUNTRY_CODE ("ERITREA", ER, ERI, 232)
DEFINE_COUNTRY_CODE ("ESTONIA", EE, EST, 233)
DEFINE_COUNTRY_CODE ("ETHIOPIA", ET, ETH, 231)
DEFINE_COUNTRY_CODE ("FALKLAND ISLANDS (MALVINAS)", FK, FLK, 238)
DEFINE_COUNTRY_CODE ("FAROE ISLANDS", FO, FRO, 234)
DEFINE_COUNTRY_CODE ("FIJI", FJ, FJI, 242)
DEFINE_COUNTRY_CODE ("FINLAND", FI, FIN, 246)
DEFINE_COUNTRY_CODE ("FRANCE", FR, FRA, 250)
DEFINE_COUNTRY_CODE ("FRANCE, METROPOLITAN", FX, FXX, 249)
DEFINE_COUNTRY_CODE ("FRENCH GUIANA", GF, GUF, 254)
DEFINE_COUNTRY_CODE ("FRENCH POLYNESIA", PF, PYF, 258)
DEFINE_COUNTRY_CODE ("FRENCH SOUTHERN TERRITORIES", TF, ATF, 260)
DEFINE_COUNTRY_CODE ("GABON", GA, GAB, 266)
DEFINE_COUNTRY_CODE ("GAMBIA", GM, GMB, 270)
DEFINE_COUNTRY_CODE ("GEORGIA", GE, GEO, 268)
DEFINE_COUNTRY_CODE ("GERMANY", DE, DEU, 276)
DEFINE_COUNTRY_CODE ("GHANA", GH, GHA, 288)
DEFINE_COUNTRY_CODE ("GIBRALTAR", GI, GIB, 292)
DEFINE_COUNTRY_CODE ("GREECE", GR, GRC, 300)
DEFINE_COUNTRY_CODE ("GREENLAND", GL, GRL, 304)
DEFINE_COUNTRY_CODE ("GRENADA", GD, GRD, 308)
DEFINE_COUNTRY_CODE ("GUADELOUPE", GP, GLP, 312)
DEFINE_COUNTRY_CODE ("GUAM", GU, GUM, 316)
DEFINE_COUNTRY_CODE ("GUATEMALA", GT, GTM, 320)
DEFINE_COUNTRY_CODE ("GUINEA", GN, GIN, 324)
DEFINE_COUNTRY_CODE ("GUINEA-BISSAU", GW, GNB, 624)
DEFINE_COUNTRY_CODE ("GUYANA", GY, GUY, 328)
DEFINE_COUNTRY_CODE ("HAITI", HT, HTI, 332)
DEFINE_COUNTRY_CODE ("HEARD AND MC DONALD ISLANDS", HM, HMD, 334)
DEFINE_COUNTRY_CODE ("HOLY SEE (VATICAN CITY STATE)", VA, VAT, 336)
DEFINE_COUNTRY_CODE ("HONDURAS", HN, HND, 340)
DEFINE_COUNTRY_CODE ("HONG KONG", HK, HKG, 344)
DEFINE_COUNTRY_CODE ("HUNGARY", HU, HUN, 348)
DEFINE_COUNTRY_CODE ("ICELAND", IS, ISL, 352)
DEFINE_COUNTRY_CODE ("INDIA", IN, IND, 356)
DEFINE_COUNTRY_CODE ("INDONESIA", ID, IDN, 360)
DEFINE_COUNTRY_CODE ("IRAN (ISLAMIC REPUBLIC OF)", IR, IRN, 364)
DEFINE_COUNTRY_CODE ("IRAQ", IQ, IRQ, 368)
DEFINE_COUNTRY_CODE ("IRELAND", IE, IRL, 372)
DEFINE_COUNTRY_CODE ("ISRAEL", IL, ISR, 376)
DEFINE_COUNTRY_CODE ("ITALY", IT, ITA, 380)
DEFINE_COUNTRY_CODE ("JAMAICA", JM, JAM, 388)
DEFINE_COUNTRY_CODE ("JAPAN", JP, JPN, 392)
DEFINE_COUNTRY_CODE ("JORDAN", JO, JOR, 400)
DEFINE_COUNTRY_CODE ("KAZAKHSTAN", KZ, KAZ, 398)
DEFINE_COUNTRY_CODE ("KENYA", KE, KEN, 404)
DEFINE_COUNTRY_CODE ("KIRIBATI", KI, KIR, 296)
DEFINE_COUNTRY_CODE ("KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF", KP, PRK, 408)
DEFINE_COUNTRY_CODE ("KOREA, REPUBLIC OF", KR, KOR, 410)
DEFINE_COUNTRY_CODE ("KUWAIT", KW, KWT, 414)
DEFINE_COUNTRY_CODE ("KYRGYZSTAN", KG, KGZ, 417)
DEFINE_COUNTRY_CODE ("LAO PEOPLE'S DEMOCRATIC REPUBLIC", LA, LAO, 418)
DEFINE_COUNTRY_CODE ("LATVIA", LV, LVA, 428)
DEFINE_COUNTRY_CODE ("LEBANON", LB, LBN, 422)
DEFINE_COUNTRY_CODE ("LESOTHO", LS, LSO, 426)
DEFINE_COUNTRY_CODE ("LIBERIA", LR, LBR, 430)
DEFINE_COUNTRY_CODE ("LIBYAN ARAB JAMAHIRIYA", LY, LBY, 434)
DEFINE_COUNTRY_CODE ("LIECHTENSTEIN", LI, LIE, 438)
DEFINE_COUNTRY_CODE ("LITHUANIA", LT, LTU, 440)
DEFINE_COUNTRY_CODE ("LUXEMBOURG", LU, LUX, 442)
DEFINE_COUNTRY_CODE ("MACAU", MO, MAC, 446)
DEFINE_COUNTRY_CODE ("MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF", MK, MKD, 807)
DEFINE_COUNTRY_CODE ("MADAGASCAR", MG, MDG, 450)
DEFINE_COUNTRY_CODE ("MALAWI", MW, MWI, 454)
DEFINE_COUNTRY_CODE ("MALAYSIA", MY, MYS, 458)
DEFINE_COUNTRY_CODE ("MALDIVES", MV, MDV, 462)
DEFINE_COUNTRY_CODE ("MALI", ML, MLI, 466)
DEFINE_COUNTRY_CODE ("MALTA", MT, MLT, 470)
DEFINE_COUNTRY_CODE ("MARSHALL ISLANDS", MH, MHL, 584)
DEFINE_COUNTRY_CODE ("MARTINIQUE", MQ, MTQ, 474)
DEFINE_COUNTRY_CODE ("MAURITANIA", MR, MRT, 478)
DEFINE_COUNTRY_CODE ("MAURITIUS", MU, MUS, 480)
DEFINE_COUNTRY_CODE ("MAYOTTE", YT, MYT, 175)
DEFINE_COUNTRY_CODE ("MEXICO", MX, MEX, 484)
DEFINE_COUNTRY_CODE ("MICRONESIA, FEDERATED STATES OF", FM, FSM, 583)
DEFINE_COUNTRY_CODE ("MOLDOVA, REPUBLIC OF", MD, MDA, 498)
DEFINE_COUNTRY_CODE ("MONACO", MC, MCO, 492)
DEFINE_COUNTRY_CODE ("MONGOLIA", MN, MNG, 496)
DEFINE_COUNTRY_CODE ("MONTSERRAT", MS, MSR, 500)
DEFINE_COUNTRY_CODE ("MOROCCO", MA, MAR, 504)
DEFINE_COUNTRY_CODE ("MOZAMBIQUE", MZ, MOZ, 508)
DEFINE_COUNTRY_CODE ("MYANMAR", MM, MMR, 104)
DEFINE_COUNTRY_CODE ("NAMIBIA", NA, NAM, 516)
DEFINE_COUNTRY_CODE ("NAURU", NR, NRU, 520)
DEFINE_COUNTRY_CODE ("NEPAL", NP, NPL, 524)
DEFINE_COUNTRY_CODE ("NETHERLANDS", NL, NLD, 528)
DEFINE_COUNTRY_CODE ("NETHERLANDS ANTILLES", AN, ANT, 530)
DEFINE_COUNTRY_CODE ("NEW CALEDONIA", NC, NCL, 540)
DEFINE_COUNTRY_CODE ("NEW ZEALAND", NZ, NZL, 554)
DEFINE_COUNTRY_CODE ("NICARAGUA", NI, NIC, 558)
DEFINE_COUNTRY_CODE ("NIGER", NE, NER, 562)
DEFINE_COUNTRY_CODE ("NIGERIA", NG, NGA, 566)
DEFINE_COUNTRY_CODE ("NIUE", NU, NIU, 570)
DEFINE_COUNTRY_CODE ("NORFOLK ISLAND", NF, NFK, 574)
DEFINE_COUNTRY_CODE ("NORTHERN MARIANA ISLANDS", MP, MNP, 580)
DEFINE_COUNTRY_CODE ("NORWAY", NO, NOR, 578)
DEFINE_COUNTRY_CODE ("OMAN", OM, OMN, 512)
DEFINE_COUNTRY_CODE ("PAKISTAN", PK, PAK, 586)
DEFINE_COUNTRY_CODE ("PALAU", PW, PLW, 585)
DEFINE_COUNTRY_CODE ("PANAMA", PA, PAN, 591)
DEFINE_COUNTRY_CODE ("PAPUA NEW GUINEA", PG, PNG, 598)
DEFINE_COUNTRY_CODE ("PARAGUAY", PY, PRY, 600)
DEFINE_COUNTRY_CODE ("PERU", PE, PER, 604)
DEFINE_COUNTRY_CODE ("PHILIPPINES", PH, PHL, 608)
DEFINE_COUNTRY_CODE ("PITCAIRN", PN, PCN, 612)
DEFINE_COUNTRY_CODE ("POLAND", PL, POL, 616)
DEFINE_COUNTRY_CODE ("PORTUGAL", PT, PRT, 620)
DEFINE_COUNTRY_CODE ("PUERTO RICO", PR, PRI, 630)
DEFINE_COUNTRY_CODE ("QATAR", QA, QAT, 634)
DEFINE_COUNTRY_CODE ("REUNION", RE, REU, 638)
DEFINE_COUNTRY_CODE ("ROMANIA", RO, ROM, 642)
DEFINE_COUNTRY_CODE ("RUSSIAN FEDERATION", RU, RUS, 643)
DEFINE_COUNTRY_CODE ("RWANDA", RW, RWA, 646)
DEFINE_COUNTRY_CODE ("SAINT KITTS AND NEVIS", KN, KNA, 659)
DEFINE_COUNTRY_CODE ("SAINT LUCIA", LC, LCA, 662)
DEFINE_COUNTRY_CODE ("SAINT VINCENT AND THE GRENADINES", VC, VCT, 670)
DEFINE_COUNTRY_CODE ("SAMOA", WS, WSM, 882)
DEFINE_COUNTRY_CODE ("SAN MARINO", SM, SMR, 674)
DEFINE_COUNTRY_CODE ("SAO TOME AND PRINCIPE", ST, STP, 678)
DEFINE_COUNTRY_CODE ("SAUDI ARABIA", SA, SAU, 682)
DEFINE_COUNTRY_CODE ("SENEGAL", SN, SEN, 686)
DEFINE_COUNTRY_CODE ("SEYCHELLES", SC, SYC, 690)
DEFINE_COUNTRY_CODE ("SIERRA LEONE", SL, SLE, 694)
DEFINE_COUNTRY_CODE ("SINGAPORE", SG, SGP, 702)
DEFINE_COUNTRY_CODE ("SLOVAKIA (Slovak Republic)", SK, SVK, 703)
DEFINE_COUNTRY_CODE ("SLOVENIA", SI, SVN, 705)
DEFINE_COUNTRY_CODE ("SOLOMON ISLANDS", SB, SLB, 90)
DEFINE_COUNTRY_CODE ("SOMALIA", SO, SOM, 706)
DEFINE_COUNTRY_CODE ("SOUTH AFRICA", ZA, ZAF, 710)
DEFINE_COUNTRY_CODE ("SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS", GS, SGS, 239)
DEFINE_COUNTRY_CODE ("SPAIN", ES, ESP, 724)
DEFINE_COUNTRY_CODE ("SRI LANKA", LK, LKA, 144)
DEFINE_COUNTRY_CODE ("ST. HELENA", SH, SHN, 654)
DEFINE_COUNTRY_CODE ("ST. PIERRE AND MIQUELON", PM, SPM, 666)
DEFINE_COUNTRY_CODE ("SUDAN", SD, SDN, 736)
DEFINE_COUNTRY_CODE ("SURINAME", SR, SUR, 740)
DEFINE_COUNTRY_CODE ("SVALBARD AND JAN MAYEN ISLANDS", SJ, SJM, 744)
DEFINE_COUNTRY_CODE ("SWAZILAND", SZ, SWZ, 748)
DEFINE_COUNTRY_CODE ("SWEDEN", SE, SWE, 752)
DEFINE_COUNTRY_CODE ("SWITZERLAND", CH, CHE, 756)
DEFINE_COUNTRY_CODE ("SYRIAN ARAB REPUBLIC", SY, SYR, 760)
DEFINE_COUNTRY_CODE ("TAIWAN, PROVINCE OF CHINA", TW, TWN, 158)
DEFINE_COUNTRY_CODE ("TAJIKISTAN", TJ, TJK, 762)
DEFINE_COUNTRY_CODE ("TANZANIA, UNITED REPUBLIC OF", TZ, TZA, 834)
DEFINE_COUNTRY_CODE ("THAILAND", TH, THA, 764)
DEFINE_COUNTRY_CODE ("TOGO", TG, TGO, 768)
DEFINE_COUNTRY_CODE ("TOKELAU", TK, TKL, 772)
DEFINE_COUNTRY_CODE ("TONGA", TO, TON, 776)
DEFINE_COUNTRY_CODE ("TRINIDAD AND TOBAGO", TT, TTO, 780)
DEFINE_COUNTRY_CODE ("TUNISIA", TN, TUN, 788)
DEFINE_COUNTRY_CODE ("TURKEY", TR, TUR, 792)
DEFINE_COUNTRY_CODE ("TURKMENISTAN", TM, TKM, 795)
DEFINE_COUNTRY_CODE ("TURKS AND CAICOS ISLANDS", TC, TCA, 796)
DEFINE_COUNTRY_CODE ("TUVALU", TV, TUV, 798)
DEFINE_COUNTRY_CODE ("UGANDA", UG, UGA, 800)
DEFINE_COUNTRY_CODE ("UKRAINE", UA, UKR, 804)
DEFINE_COUNTRY_CODE ("UNITED ARAB EMIRATES", AE, ARE, 784)
DEFINE_COUNTRY_CODE ("UNITED KINGDOM", GB, GBR, 826)
DEFINE_COUNTRY_CODE ("UNITED STATES", US, USA, 840)
DEFINE_COUNTRY_CODE ("UNITED STATES MINOR OUTLYING ISLANDS", UM, UMI, 581)
DEFINE_COUNTRY_CODE ("URUGUAY", UY, URY, 858)
DEFINE_COUNTRY_CODE ("UZBEKISTAN", UZ, UZB, 860)
DEFINE_COUNTRY_CODE ("VANUATU", VU, VUT, 548)
DEFINE_COUNTRY_CODE ("VENEZUELA", VE, VEN, 862)
DEFINE_COUNTRY_CODE ("VIET NAM", VN, VNM, 704)
DEFINE_COUNTRY_CODE ("VIRGIN ISLANDS (BRITISH)", VG, VGB, 92)
DEFINE_COUNTRY_CODE ("VIRGIN ISLANDS (U.S.)", VI, VIR, 850)
DEFINE_COUNTRY_CODE ("WALLIS AND FUTUNA ISLANDS", WF, WLF, 876)
DEFINE_COUNTRY_CODE ("WESTERN SAHARA", EH, ESH, 732)
DEFINE_COUNTRY_CODE ("YEMEN", YE, YEM, 887)
DEFINE_COUNTRY_CODE ("YUGOSLAVIA", YU, YUG, 891)
DEFINE_COUNTRY_CODE ("ZAMBIA", ZM, ZMB, 894)
DEFINE_COUNTRY_CODE ("ZIMBABWE", ZW, ZWE, 716)

133
locale/iso-639.def Normal file
View File

@ -0,0 +1,133 @@
/*
* Defines the languages codes and abbreviations according to ISO 639-[12].
* This is used in ld-address.c (address_finish).
*
* If you find something missing or wrong contact <bug-glibc@gnu.org>
*/
DEFINE_LANGUAGE_CODE ("Afar", aa, aar, aar)
DEFINE_LANGUAGE_CODE ("Abkhazian", ab, abk, abk)
DEFINE_LANGUAGE_CODE ("Afrikaans", af, afr, afr)
DEFINE_LANGUAGE_CODE ("Amharic", am, amh, amh)
DEFINE_LANGUAGE_CODE ("Arabian", ar, ara, ara)
DEFINE_LANGUAGE_CODE ("Assamese", as, asm, asm)
DEFINE_LANGUAGE_CODE ("Aymara", ay, aym, aym)
DEFINE_LANGUAGE_CODE ("Azerbajani", az, aze, aze)
DEFINE_LANGUAGE_CODE ("Bashkir", ba, bak, bak)
DEFINE_LANGUAGE_CODE ("Byelorussian", be, bel, bel)
DEFINE_LANGUAGE_CODE ("Bulgarian", bg, bul, bul)
DEFINE_LANGUAGE_CODE ("Bihari", bh, bih, bih)
DEFINE_LANGUAGE_CODE ("Bislama", bi, bis, bis)
DEFINE_LANGUAGE_CODE ("Bengali", bn, ben, ben)
DEFINE_LANGUAGE_CODE ("Tibetan", bo, bod, tib)
DEFINE_LANGUAGE_CODE ("Breton", br, bre, bre)
DEFINE_LANGUAGE_CODE ("Catalan", ca, cat, cat)
DEFINE_LANGUAGE_CODE ("Corsican", co, cos, cos)
DEFINE_LANGUAGE_CODE ("Czech", cs, ces, cze)
DEFINE_LANGUAGE_CODE ("Welsh", cy, cym, wel)
DEFINE_LANGUAGE_CODE ("Danish", da, dan, dan)
DEFINE_LANGUAGE_CODE ("German", de, deu, ger)
DEFINE_LANGUAGE_CODE ("Greek", el, ell, gre)
DEFINE_LANGUAGE_CODE ("English", en, eng, eng)
DEFINE_LANGUAGE_CODE ("Esperanto", eo, epo, epo)
DEFINE_LANGUAGE_CODE ("Spanish", es, spa, spa)
DEFINE_LANGUAGE_CODE ("Estonian", et, est, est)
DEFINE_LANGUAGE_CODE ("Basque", eu, eus, baq)
DEFINE_LANGUAGE_CODE ("Persian", fa, fas, per)
DEFINE_LANGUAGE_CODE ("Finnish", fi, fin, fin)
DEFINE_LANGUAGE_CODE ("Fiji", fj, fij, fij)
DEFINE_LANGUAGE_CODE ("Faroese", fo, fao, fao)
DEFINE_LANGUAGE_CODE ("French", fr, fra, fre)
DEFINE_LANGUAGE_CODE ("Frisian", fy, fry, fry)
DEFINE_LANGUAGE_CODE ("Irish", ga, gai, iri)
DEFINE_LANGUAGE_CODE ("Scots Gaelic", gd, gdh, gae)
DEFINE_LANGUAGE_CODE ("Guarani", gn, grn, grn)
DEFINE_LANGUAGE_CODE ("Gujarati", gu, guj, guj)
DEFINE_LANGUAGE_CODE ("Hausa", ha, hau, hau)
DEFINE_LANGUAGE_CODE ("Hindi", hi, hin, hin)
DEFINE_LANGUAGE_CODE ("Croatian", hr, hrv, scr)
DEFINE_LANGUAGE_CODE ("Hungarian", hu, hun, hun)
DEFINE_LANGUAGE_CODE ("Armenian", hy, hye, arm)
DEFINE_LANGUAGE_CODE ("Interlingua", ia, ina, ina)
DEFINE_LANGUAGE_CODE ("Interlingue", ie, ile, ile)
DEFINE_LANGUAGE_CODE ("Inupiak", ik, ipk, ipk)
DEFINE_LANGUAGE_CODE ("Indonesian", in, ind, ind)
DEFINE_LANGUAGE_CODE ("Icelandic", is, isl, ice)
DEFINE_LANGUAGE_CODE ("Italian", it, ita, ita)
DEFINE_LANGUAGE_CODE ("Hebrew", iw, heb, heb)
DEFINE_LANGUAGE_CODE ("Japanese", ja, jpn, jpn)
DEFINE_LANGUAGE_CODE ("Yiddish", ji, yid, yid)
DEFINE_LANGUAGE_CODE ("Javanese", jv, jaw, jav)
DEFINE_LANGUAGE_CODE ("Georgian", ka, kat, geo)
DEFINE_LANGUAGE_CODE ("Kazakh", kk, kaz, kaz)
DEFINE_LANGUAGE_CODE ("Kannada", kn, kan, kan)
DEFINE_LANGUAGE_CODE ("Korean", ko, kor, kor)
DEFINE_LANGUAGE_CODE ("Kashmiri", ks, kas, kas)
DEFINE_LANGUAGE_CODE ("Kurdish", ku, kur, kur)
DEFINE_LANGUAGE_CODE ("Kirghiz", ky, kir, kir)
DEFINE_LANGUAGE_CODE ("Latin", la, lat, lat)
DEFINE_LANGUAGE_CODE ("Lingala", ln, lin, lin)
DEFINE_LANGUAGE_CODE ("Laotian", lo, lao, lao)
DEFINE_LANGUAGE_CODE ("Lithuanian", lt, lit, lit)
DEFINE_LANGUAGE_CODE ("Latvian, Lettish", lv, lav, lav)
DEFINE_LANGUAGE_CODE ("Malagasy", mg, mlg, mlg)
DEFINE_LANGUAGE_CODE ("Maori", mi, mri, mao)
DEFINE_LANGUAGE_CODE ("Macedonian", mk, mkd, mac)
DEFINE_LANGUAGE_CODE ("Malayalam", ml, mal, mal)
DEFINE_LANGUAGE_CODE ("Mongolian", mn, mon, mon)
DEFINE_LANGUAGE_CODE ("Moldavian", mo, mol, mol)
DEFINE_LANGUAGE_CODE ("Marathi", mr, mar, mar)
DEFINE_LANGUAGE_CODE ("Malay", ms, msa, may)
DEFINE_LANGUAGE_CODE ("Maltese", mt, mlt, mlt)
DEFINE_LANGUAGE_CODE ("Burmese", my, mya, bur)
DEFINE_LANGUAGE_CODE ("Nauru", na, nau, nau)
DEFINE_LANGUAGE_CODE ("Nepali", ne, nep, nep)
DEFINE_LANGUAGE_CODE ("Dutch", nl, nld, dut)
DEFINE_LANGUAGE_CODE ("Norwegian", no, nor, nor)
DEFINE_LANGUAGE_CODE ("Occitan", oc, oci, oci)
DEFINE_LANGUAGE_CODE ("(Afan)Oromo", om, orm, orm)
DEFINE_LANGUAGE_CODE ("Oriya", or, ori, ori)
DEFINE_LANGUAGE_CODE ("Polish", pl, pol, pol)
DEFINE_LANGUAGE_CODE ("Pashto, Pushto", ps, pus, pus)
DEFINE_LANGUAGE_CODE ("Portuguese", pt, por, por)
DEFINE_LANGUAGE_CODE ("Quechua", qu, que, que)
DEFINE_LANGUAGE_CODE ("Rhaeto-Romance", rm, roh, roh)
DEFINE_LANGUAGE_CODE ("Romanian", ro, rom, rom)
DEFINE_LANGUAGE_CODE ("Russian", ru, rus, rus)
DEFINE_LANGUAGE_CODE ("Kinyarwanda", rw, kin, kin)
DEFINE_LANGUAGE_CODE ("Sanskrit", sa, san, san)
DEFINE_LANGUAGE_CODE ("Sindhi", sd, snd, snd)
DEFINE_LANGUAGE_CODE ("Sangho", sg, sag, sag)
DEFINE_LANGUAGE_CODE ("Singhalese", si, sin, sin)
DEFINE_LANGUAGE_CODE ("Slovak", sk, slk, slo)
DEFINE_LANGUAGE_CODE ("Slovenian", sl, slv, slv)
DEFINE_LANGUAGE_CODE ("Samoan", sm, smo, smo)
DEFINE_LANGUAGE_CODE ("Shona", sn, sna, sna)
DEFINE_LANGUAGE_CODE ("Somali", so, som, som)
DEFINE_LANGUAGE_CODE ("Albanian", sq, sqi, alb)
DEFINE_LANGUAGE_CODE ("Serbian", sr, srq, scc)
DEFINE_LANGUAGE_CODE ("Siswati", ss, ssw, ssw)
DEFINE_LANGUAGE_CODE ("Sudanese", su, sun, sun)
DEFINE_LANGUAGE_CODE ("Swedish", sv, swe, swe)
DEFINE_LANGUAGE_CODE ("Suahili", sw, swa, swa)
DEFINE_LANGUAGE_CODE ("Tamil", ta, tam, tam)
DEFINE_LANGUAGE_CODE ("Telugu", te, tel, tel)
DEFINE_LANGUAGE_CODE ("Tajik", tg, tgk, tgk)
DEFINE_LANGUAGE_CODE ("Thai", th, tha, tha)
DEFINE_LANGUAGE_CODE ("Tigrinya", ti, tir, tir)
DEFINE_LANGUAGE_CODE ("Turkmen", tk, tuk, tuk)
DEFINE_LANGUAGE_CODE ("Tagalog", tl, tgl, tgl)
DEFINE_LANGUAGE_CODE ("Tonga", to, ton, ton)
DEFINE_LANGUAGE_CODE ("Turkish", tr, tur, tur)
DEFINE_LANGUAGE_CODE ("Tsonga", ts, tso, tso)
DEFINE_LANGUAGE_CODE ("Tatar", tt, tat, tat)
DEFINE_LANGUAGE_CODE ("Twi", tw, twi, twi)
DEFINE_LANGUAGE_CODE ("Ukrainian", uk, ukr, ukr)
DEFINE_LANGUAGE_CODE ("Urdu", ur, urd, urd)
DEFINE_LANGUAGE_CODE ("Uzbek", uz, uzb, uzb)
DEFINE_LANGUAGE_CODE ("Vietnamese", vi, vie, vie)
DEFINE_LANGUAGE_CODE ("Volapük", vo, vol, vol)
DEFINE_LANGUAGE_CODE ("Wolof", wo, wol, wol)
DEFINE_LANGUAGE_CODE ("Xhosa", xh, xho, xho)
DEFINE_LANGUAGE_CODE ("Yoruba", yo, yor, yor)
DEFINE_LANGUAGE_CODE ("Chinese", zh, zho, chi)
DEFINE_LANGUAGE_CODE ("Zulu", zu, zul, zul)

View File

@ -155,71 +155,126 @@ enum
ERA_T_FMT, /* Time in alternate era format. */
#define ERA_T_FMT ERA_T_FMT
_NL_TIME_NUM_ALT_DIGITS, /* Number entries in the alt_digits arrays. */
_NL_TIME_ERA_NUM_ENTRIES, /* Number entries in the era arrays. */
_NL_TIME_ERA_NUM_ENTRIES_EB, /* Number entries in the era arrays. */
_NL_TIME_ERA_NUM_ENTRIES_EL, /* Number entries in the era arrays. */
_NL_TIME_ERA_ENTRIES_EB, /* Structure with era entries in usable form.*/
_NL_TIME_ERA_ENTRIES_EL,
_NL_WABDAY_1, /* Sun */
_NL_WABDAY_2,
_NL_WABDAY_3,
_NL_WABDAY_4,
_NL_WABDAY_5,
_NL_WABDAY_6,
_NL_WABDAY_7,
_NL_WABDAY_1_EB, /* Sun */
_NL_WABDAY_2_EB,
_NL_WABDAY_3_EB,
_NL_WABDAY_4_EB,
_NL_WABDAY_5_EB,
_NL_WABDAY_6_EB,
_NL_WABDAY_7_EB,
_NL_WABDAY_1_EL, /* Sun */
_NL_WABDAY_2_EL,
_NL_WABDAY_3_EL,
_NL_WABDAY_4_EL,
_NL_WABDAY_5_EL,
_NL_WABDAY_6_EL,
_NL_WABDAY_7_EL,
/* Long-named days of the week. */
_NL_WDAY_1, /* Sunday */
_NL_WDAY_2, /* Monday */
_NL_WDAY_3, /* Tuesday */
_NL_WDAY_4, /* Wednesday */
_NL_WDAY_5, /* Thursday */
_NL_WDAY_6, /* Friday */
_NL_WDAY_7, /* Saturday */
_NL_WDAY_1_EB, /* Sunday */
_NL_WDAY_2_EB, /* Monday */
_NL_WDAY_3_EB, /* Tuesday */
_NL_WDAY_4_EB, /* Wednesday */
_NL_WDAY_5_EB, /* Thursday */
_NL_WDAY_6_EB, /* Friday */
_NL_WDAY_7_EB, /* Saturday */
_NL_WDAY_1_EL, /* Sunday */
_NL_WDAY_2_EL, /* Monday */
_NL_WDAY_3_EL, /* Tuesday */
_NL_WDAY_4_EL, /* Wednesday */
_NL_WDAY_5_EL, /* Thursday */
_NL_WDAY_6_EL, /* Friday */
_NL_WDAY_7_EL, /* Saturday */
/* Abbreviated month names. */
_NL_WABMON_1, /* Jan */
_NL_WABMON_2,
_NL_WABMON_3,
_NL_WABMON_4,
_NL_WABMON_5,
_NL_WABMON_6,
_NL_WABMON_7,
_NL_WABMON_8,
_NL_WABMON_9,
_NL_WABMON_10,
_NL_WABMON_11,
_NL_WABMON_12,
_NL_WABMON_1_EB, /* Jan */
_NL_WABMON_2_EB,
_NL_WABMON_3_EB,
_NL_WABMON_4_EB,
_NL_WABMON_5_EB,
_NL_WABMON_6_EB,
_NL_WABMON_7_EB,
_NL_WABMON_8_EB,
_NL_WABMON_9_EB,
_NL_WABMON_10_EB,
_NL_WABMON_11_EB,
_NL_WABMON_12_EB,
_NL_WABMON_1_EL, /* Jan */
_NL_WABMON_2_EL,
_NL_WABMON_3_EL,
_NL_WABMON_4_EL,
_NL_WABMON_5_EL,
_NL_WABMON_6_EL,
_NL_WABMON_7_EL,
_NL_WABMON_8_EL,
_NL_WABMON_9_EL,
_NL_WABMON_10_EL,
_NL_WABMON_11_EL,
_NL_WABMON_12_EL,
/* Long month names. */
_NL_WMON_1, /* January */
_NL_WMON_2,
_NL_WMON_3,
_NL_WMON_4,
_NL_WMON_5,
_NL_WMON_6,
_NL_WMON_7,
_NL_WMON_8,
_NL_WMON_9,
_NL_WMON_10,
_NL_WMON_11,
_NL_WMON_12,
_NL_WMON_1_EB, /* January */
_NL_WMON_2_EB,
_NL_WMON_3_EB,
_NL_WMON_4_EB,
_NL_WMON_5_EB,
_NL_WMON_6_EB,
_NL_WMON_7_EB,
_NL_WMON_8_EB,
_NL_WMON_9_EB,
_NL_WMON_10_EB,
_NL_WMON_11_EB,
_NL_WMON_12_EB,
_NL_WMON_1_EL, /* January */
_NL_WMON_2_EL,
_NL_WMON_3_EL,
_NL_WMON_4_EL,
_NL_WMON_5_EL,
_NL_WMON_6_EL,
_NL_WMON_7_EL,
_NL_WMON_8_EL,
_NL_WMON_9_EL,
_NL_WMON_10_EL,
_NL_WMON_11_EL,
_NL_WMON_12_EL,
_NL_WAM_STR, /* Ante meridian string. */
_NL_WPM_STR, /* Post meridian string. */
_NL_WAM_STR_EB, /* Ante meridian string. */
_NL_WPM_STR_EB, /* Post meridian string. */
_NL_WAM_STR_EL, /* Ante meridian string. */
_NL_WPM_STR_EL, /* Post meridian string. */
_NL_WD_T_FMT, /* Date and time format for strftime. */
_NL_WD_FMT, /* Date format for strftime. */
_NL_WT_FMT, /* Time format for strftime. */
_NL_WT_FMT_AMPM, /* 12-hour time format for strftime. */
_NL_WD_T_FMT_EB, /* Date and time format for strftime. */
_NL_WD_FMT_EB, /* Date format for strftime. */
_NL_WT_FMT_EB, /* Time format for strftime. */
_NL_WT_FMT_AMPM_EB, /* 12-hour time format for strftime. */
_NL_WD_T_FMT_EL, /* Date and time format for strftime. */
_NL_WD_FMT_EL, /* Date format for strftime. */
_NL_WT_FMT_EL, /* Time format for strftime. */
_NL_WT_FMT_AMPM_EL, /* 12-hour time format for strftime. */
_NL_WERA, /* Alternate era. */
_NL_WERA_YEAR, /* Year in alternate era format. */
_NL_WERA_D_FMT, /* Date in alternate era format. */
_NL_WALT_DIGITS, /* Alternate symbols for digits. */
_NL_WERA_D_T_FMT, /* Date and time in alternate era format. */
_NL_WERA_T_FMT, /* Time in alternate era format. */
_NL_WERA_YEAR_EB, /* Year in alternate era format. */
_NL_WERA_D_FMT_EB, /* Date in alternate era format. */
_NL_WALT_DIGITS_EB, /* Alternate symbols for digits. */
_NL_WERA_D_T_FMT_EB, /* Date and time in alternate era format. */
_NL_WERA_T_FMT_EB, /* Time in alternate era format. */
_NL_WERA_YEAR_EL, /* Year in alternate era format. */
_NL_WERA_D_FMT_EL, /* Date in alternate era format. */
_NL_WALT_DIGITS_EL, /* Alternate symbols for digits. */
_NL_WERA_D_T_FMT_EL, /* Date and time in alternate era format. */
_NL_WERA_T_FMT_EL, /* Time in alternate era format. */
_NL_TIME_WEEK_NDAYS,
_NL_TIME_WEEK_1STDAY,
_NL_TIME_WEEK_1STWEEK,
_NL_TIME_FIRST_WEEKDAY,
_NL_TIME_FIRST_WORKDAY,
_NL_TIME_CAL_DIRECTION,
_NL_TIME_TIMEZONE,
_NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */
@ -230,23 +285,34 @@ enum
_NL_COLLATE_RULES,
_NL_COLLATE_HASH_SIZE,
_NL_COLLATE_HASH_LAYERS,
_NL_COLLATE_TABLE_EB,
_NL_COLLATE_TABLE_EL,
_NL_COLLATE_UNDEFINED,
_NL_COLLATE_EXTRA_EB,
_NL_COLLATE_EXTRA_EL,
_NL_COLLATE_TABLEMB_EB,
_NL_COLLATE_TABLEMB_EL,
_NL_COLLATE_TABLEWC_EB,
_NL_COLLATE_TABLEWC_EL,
_NL_COLLATE_UNDEFINED_MB,
_NL_COLLATE_UNDEFINED_WC,
_NL_COLLATE_EXTRAMB_EB,
_NL_COLLATE_EXTRAMB_EL,
_NL_COLLATE_EXTRAWC_EB,
_NL_COLLATE_EXTRAWC_EL,
_NL_COLLATE_ELEM_HASH_SIZE,
_NL_COLLATE_ELEM_HASH_EB,
_NL_COLLATE_ELEM_HASH_EL,
_NL_COLLATE_ELEM_STR_POOL,
_NL_COLLATE_ELEM_VAL_EB,
_NL_COLLATE_ELEM_VAL_EL,
_NL_COLLATE_ELEM_VALMB_EB,
_NL_COLLATE_ELEM_VALMB_EL,
_NL_COLLATE_ELEM_VALWC_EB,
_NL_COLLATE_ELEM_VALWC_EL,
_NL_COLLATE_SYMB_HASH_SIZE,
_NL_COLLATE_SYMB_HASH_EB,
_NL_COLLATE_SYMB_HASH_EL,
_NL_COLLATE_SYMB_STR_POOL,
_NL_COLLATE_SYMB_CLASS_EB,
_NL_COLLATE_SYMB_CLASS_EL,
_NL_COLLATE_SYMB_CLASSMB_EB,
_NL_COLLATE_SYMB_CLASSMB_EL,
_NL_COLLATE_SYMB_CLASSWC_EB,
_NL_COLLATE_SYMB_CLASSWC_EL,
_NL_NUM_LC_COLLATE,
/* LC_CTYPE category: character classification.
@ -260,8 +326,8 @@ enum
_NL_CTYPE_CLASS32,
_NL_CTYPE_NAMES_EB,
_NL_CTYPE_NAMES_EL,
_NL_CTYPE_HASH_SIZE,
_NL_CTYPE_HASH_LAYERS,
_NL_CTYPE_HASH_SIZE_EB,
_NL_CTYPE_HASH_LAYERS_EB,
_NL_CTYPE_CLASS_NAMES,
_NL_CTYPE_MAP_NAMES,
_NL_CTYPE_WIDTH,
@ -270,6 +336,84 @@ enum
#ifdef __USE_XOPEN
CODESET = _NL_CTYPE_CODESET_NAME,
#endif
_NL_CTYPE_HASH_SIZE_EL,
_NL_CTYPE_HASH_LAYERS_EL,
_NL_CTYPE_INDIGITS_MB_LEN_EB,
_NL_CTYPE_INDIGITS_MB_LEN_EL,
_NL_CTYPE_INDIGITS0_MB,
_NL_CTYPE_INDIGITS1_MB,
_NL_CTYPE_INDIGITS2_MB,
_NL_CTYPE_INDIGITS3_MB,
_NL_CTYPE_INDIGITS4_MB,
_NL_CTYPE_INDIGITS5_MB,
_NL_CTYPE_INDIGITS6_MB,
_NL_CTYPE_INDIGITS7_MB,
_NL_CTYPE_INDIGITS8_MB,
_NL_CTYPE_INDIGITS9_MB,
_NL_CTYPE_INDIGITS_WC_LEN_EB,
_NL_CTYPE_INDIGITS_WC_LEN_EL,
_NL_CTYPE_INDIGITS0_WC_EB,
_NL_CTYPE_INDIGITS1_WC_EB,
_NL_CTYPE_INDIGITS2_WC_EB,
_NL_CTYPE_INDIGITS3_WC_EB,
_NL_CTYPE_INDIGITS4_WC_EB,
_NL_CTYPE_INDIGITS5_WC_EB,
_NL_CTYPE_INDIGITS6_WC_EB,
_NL_CTYPE_INDIGITS7_WC_EB,
_NL_CTYPE_INDIGITS8_WC_EB,
_NL_CTYPE_INDIGITS9_WC_EB,
_NL_CTYPE_INDIGITS0_WC_EL,
_NL_CTYPE_INDIGITS1_WC_EL,
_NL_CTYPE_INDIGITS2_WC_EL,
_NL_CTYPE_INDIGITS3_WC_EL,
_NL_CTYPE_INDIGITS4_WC_EL,
_NL_CTYPE_INDIGITS5_WC_EL,
_NL_CTYPE_INDIGITS6_WC_EL,
_NL_CTYPE_INDIGITS7_WC_EL,
_NL_CTYPE_INDIGITS8_WC_EL,
_NL_CTYPE_INDIGITS9_WC_EL,
_NL_CTYPE_OUTDIGIT0_MB,
_NL_CTYPE_OUTDIGIT1_MB,
_NL_CTYPE_OUTDIGIT2_MB,
_NL_CTYPE_OUTDIGIT3_MB,
_NL_CTYPE_OUTDIGIT4_MB,
_NL_CTYPE_OUTDIGIT5_MB,
_NL_CTYPE_OUTDIGIT6_MB,
_NL_CTYPE_OUTDIGIT7_MB,
_NL_CTYPE_OUTDIGIT8_MB,
_NL_CTYPE_OUTDIGIT9_MB,
_NL_CTYPE_OUTDIGIT0_WC_EB,
_NL_CTYPE_OUTDIGIT1_WC_EB,
_NL_CTYPE_OUTDIGIT2_WC_EB,
_NL_CTYPE_OUTDIGIT3_WC_EB,
_NL_CTYPE_OUTDIGIT4_WC_EB,
_NL_CTYPE_OUTDIGIT5_WC_EB,
_NL_CTYPE_OUTDIGIT6_WC_EB,
_NL_CTYPE_OUTDIGIT7_WC_EB,
_NL_CTYPE_OUTDIGIT8_WC_EB,
_NL_CTYPE_OUTDIGIT9_WC_EB,
_NL_CTYPE_OUTDIGIT0_WC_EL,
_NL_CTYPE_OUTDIGIT1_WC_EL,
_NL_CTYPE_OUTDIGIT2_WC_EL,
_NL_CTYPE_OUTDIGIT3_WC_EL,
_NL_CTYPE_OUTDIGIT4_WC_EL,
_NL_CTYPE_OUTDIGIT5_WC_EL,
_NL_CTYPE_OUTDIGIT6_WC_EL,
_NL_CTYPE_OUTDIGIT7_WC_EL,
_NL_CTYPE_OUTDIGIT8_WC_EL,
_NL_CTYPE_OUTDIGIT9_WC_EL,
_NL_CTYPE_TRANSLIT_HASH_SIZE_EB,
_NL_CTYPE_TRANSLIT_HASH_SIZE_EL,
_NL_CTYPE_TRANSLIT_HASH_LAYERS_EB,
_NL_CTYPE_TRANSLIT_HASH_LAYERS_EL,
_NL_CTYPE_TRANSLIT_FROM_IDX_EB,
_NL_CTYPE_TRANSLIT_FROM_IDX_EL,
_NL_CTYPE_TRANSLIT_FROM_TBL_EB,
_NL_CTYPE_TRANSLIT_FROM_TBL_EL,
_NL_CTYPE_TRANSLIT_TO_IDX_EB,
_NL_CTYPE_TRANSLIT_TO_IDX_EL,
_NL_CTYPE_TRANSLIT_TO_TBL_EB,
_NL_CTYPE_TRANSLIT_TO_TBL_EL,
_NL_NUM_LC_CTYPE,
/* LC_MONETARY category: formatting of monetary quantities.
@ -281,7 +425,7 @@ enum
#define CURRENCY_SYMBOL CURRENCY_SYMBOL
#ifdef __USE_XOPEN
CRNCYSTR = CURRENCY_SYMBOL,
# define CRNCYSTR CRNCYSTR
# define CRNCYSTR CRNCYSTR
#endif
MON_DECIMAL_POINT,
#define MON_DECIMAL_POINT MON_DECIMAL_POINT
@ -309,6 +453,34 @@ enum
#define P_SIGN_POSN P_SIGN_POSN
N_SIGN_POSN,
#define N_SIGN_POSN N_SIGN_POSN
_NL_MONETARY_INT_P_CS_PRECEDES,
_NL_MONETARY_INT_P_SEP_BY_SPACE,
_NL_MONETARY_INT_N_CS_PRECEDES,
_NL_MONETARY_INT_N_SEP_BY_SPACE,
_NL_MONETARY_INT_P_SIGN_POSN,
_NL_MONETARY_INT_N_SIGN_POSN,
_NL_MONETARY_DUO_INT_CURR_SYMBOL,
_NL_MONETARY_DUO_CURRENCY_SYMBOL,
_NL_MONETARY_DUO_INT_FRAC_DIGITS,
_NL_MONETARY_DUO_FRAC_DIGITS,
_NL_MONETARY_DUO_P_CS_PRECEDES,
_NL_MONETARY_DUO_P_SEP_BY_SPACE,
_NL_MONETARY_DUO_N_CS_PRECEDES,
_NL_MONETARY_DUO_N_SEP_BY_SPACE,
_NL_MONETARY_DUO_INT_P_CS_PRECEDES,
_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE,
_NL_MONETARY_DUO_INT_N_CS_PRECEDES,
_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE,
_NL_MONETARY_DUO_P_SIGN_POSN,
_NL_MONETARY_DUO_N_SIGN_POSN,
_NL_MONETARY_DUO_INT_P_SIGN_POSN,
_NL_MONETARY_DUO_INT_N_SIGN_POSN,
_NL_MONETARY_UNO_VALID_FROM,
_NL_MONETARY_UNO_VALID_TO,
_NL_MONETARY_DUO_VALID_FROM,
_NL_MONETARY_DUO_VALID_TO,
_NL_MONETARY_CONVERSION_RATE_EB,
_NL_MONETARY_CONVERSION_RATE_EL,
_NL_NUM_LC_MONETARY,
/* LC_NUMERIC category: formatting of numbers.
@ -323,7 +495,7 @@ enum
#define THOUSANDS_SEP THOUSANDS_SEP
#ifdef __USE_XOPEN
THOUSEP = THOUSANDS_SEP,
#define THOUSEP THOUSEP
# define THOUSANDS_SEP THOUSANDS_SEP
#endif
GROUPING,
#define GROUPING GROUPING
@ -333,14 +505,67 @@ enum
#define YESEXPR YESEXPR
NOEXPR, /* Regex matching ``no'' input. */
#define NOEXPR NOEXPR
__YESSTR, /* Output string for ``yes''. */
__NOSTR, /* Output string for ``no''. */
#if !defined __USE_XOPEN2K || defined __USE_GNU
# define YESSTR __YESSTR
# define NOSTR __NOSTR
#endif
YESSTR, /* Output string for ``yes''. */
#define YESSTR YESSTR
NOSTR, /* Output string for ``no''. */
#define NOSTR NOSTR
_NL_NUM_LC_MESSAGES,
_NL_PAPER_HEIGHT_EB = _NL_ITEM (LC_PAPER, 0),
_NL_PAPER_HEIGHT_EL,
_NL_PAPER_WIDTH_EB,
_NL_PAPER_WIDTH_EL,
_NL_NUM_LC_PAPER,
_NL_NAME_NAME_FMT = _NL_ITEM (LC_NAME, 0),
_NL_NAME_NAME_GEN,
_NL_NAME_NAME_MR,
_NL_NAME_NAME_MRS,
_NL_NAME_NAME_MISS,
_NL_NAME_NAME_MS,
_NL_NUM_LC_NAME,
_NL_ADDRESS_POSTAL_FMT = _NL_ITEM (LC_ADDRESS, 0),
_NL_ADDRESS_COUNTRY_NAME,
_NL_ADDRESS_COUNTRY_POST,
_NL_ADDRESS_COUNTRY_AB2,
_NL_ADDRESS_COUNTRY_AB3,
_NL_ADDRESS_COUNTRY_CAR,
_NL_ADDRESS_COUNTRY_NUM_EB,
_NL_ADDRESS_COUNTRY_NUM_EL,
_NL_ADDRESS_COUNTRY_ISBN,
_NL_ADDRESS_LANG_NAME,
_NL_ADDRESS_LANG_AB,
_NL_ADDRESS_LANG_TERM,
_NL_ADDRESS_LANG_LIB,
_NL_NUM_LC_ADDRESS,
_NL_TELEPHONE_TEL_INT_FMT = _NL_ITEM (LC_TELEPHONE, 0),
_NL_TELEPHONE_TEL_DOM_FMT,
_NL_TELEPHONE_INT_SELECT,
_NL_TELEPHONE_INT_PREFIX,
_NL_NUM_LC_TELEPHONE,
_NL_MEASUREMENT_MEASUREMENT = _NL_ITEM (LC_MEASUREMENT, 0),
_NL_NUM_LC_MEASUREMENT,
_NL_IDENTIFICATION_TITLE = _NL_ITEM (LC_IDENTIFICATION, 0),
_NL_IDENTIFICATION_SOURCE,
_NL_IDENTIFICATION_ADDRESS,
_NL_IDENTIFICATION_CONTACT,
_NL_IDENTIFICATION_EMAIL,
_NL_IDENTIFICATION_TEL,
_NL_IDENTIFICATION_FAX,
_NL_IDENTIFICATION_LANGUAGE,
_NL_IDENTIFICATION_TERRITORY,
_NL_IDENTIFICATION_AUDIENCE,
_NL_IDENTIFICATION_APPLICATION,
_NL_IDENTIFICATION_ABBREVIATION,
_NL_IDENTIFICATION_REVISION,
_NL_IDENTIFICATION_DATE,
_NL_IDENTIFICATION_CATEGORY,
_NL_NUM_LC_IDENTIFICATION,
/* This marks the highest value used. */
_NL_NUM
};

22
locale/lc-address.c Normal file
View File

@ -0,0 +1,22 @@
/* Define current locale data for LC_ADDRESS category.
Copyright (C) 1998 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. */
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_ADDRESS);

View File

@ -1,5 +1,5 @@
/* Define current locale data for LC_COLLATE category.
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999 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
@ -28,16 +28,16 @@ extern const u_int32_t _nl_C_LC_COLLATE_symbol_classes[];
_NL_CURRENT_DEFINE (LC_COLLATE);
const u_int32_t *__collate_table;
const u_int32_t *__collate_extra;
const u_int32_t *__collate_tablewc;
const u_int32_t *__collate_extrawc;
const u_int32_t *__collate_element_hash;
const char *__collate_element_strings;
const wchar_t *__collate_element_values;
const uint32_t *__collate_element_values;
const u_int32_t *__collate_symbol_hash = _nl_C_LC_COLLATE_symbol_hash;
const char *__collate_symbol_strings = _nl_C_LC_COLLATE_symbol_strings;
const u_int32_t *__collate_symbol_classes = _nl_C_LC_COLLATE_symbol_classes;
const u_int32_t *__collate_symbol_classeswc = _nl_C_LC_COLLATE_symbol_classes;
/* We are called after loading LC_CTYPE data to load it into
@ -58,14 +58,14 @@ _nl_postload_collate (void)
#define current(x) \
((const unsigned int *) _NL_CURRENT (LC_COLLATE, paste(_NL_COLLATE_,x)))
__collate_table = current (bo (TABLE));
__collate_extra = current (bo (EXTRA));
__collate_tablewc = current (bo (TABLEWC));
__collate_extrawc = current (bo (EXTRAWC));
__collate_element_hash = current (bo (ELEM_HASH));
__collate_element_strings = (const char *) current (ELEM_STR_POOL);
__collate_element_values = (const wchar_t *) current (bo (ELEM_VAL));
__collate_element_values = (const uint32_t *) current (bo (ELEM_VAL));
__collate_symbol_hash = current (bo (SYMB_HASH));
__collate_symbol_strings = (const char *) current (SYMB_STR_POOL);
__collate_symbol_classes = current (bo (SYMB_CLASS));
__collate_symbol_classeswc = current (bo (SYMB_CLASSWC));
}

View File

@ -1,5 +1,5 @@
/* Define current locale data for LC_CTYPE category.
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998 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
@ -20,6 +20,7 @@
#include "localeinfo.h"
#include <ctype.h>
#include <endian.h>
#include <stdint.h>
_NL_CURRENT_DEFINE (LC_CTYPE);
@ -46,14 +47,14 @@ _nl_postload_ctype (void)
#define current(type,x,offset) \
((const type *) _NL_CURRENT (LC_CTYPE, paste(_NL_CTYPE_,x)) + offset)
extern const unsigned int *__ctype32_b;
extern const unsigned int *__ctype_names;
extern const uint32_t *__ctype32_b;
extern const uint32_t *__ctype_names;
extern const unsigned char *__ctype_width;
__ctype_b = current (unsigned short int, CLASS, 128);
__ctype_toupper = current (int, bo (TOUPPER), 128);
__ctype_tolower = current (int, bo (TOLOWER), 128);
__ctype32_b = current (unsigned int, CLASS32, 0);
__ctype_names = current (unsigned int, bo (NAMES), 0);
__ctype_b = current (uint16_t, CLASS, 128);
__ctype_toupper = current (uint32_t, bo (TOUPPER), 128);
__ctype_tolower = current (uint32_t, bo (TOLOWER), 128);
__ctype32_b = current (uint32_t, CLASS32, 0);
__ctype_names = current (uint32_t, bo (NAMES), 0);
__ctype_width = current (unsigned char, WIDTH, 0);
}

View File

@ -0,0 +1,22 @@
/* Define current locale data for LC_IDENTIFICATION category.
Copyright (C) 1998, 1999 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. */
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_IDENTIFICATION);

22
locale/lc-measurement.c Normal file
View File

@ -0,0 +1,22 @@
/* Define current locale data for LC_MEASUREMENT category.
Copyright (C) 1998 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. */
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_MEASUREMENT);

View File

@ -1,5 +1,5 @@
/* Define current locale data for LC_MONETARY category.
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
Copyright (C) 1995, 1997, 1998 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
@ -20,3 +20,24 @@
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_MONETARY);
const uint32_t *__monetary_conversion_rate;
void
_nl_postload_monetary (void)
{
#if BYTE_ORDER == BIG_ENDIAN
#define bo(x) x##_EB
#elif BYTE_ORDER == LITTLE_ENDIAN
#define bo(x) x##_EL
#else
#error bizarre byte order
#endif
#define paste(a,b) paste1(a,b)
#define paste1(a,b) a##b
#define current(type,x,offset) \
((const type *) _NL_CURRENT (LC_MONETARY, paste(_NL_MONETARY_,x)) + offset)
__monetary_conversion_rate = current (uint32_t, bo (CONVERSION_RATE), 0);
}

22
locale/lc-name.c Normal file
View File

@ -0,0 +1,22 @@
/* Define current locale data for LC_NAME category.
Copyright (C) 1998 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. */
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_NAME);

22
locale/lc-paper.c Normal file
View File

@ -0,0 +1,22 @@
/* Define current locale data for LC_PAPER category.
Copyright (C) 1998 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. */
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_PAPER);

22
locale/lc-telephone.c Normal file
View File

@ -0,0 +1,22 @@
/* Define current locale data for LC_TELEPHONE category.
Copyright (C) 1998 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. */
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_TELEPHONE);

View File

@ -1,5 +1,5 @@
/* Define current locale data for LC_TIME category.
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999 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
@ -18,9 +18,11 @@
Boston, MA 02111-1307, USA. */
#include <bits/libc-lock.h>
#include <endian.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include "localeinfo.h"
_NL_CURRENT_DEFINE (LC_TIME);
@ -36,7 +38,10 @@ static size_t num_eras;
static int alt_digits_initialized;
static const char **alt_digits;
static size_t num_alt_digits;
static int walt_digits_initialized;
static const wchar_t **walt_digits;
void
@ -45,6 +50,7 @@ _nl_postload_time (void)
/* Prepare lazy initialization of `era' and `alt_digits' array. */
era_initialized = 0;
alt_digits_initialized = 0;
walt_digits_initialized = 0;
}
@ -58,8 +64,13 @@ _nl_get_era_entry (const struct tm *tp)
if (era_initialized == 0)
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
size_t new_num_eras = _NL_CURRENT_WORD (LC_TIME,
_NL_TIME_ERA_NUM_ENTRIES);
_NL_TIME_ERA_NUM_ENTRIES_EL);
#else
size_t new_num_eras = _NL_CURRENT_WORD (LC_TIME,
_NL_TIME_ERA_NUM_ENTRIES_EB);
#endif
if (eras != NULL && new_num_eras == 0)
{
@ -88,12 +99,17 @@ _nl_get_era_entry (const struct tm *tp)
/* Skip numeric values. */
ptr += sizeof (struct era_entry);
/* Skip era name. */
/* Skip era name. */
ptr = strchr (ptr, '\0') + 1;
/* Skip era format. */
/* Skip era format. */
ptr = strchr (ptr, '\0') + 1;
ptr += 3 - (((ptr - (const char *) eras[cnt]) + 3) & 3);
/* Skip wide era name. */
ptr = (char *) wcschr ((wchar_t *) ptr, '\0');
/* Skip wide era format. */
ptr = (char *) wcschr ((wchar_t *) ptr, '\0');
}
}
}
@ -132,43 +148,28 @@ _nl_get_alt_digit (unsigned int number)
if (alt_digits_initialized == 0)
{
size_t new_num_alt_digits = _NL_CURRENT_WORD (LC_TIME,
_NL_TIME_NUM_ALT_DIGITS);
if (alt_digits != NULL && new_num_alt_digits == 0)
{
free (alt_digits);
alt_digits = NULL;
}
else if (new_num_alt_digits != 0)
{
if (num_alt_digits != new_num_alt_digits)
alt_digits = realloc (alt_digits, (new_num_alt_digits
* sizeof (const char *)));
if (alt_digits == NULL)
num_alt_digits = 0;
else
{
const char *ptr = _NL_CURRENT (LC_TIME, ALT_DIGITS);
size_t cnt;
num_alt_digits = new_num_alt_digits;
for (cnt = 0; cnt < num_alt_digits; ++cnt)
{
alt_digits[cnt] = ptr;
/* Skip digit format. */
ptr = strchr (ptr, '\0') + 1;
}
}
}
alt_digits_initialized = 1;
if (alt_digits == NULL)
alt_digits = malloc (100 * sizeof (const char *));
if (alt_digits != NULL)
{
const char *ptr = _NL_CURRENT (LC_TIME, ALT_DIGITS);
size_t cnt;
if (alt_digits != NULL)
for (cnt = 0; cnt < 100; ++cnt)
{
alt_digits[cnt] = ptr;
/* Skip digit format. */
ptr = strchr (ptr, '\0') + 1;
}
}
}
result = number < num_alt_digits ? alt_digits[number] : NULL;
result = alt_digits != NULL && number < 100 ? alt_digits[number] : NULL;
__libc_lock_unlock (__libc_setlocale_lock);
@ -176,14 +177,42 @@ _nl_get_alt_digit (unsigned int number)
}
/* Free all resources if necessary. */
static void __attribute__ ((unused))
free_mem (void)
const wchar_t *
_nl_get_walt_digit (unsigned int number)
{
if (eras != NULL)
free (eras);
if (alt_digits != NULL)
free (alt_digits);
}
const wchar_t *result;
text_set_element (__libc_subfreeres, free_mem);
__libc_lock_lock (__libc_setlocale_lock);
if (walt_digits_initialized == 0)
{
walt_digits_initialized = 1;
if (walt_digits == NULL)
walt_digits = malloc (100 * sizeof (const uint32_t *));
if (walt_digits != NULL)
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
const wchar_t *ptr = _NL_CURRENT_WSTR (LC_TIME, _NL_WALT_DIGITS_EL);
#else
const wchar_t *ptr = _NL_CURRENT_WSTR (LC_TIME, _NL_WALT_DIGITS_EB);
#endif
size_t cnt;
for (cnt = 0; cnt < 100; ++cnt)
{
walt_digits[cnt] = ptr;
/* Skip digit format. */
ptr = wcschr (ptr, L'\0') + 1;
}
}
}
result = walt_digits != NULL && number < 100 ? walt_digits[number] : NULL;
__libc_lock_unlock (__libc_setlocale_lock);
return (wchar_t *) result;
}

View File

@ -1,7 +1,7 @@
/* Functions to read locale data files.
Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
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
@ -18,14 +18,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <byteswap.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef _POSIX_MAPPED_FILES
# include <sys/mman.h>
#endif
#include <sys/mman.h>
#include <sys/stat.h>
#include "localeinfo.h"
@ -33,7 +32,7 @@
static const size_t _nl_category_num_items[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = _NL_ITEM_INDEX (_NL_NUM_##category),
#include "categories.def"
#undef DEFINE_CATEGORY
@ -42,7 +41,7 @@ static const size_t _nl_category_num_items[] =
#define NO_PAREN(arg, rest...) arg, ##rest
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
static const enum value_type _nl_value_type_##category[] = { NO_PAREN items };
#define DEFINE_ELEMENT(element, element_name, optstd, type, rest...) \
[_NL_ITEM_INDEX (element)] = type,
@ -51,7 +50,7 @@ static const enum value_type _nl_value_type_##category[] = { NO_PAREN items };
static const enum value_type *_nl_value_types[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = _nl_value_type_##category,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -76,10 +75,9 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
size_t cnt;
inline unsigned int SWAP (const unsigned int *inw)
{
const unsigned char *inc = (const unsigned char *) inw;
if (!swap)
return *inw;
return (inc[3] << 24) | (inc[2] << 16) | (inc[1] << 8) | inc[0];
return bswap_32 (*inw);
}
file->decided = 1;
@ -97,17 +95,13 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
/* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo
instead. */
char *newp;
size_t filenamelen;
__close (fd);
filenamelen = strlen (file->filename);
newp = (char *) alloca (filenamelen
newp = (char *) alloca (strlen (file->filename)
+ 5 + _nl_category_name_sizes[category] + 1);
__mempcpy (__mempcpy (__mempcpy (newp, file->filename, filenamelen),
"/SYS_", 5),
_nl_category_names[category],
_nl_category_name_sizes[category] + 1);
__stpcpy (__stpcpy (__stpcpy (newp, file->filename), "/SYS_"),
_nl_category_names[category]);
fd = __open (newp, O_RDONLY);
if (fd < 0)
@ -119,32 +113,24 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
/* Map in the file's data. */
save_err = errno;
#ifdef _POSIX_MAPPED_FILES
# ifndef MAP_COPY
#ifndef MAP_COPY
/* Linux seems to lack read-only copy-on-write. */
# define MAP_COPY MAP_PRIVATE
# endif
# ifndef MAP_FILE
#define MAP_COPY MAP_PRIVATE
#endif
#ifndef MAP_FILE
/* Some systems do not have this flag; it is superfluous. */
# define MAP_FILE 0
# endif
# ifndef MAP_INHERIT
#define MAP_FILE 0
#endif
#ifndef MAP_INHERIT
/* Some systems might lack this; they lose. */
# define MAP_INHERIT 0
# endif
#define MAP_INHERIT 0
#endif
filedata = (void *) __mmap ((caddr_t) 0, st.st_size, PROT_READ,
MAP_FILE|MAP_COPY|MAP_INHERIT, fd, 0);
if ((void *) filedata != MAP_FAILED)
{
if (st.st_size < sizeof (*filedata))
/* This cannot be a locale data file since it's too small. */
goto puntfd;
}
else
if ((void *) filedata == MAP_FAILED)
{
if (errno == ENOSYS)
{
#endif /* _POSIX_MAPPED_FILES */
/* No mmap; allocate a buffer and read from the file. */
mmaped = 0;
filedata = malloc (st.st_size);
@ -170,12 +156,13 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
else
goto puntfd;
__set_errno (save_err);
#ifdef _POSIX_MAPPED_FILES
}
else
goto puntfd;
}
#endif /* _POSIX_MAPPED_FILES */
else if (st.st_size < sizeof (*filedata))
/* This cannot be a locale data file since it's too small. */
goto puntfd;
if (filedata->magic == LIMAGIC (category))
/* Good data file in our byte order. */
@ -188,12 +175,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
/* Bad data file in either byte order. */
{
puntmap:
#ifdef _POSIX_MAPPED_FILES
if (mmaped)
__munmap ((caddr_t) filedata, st.st_size);
else
#endif /* _POSIX_MAPPED_FILES */
free (filedata);
__munmap ((caddr_t) filedata, st.st_size);
puntfd:
__close (fd);
return;
@ -211,9 +193,9 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
goto puntmap;
}
newdata = malloc (sizeof *newdata +
(_nl_category_num_items[category]
* sizeof (union locale_data_value)));
newdata = malloc (sizeof *newdata
+ (_nl_category_num_items[category]
* sizeof (union locale_data_value)));
if (! newdata)
goto puntmap;
@ -246,14 +228,9 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
void
_nl_unload_locale (struct locale_data *locale)
{
if (locale->name != NULL)
free ((void *) locale->name);
#ifdef _POSIX_MAPPED_FILES
if (locale->mmaped)
__munmap ((caddr_t) locale->filedata, locale->filesize);
else
#endif
free ((void *) locale->filedata);
free (locale);

View File

@ -32,13 +32,19 @@ __BEGIN_DECLS
/* These are the possibilities for the first argument to setlocale.
The code assumes that LC_ALL is the highest value, and zero the lowest. */
#define LC_CTYPE 0
#define LC_NUMERIC 1
#define LC_TIME 2
#define LC_COLLATE 3
#define LC_MONETARY 4
#define LC_MESSAGES 5
#define LC_ALL 6
#define LC_CTYPE 0
#define LC_NUMERIC 1
#define LC_TIME 2
#define LC_COLLATE 3
#define LC_MONETARY 4
#define LC_MESSAGES 5
#define LC_ALL 6
#define LC_PAPER 7
#define LC_NAME 8
#define LC_ADDRESS 9
#define LC_TELEPHONE 10
#define LC_MEASUREMENT 11
#define LC_IDENTIFICATION 12
/* Structure giving information about numeric and monetary notation. */

View File

@ -1,5 +1,5 @@
/* localeinfo.h -- declarations for internal libc locale interfaces
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
/* Declarations for internal libc locale interfaces
Copyright (C) 1995, 1996, 1997, 1998, 1999 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
@ -24,17 +24,21 @@
#include <langinfo.h>
#include <limits.h>
#include <time.h>
#include <stdint.h>
#include <sys/types.h>
#include "../intl/loadinfo.h" /* For loaded_l10nfile definition. */
/* This has to be changed whenever a new locale is defined. */
#define __LC_LAST 13
#include <intl/loadinfo.h> /* For loaded_l10nfile definition. */
/* Magic number at the beginning of a locale data file for CATEGORY. */
#define LIMAGIC(category) (0x960617de ^ (category))
#define LIMAGIC(category) (0x980505 ^ (category))
/* Two special weight constants for the collation data. */
#define FORWARD_CHAR ((wchar_t) 0xfffffffd)
#define ELLIPSIS_CHAR ((wchar_t) 0xfffffffe)
#define IGNORE_CHAR ((wchar_t) 0xffffffff)
#define FORWARD_CHAR ((uint32_t) 0xfffffffd)
#define ELLIPSIS_CHAR ((uint32_t) 0xfffffffe)
#define IGNORE_CHAR ((uint32_t) 0xffffffff)
/* We use a special value for the usage counter in `locale_data' to
signal that this data must never be removed anymore. */
@ -54,7 +58,7 @@ struct locale_data
unsigned int nstrings; /* Number of strings below. */
union locale_data_value
{
const wchar_t *wstr;
const uint32_t *wstr;
const char *string;
unsigned int word;
}
@ -83,14 +87,15 @@ enum value_type
byte,
bytearray,
word,
stringlist
stringlist,
wordarray
};
/* Structure to access `era' information from LC_TIME. */
struct era_entry
{
u_int32_t direction; /* Contains '+' or '-'. */
uint32_t direction; /* Contains '+' or '-'. */
int32_t offset;
int32_t start_date[3];
int32_t stop_date[3];
@ -99,27 +104,26 @@ struct era_entry
/* For each category declare the variable for the current locale data. */
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
extern struct locale_data *_nl_current_##category;
#include "categories.def"
#undef DEFINE_CATEGORY
extern const char _nl_category_names[LC_ALL + 1][16];
extern const size_t _nl_category_name_sizes[LC_ALL + 1];
extern struct locale_data * *const _nl_current[LC_ALL + 1];
extern const char *const _nl_category_names[__LC_LAST];
extern const size_t _nl_category_name_sizes[__LC_LAST];
extern struct locale_data * *const _nl_current[__LC_LAST];
/* Name of the standard locales. */
extern const char _nl_C_name[];
extern const char _nl_POSIX_name[];
/* XXX Temporily until the locale data has everything. */
extern struct locale_data _nl_C_LC_TIME;
/* Extract the current CATEGORY locale's string for ITEM. */
#define _NL_CURRENT(category, item) \
((item) < _NL_WABDAY_1 || (item) > _NL_WALT_DIGITS \
? (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string) \
: _nl_C_LC_TIME.values[_NL_ITEM_INDEX (item)].string)
(_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
/* Extract the current CATEGORY locale's string for ITEM. */
#define _NL_CURRENT_WSTR(category, item) \
((wchar_t *) (_nl_current_##category->values[_NL_ITEM_INDEX (item)].wstr))
/* Extract the current CATEGORY locale's word for ITEM. */
#define _NL_CURRENT_WORD(category, item) \
@ -154,15 +158,18 @@ extern struct era_entry *_nl_get_era_entry (const struct tm *tp);
/* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */
extern const char *_nl_get_alt_digit (unsigned int number);
/* Similar, but now for wide characters. */
extern const wchar_t *_nl_get_walt_digit (unsigned int number);
/* Global variables for LC_COLLATE category data. */
extern const u_int32_t *__collate_table;
extern const u_int32_t *__collate_extra;
extern const u_int32_t *__collate_element_hash;
extern const uint32_t *__collate_tablewc;
extern const uint32_t *__collate_extrawc;
extern const uint32_t *__collate_element_hash;
extern const char *__collate_element_strings;
extern const wchar_t *__collate_element_values;
extern const u_int32_t *__collate_symbol_hash;
extern const uint32_t *__collate_element_values;
extern const uint32_t *__collate_symbol_hash;
extern const char *__collate_symbol_strings;
extern const u_int32_t *__collate_symbol_classes;
extern const uint32_t *__collate_symbol_classes;
#endif /* localeinfo.h */

View File

@ -1,5 +1,5 @@
/* Return a reference to locale information record.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -41,7 +41,7 @@ __locale_t
__newlocale (int category_mask, const char *locale, __locale_t base)
{
/* Intermediate memory for result. */
const char *newnames[LC_ALL];
const char *newnames[__LC_LAST];
struct __locale_struct result;
__locale_t result_ptr;
char *locale_path;
@ -51,10 +51,10 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
/* We treat LC_ALL in the same way as if all bits were set. */
if (category_mask == LC_ALL)
category_mask = (1 << LC_ALL) - 1;
category_mask = (1 << __LC_LAST) - 1 - (1 << LC_ALL);
/* Sanity check for CATEGORY argument. */
if ((category_mask & ~((1 << LC_ALL) - 1)) != 0)
if ((category_mask & ~((1 << LC_ALL) - 1 - (1 << LC_ALL))) != 0)
ERROR_RETURN;
/* `newlocale' does not support asking for the locale name. */
@ -72,8 +72,9 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
else
{
/* Fill with pointers to C locale data to . */
for (cnt = 0; cnt < LC_ALL; ++cnt)
result.__locales[cnt] = _nl_C[cnt];
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL)
result.__locales[cnt] = _nl_C[cnt];
/* If no category is to be set we return BASE if available or a
dataset using the C locale data. */
@ -105,8 +106,9 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
/* Get the names for the locales we are interested in. We either
allow a composite name or a single name. */
for (cnt = 0; cnt < LC_ALL; ++cnt)
newnames[cnt] = locale;
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL)
newnames[cnt] = locale;
if (strchr (locale, ';') != NULL)
{
/* This is a composite name. Make a copy and split it up. */
@ -115,12 +117,13 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
while ((cp = strchr (np, '=')) != NULL)
{
for (cnt = 0; cnt < LC_ALL; ++cnt)
if ((size_t) (cp - np) == _nl_category_name_sizes[cnt]
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL
&& (size_t) (cp - np) == _nl_category_name_sizes[cnt]
&& memcmp (np, _nl_category_names[cnt], cp - np) == 0)
break;
if (cnt == LC_ALL)
if (cnt == __LC_LAST)
/* Bogus category name. */
ERROR_RETURN;
@ -138,15 +141,16 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
break;
}
for (cnt = 0; cnt < LC_ALL; ++cnt)
if ((category_mask & 1 << cnt) != 0 && newnames[cnt] == locale)
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL
&& (category_mask & 1 << cnt) != 0 && newnames[cnt] == locale)
/* The composite name did not specify the category we need. */
ERROR_RETURN;
}
/* Now process all categories we are interested in. */
for (cnt = 0; cnt < LC_ALL; ++cnt)
if ((category_mask & 1 << cnt) != 0)
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL && (category_mask & 1 << cnt) != 0)
{
result.__locales[cnt] = _nl_find_locale (locale_path, locale_path_len,
cnt, &newnames[cnt]);

View File

@ -1,7 +1,7 @@
%{
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
Contributed by Ulrich Drepper, <drepper@gnu.org>.
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
@ -33,6 +33,9 @@ g0esc, tok_g0esc, 1
g1esc, tok_g1esc, 1
g2esc, tok_g2esc, 1
g3esc, tok_g3esc, 1
escseq, tok_escseq, 1
addset, tok_addset, 1
include, tok_include, 1
CHARMAP, tok_charmap, 0
END, tok_end, 0
WIDTH, tok_width, 0

View File

@ -1,8 +1,8 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: gperf -acCgopt -k1,2,5,$ -N charmap_hash programs/charmap-kw.gperf */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
/* ANSI-C code produced by gperf version 2.7.1 (19981006 egcs) */
/* Command-line: gperf -acCgopt -k1,2,5,9,$ -L ANSI-C -N charmap_hash programs/charmap-kw.gperf */
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
Contributed by Ulrich Drepper, <drepper@gnu.org>.
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
@ -24,81 +24,103 @@
#include "locfile-token.h"
struct keyword_t ;
#define TOTAL_KEYWORDS 14
#define TOTAL_KEYWORDS 17
#define MIN_WORD_LENGTH 3
#define MAX_WORD_LENGTH 14
#define MIN_HASH_VALUE 3
#define MAX_HASH_VALUE 25
/* maximum key range = 23, duplicates = 0 */
#define MAX_HASH_VALUE 35
/* maximum key range = 33, duplicates = 0 */
#ifdef __GNUC__
inline
__inline
#endif
static unsigned int
hash (register const char *str, register int len)
hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
{
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 14, 10,
15, 4, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 0, 0, 0,
26, 26, 0, 0, 26, 26, 26, 0, 0, 26,
0, 26, 26, 26, 5, 26, 26, 0, 26, 26,
26, 26, 26, 26, 26, 0, 26, 26, 0, 0,
26, 0, 26, 0, 26, 26, 26, 26, 26, 0,
15, 0, 0, 26, 0, 0, 26, 0, 26, 26,
0, 26, 26, 26, 26, 26, 26, 26,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 25, 10,
15, 20, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 10, 0, 0,
5, 36, 0, 0, 36, 36, 36, 0, 0, 36,
0, 36, 0, 36, 0, 36, 36, 0, 36, 36,
36, 36, 36, 36, 36, 0, 36, 0, 0, 0,
10, 0, 36, 0, 0, 0, 36, 36, 36, 0,
0, 0, 0, 0, 0, 0, 0, 0, 36, 36,
25, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36
};
register int hval = len;
switch (hval)
{
default:
case 9:
hval += asso_values[(unsigned char)str[8]];
case 8:
case 7:
case 6:
case 5:
hval += asso_values[str[4]];
hval += asso_values[(unsigned char)str[4]];
case 4:
case 3:
case 2:
hval += asso_values[str[1]];
hval += asso_values[(unsigned char)str[1]];
case 1:
hval += asso_values[str[0]];
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval + asso_values[str[len - 1]];
return hval + asso_values[(unsigned char)str[len - 1]];
}
#ifdef __GNUC__
inline
__inline
#endif
const struct keyword_t *
charmap_hash (register const char *str, register int len)
charmap_hash (register const char *str, register unsigned int len)
{
static const struct keyword_t wordlist[] =
{
{"",}, {"",}, {"",},
{"END", tok_end, 0},
{"",},
{"WIDTH", tok_width, 0},
{"",},
{"CHARMAP", tok_charmap, 0},
{"",},
{"g3esc", tok_g3esc, 1},
{"mb_cur_max", tok_mb_cur_max, 1},
{"escape_char", tok_escape_char, 1},
{"comment_char", tok_comment_char, 1},
{"code_set_name", tok_code_set_name, 1},
{"WIDTH_VARIABLE", tok_width_variable, 0},
{"g1esc", tok_g1esc, 1},
{"",}, {"",},
{"WIDTH_DEFAULT", tok_width_default, 0},
{"g0esc", tok_g0esc, 1},
{"g2esc", tok_g2esc, 1},
{"",}, {"",}, {"",}, {"",},
{"mb_cur_min", tok_mb_cur_min, 1},
{""}, {""}, {""},
{"END", tok_end, 0},
{""},
{"WIDTH", tok_width, 0},
{"escseq", tok_escseq, 1},
{"include", tok_include, 1},
{""}, {""},
{"mb_cur_min", tok_mb_cur_min, 1},
{"escape_char", tok_escape_char, 1},
{"comment_char", tok_comment_char, 1},
{"code_set_name", tok_code_set_name, 1},
{"WIDTH_VARIABLE", tok_width_variable, 0},
{"g1esc", tok_g1esc, 1},
{"addset", tok_addset, 1},
{"CHARMAP", tok_charmap, 0},
{"WIDTH_DEFAULT", tok_width_default, 0},
{""},
{"g2esc", tok_g2esc, 1},
{""}, {""}, {""}, {""},
{"g3esc", tok_g3esc, 1},
{""}, {""}, {""}, {""},
{"g0esc", tok_g0esc, 1},
{""}, {""}, {""}, {""},
{"mb_cur_max", tok_mb_cur_max, 1}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@ -109,7 +131,7 @@ charmap_hash (register const char *str, register int len)
{
register const char *s = wordlist[key].name;
if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
return &wordlist[key];
}
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -25,6 +25,7 @@
#include <dirent.h>
#include <errno.h>
#include <libintl.h>
#include <limits.h>
#include <obstack.h>
#include <stdlib.h>
#include <string.h>
@ -32,13 +33,10 @@
#include "error.h"
#include "linereader.h"
#include "charset.h"
#include "charmap.h"
#include "locfile.h"
#include "repertoire.h"
/* Uncomment following line for production version. */
/* define NDEBUG 1 */
#include <assert.h>
@ -49,17 +47,20 @@
extern void *xmalloc (size_t __n);
/* Prototypes for local functions. */
static struct charset_t *parse_charmap (const char *filename);
static void new_width (struct linereader *cmfile, struct charset_t *result,
static struct charmap_t *parse_charmap (const char *filename);
static void new_width (struct linereader *cmfile, struct charmap_t *result,
const char *from, const char *to,
unsigned long int width);
static void charmap_new_char (struct linereader *lr, struct charmap_t *cm,
int nbytes, char *bytes, const char *from,
const char *to, int decimal_ellipsis);
struct charset_t *
struct charmap_t *
charmap_read (const char *filename)
{
const char *pathnfile;
struct charset_t *result = NULL;
struct charmap_t *result = NULL;
if (filename != NULL)
{
@ -175,16 +176,17 @@ charmap_read (const char *filename)
}
static struct charset_t *
static struct charmap_t *
parse_charmap (const char *filename)
{
struct linereader *cmfile;
struct charset_t *result;
struct charmap_t *result;
int state;
enum token_t expected_tok = tok_error;
const char *expected_str = NULL;
char *from_name = NULL;
char *to_name = NULL;
enum token_t ellipsis = 0;
/* Determine path. */
cmfile = lr_open (filename, charmap_hash);
@ -206,9 +208,12 @@ parse_charmap (const char *filename)
return NULL;
}
/* We don't want symbolic names in string to be translated. */
cmfile->translate_strings = 0;
/* Allocate room for result. */
result = (struct charset_t *) xmalloc (sizeof (struct charset_t));
memset (result, '\0', sizeof (struct charset_t));
result = (struct charmap_t *) xmalloc (sizeof (struct charmap_t));
memset (result, '\0', sizeof (struct charmap_t));
/* The default DEFAULT_WIDTH is 1. */
result->width_default = 1;
@ -216,7 +221,8 @@ parse_charmap (const char *filename)
#define obstack_chunk_free free
obstack_init (&result->mem_pool);
if (init_hash (&result->char_table, 256))
if (init_hash (&result->char_table, 256)
|| init_hash (&result->byte_table, 256))
{
free (result);
return NULL;
@ -228,7 +234,7 @@ parse_charmap (const char *filename)
while (1)
{
/* What's on? */
struct token *now = lr_token (cmfile, NULL);
struct token *now = lr_token (cmfile, NULL, NULL);
enum token_t nowtok = now->tok;
struct token *arg;
@ -275,22 +281,24 @@ parse_charmap (const char *filename)
&& nowtok != tok_mb_cur_min && nowtok != tok_escape_char
&& nowtok != tok_comment_char && nowtok != tok_g0esc
&& nowtok != tok_g1esc && nowtok != tok_g2esc
&& nowtok != tok_g3esc)
&& nowtok != tok_g3esc && nowtok != tok_repertoiremap
&& nowtok != tok_include)
{
lr_error (cmfile, _("syntax error in prolog: %s"),
_("illegal definition"));
_("invalid definition"));
lr_ignore_rest (cmfile, 0);
continue;
}
/* We know that we need an argument. */
arg = lr_token (cmfile, NULL);
arg = lr_token (cmfile, NULL, NULL);
switch (nowtok)
{
case tok_code_set_name:
if (arg->tok != tok_ident && arg->tok != tok_string)
case tok_repertoiremap:
if (arg->tok != tok_ident)
{
badarg:
lr_error (cmfile, _("syntax error in prolog: %s"),
@ -300,9 +308,14 @@ parse_charmap (const char *filename)
continue;
}
result->code_set_name = obstack_copy0 (&result->mem_pool,
arg->val.str.start,
arg->val.str.len);
if (nowtok == tok_code_set_name)
result->code_set_name = obstack_copy0 (&result->mem_pool,
arg->val.str.startmb,
arg->val.str.lenmb);
else
result->repertoiremap = obstack_copy0 (&result->mem_pool,
arg->val.str.startmb,
arg->val.str.lenmb);
lr_ignore_rest (cmfile, 1);
continue;
@ -312,12 +325,21 @@ parse_charmap (const char *filename)
if (arg->tok != tok_number)
goto badarg;
if (arg->val.num < 1 || arg->val.num > 4)
if (verbose
&& ((nowtok == tok_mb_cur_max
&& result->mb_cur_max != 0)
|| (nowtok == tok_mb_cur_max
&& result->mb_cur_max != 0)))
lr_error (cmfile, _("duplicate definition of <%s>"),
nowtok == tok_mb_cur_min
? "mb_cur_min" : "mb_cur_max");
if (arg->val.num < 1)
{
lr_error (cmfile,
_("value for <%s> must lie between 1 and 4"),
nowtok == tok_mb_cur_min ? "mb_cur_min"
: "mb_cur_max");
_("value for <%s> must be 1 or greater"),
nowtok == tok_mb_cur_min
? "mb_cur_min" : "mb_cur_max");
lr_ignore_rest (cmfile, 0);
continue;
@ -328,7 +350,8 @@ parse_charmap (const char *filename)
&& (int) arg->val.num > result->mb_cur_max))
{
lr_error (cmfile, _("\
value of <mb_cur_max> must be greater than the value of <mb_cur_min>"));
value of <%s> must be greater or equal than the value of <%s>"),
"mb_cur_max", "mb_cur_min");
lr_ignore_rest (cmfile, 0);
continue;
@ -347,7 +370,7 @@ value of <mb_cur_max> must be greater than the value of <mb_cur_min>"));
if (arg->tok != tok_ident)
goto badarg;
if (arg->val.str.len != 1)
if (arg->val.str.lenmb != 1)
{
lr_error (cmfile, _("\
argument to <%s> must be a single character"),
@ -359,9 +382,9 @@ argument to <%s> must be a single character"),
}
if (nowtok == tok_escape_char)
cmfile->escape_char = *arg->val.str.start;
cmfile->escape_char = *arg->val.str.startmb;
else
cmfile->comment_char = *arg->val.str.start;
cmfile->comment_char = *arg->val.str.startmb;
lr_ignore_rest (cmfile, 1);
continue;
@ -370,9 +393,15 @@ argument to <%s> must be a single character"),
case tok_g1esc:
case tok_g2esc:
case tok_g3esc:
case tok_escseq:
lr_ignore_rest (cmfile, 0); /* XXX */
continue;
case tok_include:
lr_error (cmfile, _("\
character sets with locking states are not supported"));
exit (4);
default:
/* Cannot happen. */
assert (! "Should not happen");
@ -409,8 +438,8 @@ argument to <%s> must be a single character"),
obstack_free (&result->mem_pool, from_name);
from_name = (char *) obstack_copy0 (&result->mem_pool,
now->val.str.start,
now->val.str.len);
now->val.str.startmb,
now->val.str.lenmb);
to_name = NULL;
state = 3;
@ -419,19 +448,20 @@ argument to <%s> must be a single character"),
case 3:
/* We have two possibilities: We can see an ellipsis or an
encoding value. */
if (nowtok == tok_ellipsis)
if (nowtok == tok_ellipsis3 || nowtok == tok_ellipsis4
|| nowtok == tok_ellipsis2)
{
ellipsis = nowtok;
state = 4;
continue;
}
/* FALLTHROUGH */
case 5:
if (nowtok != tok_charcode && nowtok != tok_ucs2
&& nowtok != tok_ucs4)
if (nowtok != tok_charcode)
{
lr_error (cmfile, _("syntax error in %s definition: %s"),
"CHARMAP", _("illegal encoding given"));
"CHARMAP", _("invalid encoding given"));
lr_ignore_rest (cmfile, 0);
@ -444,9 +474,9 @@ argument to <%s> must be a single character"),
else if (now->val.charcode.nbytes > result->mb_cur_max)
lr_error (cmfile, _("too many bytes in character encoding"));
else
charset_new_char (cmfile, &result->char_table,
now->val.charcode.nbytes,
now->val.charcode.val, from_name, to_name);
charmap_new_char (cmfile, result, now->val.charcode.nbytes,
now->val.charcode.bytes, from_name, to_name,
ellipsis != tok_ellipsis2);
/* Ignore trailing comment silently. */
lr_ignore_rest (cmfile, 0);
@ -470,8 +500,8 @@ argument to <%s> must be a single character"),
/* Copy the to-name in a safe place. */
to_name = (char *) obstack_copy0 (&result->mem_pool,
cmfile->token.val.str.start,
cmfile->token.val.str.len);
cmfile->token.val.str.startmb,
cmfile->token.val.str.lenmb);
state = 5;
continue;
@ -557,15 +587,15 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
obstack_free (&result->mem_pool, from_name);
from_name = (char *) obstack_copy0 (&result->mem_pool,
now->val.str.start,
now->val.str.len);
now->val.str.startmb,
now->val.str.lenmb);
to_name = NULL;
state = 94;
continue;
case 94:
if (nowtok == tok_ellipsis)
if (nowtok == tok_ellipsis3)
{
state = 95;
continue;
@ -602,8 +632,8 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
}
to_name = (char *) obstack_copy0 (&result->mem_pool,
now->val.str.start,
now->val.str.len);
now->val.str.startmb,
now->val.str.lenmb);
state = 96;
continue;
@ -637,15 +667,15 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
obstack_free (&result->mem_pool, from_name);
from_name = (char *) obstack_copy0 (&result->mem_pool,
now->val.str.start,
now->val.str.len);
now->val.str.startmb,
now->val.str.lenmb);
to_name = NULL;
state = 99;
continue;
case 99:
if (nowtok == tok_ellipsis)
if (nowtok == tok_ellipsis3)
state = 100;
/* Store info. */
@ -663,8 +693,8 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
else
{
to_name = (char *) obstack_copy0 (&result->mem_pool,
now->val.str.start,
now->val.str.len);
now->val.str.startmb,
now->val.str.lenmb);
/* XXX Enter value into table. */
}
@ -690,13 +720,14 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
static void
new_width (struct linereader *cmfile, struct charset_t *result,
new_width (struct linereader *cmfile, struct charmap_t *result,
const char *from, const char *to, unsigned long int width)
{
unsigned int from_val, to_val;
struct charseq *from_val;
struct charseq *to_val;
from_val = charset_find_value (&result->char_table, from, strlen (from));
if ((wchar_t) from_val == ILLEGAL_CHAR_VALUE)
from_val = charmap_find_value (result, from, strlen (from));
if (from_val == NULL)
{
lr_error (cmfile, _("unknown character `%s'"), from);
return;
@ -706,8 +737,8 @@ new_width (struct linereader *cmfile, struct charset_t *result,
to_val = from_val;
else
{
to_val = charset_find_value (&result->char_table, to, strlen (to));
if ((wchar_t) to_val == ILLEGAL_CHAR_VALUE)
to_val = charmap_find_value (result, to, strlen (to));
if (to_val == NULL)
{
lr_error (cmfile, _("unknown character `%s'"), to);
return;
@ -734,3 +765,140 @@ new_width (struct linereader *cmfile, struct charset_t *result,
result->width_rules[result->nwidth_rules].width = (unsigned int) width;
++result->nwidth_rules;
}
struct charseq *
charmap_find_value (const struct charmap_t *cm, const char *name, size_t len)
{
void *result;
return (find_entry ((hash_table *) &cm->char_table, name, len, &result)
< 0 ? NULL : (struct charseq *) result);
}
static void
charmap_new_char (struct linereader *lr, struct charmap_t *cm,
int nbytes, char *bytes, const char *from, const char *to,
int decimal_ellipsis)
{
hash_table *ht = &cm->char_table;
hash_table *bt = &cm->byte_table;
struct obstack *ob = &cm->mem_pool;
char *from_end;
char *to_end;
const char *cp;
int prefix_len, len1, len2;
unsigned int from_nr, to_nr, cnt;
struct charseq *newp;
len1 = strlen (from);
if (to == NULL)
{
newp = (struct charseq *) obstack_alloc (ob, sizeof (*newp) + nbytes);
newp->nbytes = nbytes;
memcpy (newp->bytes, bytes, nbytes);
newp->name = obstack_copy (ob, from, len1 + 1);
newp->ucs4 = UNINITIALIZED_CHAR_VALUE;
insert_entry (ht, from, len1, newp);
insert_entry (bt, newp->bytes, nbytes, newp);
/* Please note that it isn't a bug if a symbol is defined more
than once. All later definitions are simply discarded. */
return;
}
/* We have a range: the names must have names with equal prefixes
and an equal number of digits, where the second number is greater
or equal than the first. */
len2 = strlen (to);
if (len1 != len2)
{
illegal_range:
lr_error (lr, _("invalid names for character range"));
return;
}
cp = &from[len1 - 1];
if (decimal_ellipsis)
while (isdigit (*cp) && cp >= from)
--cp;
else
while (isxdigit (*cp) && cp >= from)
{
if (!isdigit (*cp) && !isupper (*cp))
lr_error (lr, _("\
hexadecimal range format should use only capital characters"));
--cp;
}
prefix_len = (cp - from) + 1;
if (cp == &from[len1 - 1] || strncmp (from, to, prefix_len) != 0)
goto illegal_range;
errno = 0;
from_nr = strtoul (&from[prefix_len], &from_end, decimal_ellipsis ? 10 : 16);
if (*from_end != '\0' || (from_nr == ULONG_MAX && errno == ERANGE)
|| ((to_nr = strtoul (&to[prefix_len], &to_end,
decimal_ellipsis ? 10 : 16)) == ULONG_MAX
&& errno == ERANGE)
|| *to_end != '\0')
{
lr_error (lr, _("<%s> and <%s> are illegal names for range"));
return;
}
if (from_nr > to_nr)
{
lr_error (lr, _("upper limit in range is not higher then lower limit"));
return;
}
for (cnt = from_nr; cnt <= to_nr; ++cnt)
{
char *name_end;
obstack_printf (ob, decimal_ellipsis ? "%.*s%0*d" : "%.*s%0*X",
prefix_len, from, len1 - prefix_len, cnt);
name_end = obstack_finish (ob);
newp = (struct charseq *) obstack_alloc (ob, sizeof (*newp) + nbytes);
newp->nbytes = nbytes;
memcpy (newp->bytes, bytes, nbytes);
newp->name = name_end;
newp->ucs4 = UNINITIALIZED_CHAR_VALUE;
insert_entry (ht, name_end, len1, newp);
insert_entry (bt, newp->bytes, nbytes, newp);
/* Please note we don't examine the return value since it is no error
if we have two definitions for a symbol. */
/* Increment the value in the byte sequence. */
if (++bytes[nbytes - 1] == '\0')
{
int b = nbytes - 2;
do
if (b < 0)
{
lr_error (lr,
_("resulting bytes for range not representable."));
return;
}
while (++bytes[b--] == 0);
}
}
}
struct charseq *
charmap_find_symbol (const struct charmap_t *cm, const char *bytes,
size_t nbytes)
{
void *result;
return (find_entry ((hash_table *) &cm->byte_table, bytes, nbytes, &result)
< 0 ? NULL : (struct charseq *) result);
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -17,27 +17,27 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _CHARSET_H
#define _CHARSET_H
#ifndef _CHARMAP_H
#define _CHARMAP_H
#include <obstack.h>
#include "repertoire.h"
#include "simple-hash.h"
#include "linereader.h"
struct width_rule
{
unsigned int from;
unsigned int to;
struct charseq *from;
struct charseq *to;
unsigned int width;
};
struct charset_t
struct charmap_t
{
const char *code_set_name;
const char *repertoiremap;
int mb_cur_min;
int mb_cur_max;
@ -48,27 +48,31 @@ struct charset_t
struct obstack mem_pool;
hash_table char_table;
hash_table byte_table;
hash_table ucs4_table;
};
/* We need one value to mark the error case. Let's use 0xffffffff.
I.e., it is placed in the last page of ISO 10646. For now only the
first is used and we have plenty of room. */
#define ILLEGAL_CHAR_VALUE ((wchar_t) 0xffffffffu)
/* This is the structure used for entries in the hash table. It represents
the sequence of bytes used for the coded character. */
struct charseq
{
const char *name;
uint32_t ucs4;
int nbytes;
unsigned char bytes[0];
};
/* Declared in localedef.c. */
extern int be_quiet;
/* Prototypes for charmap handling functions. */
struct charset_t *charmap_read (const char *filename);
/* Prototypes for function to insert new character. */
void charset_new_char (struct linereader *lr, hash_table *ht, int bytes,
unsigned int value, const char *from, const char *to);
extern struct charmap_t *charmap_read (const char *filename);
/* Return the value stored under the given key in the hashing table. */
unsigned int charset_find_value (const hash_table *ht,
const char *name, size_t len);
extern struct charseq *charmap_find_value (const struct charmap_t *charmap,
const char *name, size_t len);
#endif /* charset.h */
/* Return symbol for given multibyte sequence. */
extern struct charseq *charmap_find_symbol (const struct charmap_t *charmap,
const char *name, size_t len);
#endif /* charmap.h */

View File

@ -1,5 +1,25 @@
/* Configuration for localedef program.
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
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. */
#ifndef _LD_CONFIG_H
#define _LD_CONFIG_H
#define _LD_CONFIG_H 1
/* Use the internal textdomain used for libc messages. */
#define PACKAGE _libc_intl_domainname
@ -18,12 +38,8 @@
# endif
#endif
#define HAVE_VPRINTF 1
#define HAVE_STRING_H 1
/* This must be one higer than the last used LC_xxx category value. */
#define __LC_LAST 13
#include_next <config.h>
#endif

View File

@ -0,0 +1,514 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <byteswap.h>
#include <error.h>
#include <langinfo.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include "localeinfo.h"
#include "locfile.h"
static struct
{
const char ab2[2];
const char ab3[3];
uint32_t num;
} iso3166[] =
{
#define DEFINE_COUNTRY_CODE(Name, Ab2, Ab3, Num) \
{ #Ab2, #Ab3, Num },
#include "iso-3166.def"
};
static struct
{
const char ab[2];
const char term[3];
const char lib[3];
} iso639[] =
{
#define DEFINE_LANGUAGE_CODE(Name, Ab, Term, Lib) \
{ #Ab, #Term, #Lib },
#include "iso-639.def"
};
/* The real definition of the struct for the LC_ADDRESS locale. */
struct locale_address_t
{
const char *postal_fmt;
const char *country_name;
const char *country_post;
const char *country_ab2;
const char *country_ab3;
uint32_t country_num;
uint32_t country_num_ob;
const char *country_car;
const char *country_isbn;
const char *lang_name;
const char *lang_ab;
const char *lang_term;
const char *lang_lib;
};
static void
address_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
{
if (!ignore_content)
locale->categories[LC_ADDRESS].address =
(struct locale_address_t *) xcalloc (1,
sizeof (struct locale_address_t));
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
address_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_address_t *address = locale->categories[LC_ADDRESS].address;
size_t cnt;
int helper;
if (address->postal_fmt == NULL)
{
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "postal_fmt");
/* Use as the default value the value of the i18n locale. */
address->postal_fmt = "%a%N%f%N%d%N%b%N%s %h %e %r%N%C-%z %T%N%c%N";
}
else
{
/* We must check whether the format string contains only the
allowed escape sequences. */
const char *cp = address->postal_fmt;
if (*cp == '\0')
error (0, 0, _("%s: field `%s' must not be empty"),
"LC_ADDRESS", "postal_fmt");
else
while (*cp != '\0')
{
if (*cp == '%')
{
if (*++cp == 'R')
/* Romanize-flag. */
++cp;
if (strchr ("afdbshNtreCzTc%", *cp) == NULL)
{
error (0, 0, _("\
%s: invalid escape `%%%c' sequence in field `%s'"),
"LC_ADDRESS", *cp, "postal_fmt");
break;
}
}
++cp;
}
}
#define TEST_ELEM(cat) \
if (address->cat == NULL) \
{ \
if (verbose) \
error (0, 0, _("%s: field `%s' not defined"), "LC_ADDRESS", #cat); \
address->cat = ""; \
}
TEST_ELEM (country_name);
/* XXX Test against list of defined codes. */
TEST_ELEM (country_post);
/* XXX Test against list of defined codes. */
TEST_ELEM (country_car);
/* XXX Test against list of defined codes. */
TEST_ELEM (country_isbn);
TEST_ELEM (lang_name);
helper = 1;
if (address->lang_term == NULL)
{
if (verbose)
error (0, 0, _("%s: field `%s' not defined"), "LC_ADDRESS",
"lang_term");
address->lang_term = "";
cnt = sizeof (iso639) / sizeof (iso639[0]);
}
else if (address->lang_term[0] == '\0')
{
if (verbose)
error (0, 0, _("%s: field `%s' must not be empty"),
"LC_ADDRESS", "lang_term");
cnt = sizeof (iso639) / sizeof (iso639[0]);
}
else
{
/* Look for this language in the table. */
for (cnt = 0; cnt < sizeof (iso639) / sizeof (iso639[0]); ++cnt)
if (strcmp (address->lang_term, iso639[cnt].term) == 0)
break;
if (cnt == sizeof (iso639) / sizeof (iso639[0]))
error (0, 0, _("\
%s: terminology language code `%s' not defined"),
"LC_ADDRESS", address->lang_term);
}
if (address->lang_ab == NULL)
{
if (verbose)
error (0, 0, _("%s: field `%s' not defined"), "LC_ADDRESS", "lang_ab");
address->lang_ab = "";
}
else if (address->lang_ab[0] == '\0')
{
if (verbose)
error (0, 0, _("%s: field `%s' must not be empty"),
"LC_ADDRESS", "lang_ab");
}
else
{
if (cnt == sizeof (iso639) / sizeof (iso639[0]))
{
helper = 2;
for (cnt = 0; cnt < sizeof (iso639) / sizeof (iso639[0]); ++cnt)
if (strcmp (address->lang_ab, iso639[cnt].ab) == 0)
break;
if (cnt == sizeof (iso639) / sizeof (iso639[0]))
error (0, 0, _("\
%s: language abbreviation `%s' not defined"),
"LC_ADDRESS", address->lang_ab);
}
else
if (strcmp (iso639[cnt].ab, address->lang_ab) != 0)
error (0, 0, _("\
%s: `%s' value does not match `%s' value"),
"LC_ADDRESS", "lang_ab", "lang_term");
}
if (address->lang_lib == NULL)
/* This is no error. */
address->lang_lib = address->lang_term;
else if (address->lang_lib[0] == '\0')
{
if (verbose)
error (0, 0, _("%s: field `%s' must not be empty"),
"LC_ADDRESS", "lang_lib");
}
else
{
if (cnt == sizeof (iso639) / sizeof (iso639[0]))
{
for (cnt = 0; cnt < sizeof (iso639) / sizeof (iso639[0]); ++cnt)
if (strcmp (address->lang_lib, iso639[cnt].lib) == 0)
break;
if (cnt == sizeof (iso639) / sizeof (iso639[0]))
error (0, 0, _("\
%s: language abbreviation `%s' not defined"),
"LC_ADDRESS", address->lang_lib);
}
else
if (strcmp (iso639[cnt].ab, address->lang_ab) != 0)
error (0, 0, _("\
%s: `%s' value does not match `%s' value"), "LC_ADDRESS", "lang_lib",
helper == 1 ? "lang_term" : "lang_ab");
}
if (address->country_num == 0)
{
if (verbose)
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "country_num");
cnt = sizeof (iso3166) / sizeof (iso3166[0]);
}
else
{
for (cnt = 0; cnt < sizeof (iso3166) / sizeof (iso3166[0]); ++cnt)
if (address->country_num == iso3166[cnt].num)
break;
if (cnt == sizeof (iso3166) / sizeof (iso3166[0]))
error (0, 0, _("\
%s: numeric country code `%d' not valid"),
"LC_ADDRESS", address->country_num);
}
address->country_num_ob = bswap_32 (address->country_num);
if (address->country_ab2 == NULL)
{
if (verbose)
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "country_ab2");
address->country_ab2 = " ";
}
else if (cnt != sizeof (iso3166) / sizeof (iso3166[0])
&& strcmp (address->country_ab2, iso3166[cnt].ab2) != 0)
error (0, 0, _("%s: `%s' value does not match `%s' value"),
"LC_ADDRESS", "country_ab2", "country_num");
if (address->country_ab3 == NULL)
{
if (verbose)
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "country_ab3");
address->country_ab3 = " ";
}
else if (cnt != sizeof (iso3166) / sizeof (iso3166[0])
&& strcmp (address->country_ab3, iso3166[cnt].ab3) != 0)
error (0, 0, _("%s: `%s' value does not match `%s' value"),
"LC_ADDRESS", "country_ab3", "country_num");
}
void
address_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_address_t *address = locale->categories[LC_ADDRESS].address;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)];
size_t cnt = 0;
data.magic = LIMAGIC (LC_ADDRESS);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS);
iov[cnt].iov_base = (void *) &data;
iov[cnt].iov_len = sizeof (data);
++cnt;
iov[cnt].iov_base = (void *) idx;
iov[cnt].iov_len = sizeof (idx);
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) address->postal_fmt;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_name;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_post;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_ab2;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_ab3;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_car;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define country_num_eb country_num_ob
# define country_num_el country_num
#else
# define country_num_eb country_num
# define country_num_el country_num_ob
#endif
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_num_eb;
iov[cnt].iov_len = sizeof (uint32_t);
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_num_el;
iov[cnt].iov_len = sizeof (uint32_t);
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->country_isbn;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->lang_name;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->lang_ab;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->lang_term;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) address->lang_lib;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));
write_locale_data (output_path, "LC_ADDRESS",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov);
}
/* The parser for the LC_ADDRESS section of the locale definition. */
void
address_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_address_t *address;
struct token *now;
struct token *arg;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_ADDRESS' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_address, LC_ADDRESS,
"LC_ADDRESS", ignore_content);
return;
}
/* Prepare the data structures. */
address_startup (ldfile, result, ignore_content);
address = result->categories[LC_ADDRESS].address;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
if (address->cat != NULL) \
lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_ADDRESS", #cat); \
else if (!ignore_content && arg->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_ADDRESS", #cat); \
address->cat = ""; \
} \
else if (!ignore_content) \
address->cat = arg->val.str.startmb; \
break
STR_ELEM (postal_fmt);
STR_ELEM (country_name);
STR_ELEM (country_post);
STR_ELEM (country_ab2);
STR_ELEM (country_ab3);
STR_ELEM (country_car);
STR_ELEM (country_isbn);
STR_ELEM (lang_name);
STR_ELEM (lang_ab);
STR_ELEM (lang_term);
STR_ELEM (lang_lib);
#define INT_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_number) \
goto err_label; \
else if (address->cat != 0) \
lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_ADDRESS", #cat); \
else if (!ignore_content) \
address->cat = arg->val.num; \
break
INT_ELEM (country_num);
case tok_end:
/* Next we assume `LC_ADDRESS'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"),
"LC_ADDRESS");
else if (arg->tok != tok_lc_address)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_ADDRESS");
lr_ignore_rest (ldfile, arg->tok == tok_lc_address);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_ADDRESS");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_ADDRESS");
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,376 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <error.h>
#include <langinfo.h>
#include <stdlib.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include "localeinfo.h"
#include "locfile.h"
/* The real definition of the struct for the LC_IDENTIFICATION locale. */
struct locale_identification_t
{
const char *title;
const char *source;
const char *address;
const char *contact;
const char *email;
const char *tel;
const char *fax;
const char *language;
const char *territory;
const char *audience;
const char *application;
const char *abbreviation;
const char *revision;
const char *date;
const char *category[__LC_LAST];
};
static void
identification_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
{
if (!ignore_content)
{
locale->categories[LC_IDENTIFICATION].identification =
(struct locale_identification_t *)
xcalloc (1, sizeof (struct locale_identification_t));
locale->categories[LC_IDENTIFICATION].identification->category[LC_ALL] =
"";
}
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
identification_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_identification_t *identification
= locale->categories[LC_IDENTIFICATION].identification;
#define TEST_ELEM(cat) \
if (identification->cat == NULL) \
{ \
if (verbose) \
error (0, 0, _("%s: field `%s' not defined"), \
"LC_IDENTIFICATION", #cat); \
identification->cat = ""; \
}
TEST_ELEM (title);
TEST_ELEM (source);
TEST_ELEM (address);
TEST_ELEM (contact);
TEST_ELEM (email);
TEST_ELEM (tel);
TEST_ELEM (fax);
TEST_ELEM (language);
TEST_ELEM (territory);
TEST_ELEM (audience);
TEST_ELEM (application);
TEST_ELEM (abbreviation);
TEST_ELEM (revision);
TEST_ELEM (date);
}
void
identification_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_identification_t *identification
= locale->categories[LC_IDENTIFICATION].identification;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
+ (__LC_LAST - 1)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)];
size_t cnt = 0;
size_t num;
data.magic = LIMAGIC (LC_IDENTIFICATION);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION);
iov[cnt].iov_base = (void *) &data;
iov[cnt].iov_len = sizeof (data);
++cnt;
iov[cnt].iov_base = (void *) idx;
iov[cnt].iov_len = sizeof (idx);
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) identification->title;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->source;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->address;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->contact;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->email;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->tel;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->fax;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->language;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->territory;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->audience;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->application;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->abbreviation;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->revision;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) identification->date;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
for (num = 0; num < __LC_LAST; ++num)
{
iov[cnt].iov_base = (void *) identification->category[num];
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
}
assert (cnt == (2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
+ (__LC_LAST - 1)));
write_locale_data (output_path, "LC_IDENTIFICATION",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION), iov);
}
/* The parser for the LC_IDENTIFICATION section of the locale definition. */
void
identification_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_identification_t *identification;
struct token *now;
struct token *arg;
struct token *cattok;
int category;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_IDENTIFICATION' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_identification,
LC_IDENTIFICATION, "LC_IDENTIFICATION", ignore_content);
return;
}
/* Prepare the data structures. */
identification_startup (ldfile, result, ignore_content);
identification = result->categories[LC_IDENTIFICATION].identification;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
if (identification->cat != NULL) \
lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_IDENTIFICATION", #cat); \
else if (!ignore_content && arg->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_IDENTIFICATION", #cat); \
identification->cat = ""; \
} \
else if (!ignore_content) \
identification->cat = arg->val.str.startmb; \
break
STR_ELEM (title);
STR_ELEM (source);
STR_ELEM (address);
STR_ELEM (contact);
STR_ELEM (email);
STR_ELEM (tel);
STR_ELEM (fax);
STR_ELEM (language);
STR_ELEM (territory);
STR_ELEM (audience);
STR_ELEM (application);
STR_ELEM (abbreviation);
STR_ELEM (revision);
STR_ELEM (date);
case tok_category:
/* We expect two operands. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok != tok_string && arg->tok != tok_ident)
goto err_label;
/* Next is a semicolon. */
cattok = lr_token (ldfile, charmap, NULL);
if (cattok->tok != tok_semicolon)
goto err_label;
/* Now a LC_xxx identifier. */
cattok = lr_token (ldfile, charmap, NULL);
switch (cattok->tok)
{
#define CATEGORY(lname, uname) \
case tok_lc_##lname: \
category = LC_##uname; \
break
CATEGORY (identification, IDENTIFICATION);
CATEGORY (ctype, CTYPE);
CATEGORY (collate, COLLATE);
CATEGORY (time, TIME);
CATEGORY (numeric, NUMERIC);
CATEGORY (monetary, MONETARY);
CATEGORY (messages, MESSAGES);
CATEGORY (paper, PAPER);
CATEGORY (name, NAME);
CATEGORY (address, ADDRESS);
CATEGORY (telephone, TELEPHONE);
CATEGORY (measurement, MEASUREMENT);
default:
goto err_label;
}
if (identification->category[category] != NULL)
{
lr_error (ldfile, _("\
%s: duplicate category version definition"), "LC_IDENTIFICATION");
free (arg->val.str.startmb);
}
else
identification->category[category] = arg->val.str.startmb;
break;
case tok_end:
/* Next we assume `LC_IDENTIFICATION'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"),
"LC_IDENTIFICATION");
else if (arg->tok != tok_lc_identification)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_IDENTIFICATION");
lr_ignore_rest (ldfile, arg->tok == tok_lc_identification);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_IDENTIFICATION");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_IDENTIFICATION");
}

View File

@ -0,0 +1,206 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <error.h>
#include <langinfo.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include "localeinfo.h"
#include "locfile.h"
/* The real definition of the struct for the LC_MEASUREMENT locale. */
struct locale_measurement_t
{
unsigned char measurement;
};
static void
measurement_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
{
if (!ignore_content)
locale->categories[LC_MEASUREMENT].measurement =
(struct locale_measurement_t *)
xcalloc (1, sizeof (struct locale_measurement_t));
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
measurement_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_measurement_t *measurement =
locale->categories[LC_MEASUREMENT].measurement;
if (measurement->measurement == 0)
{
error (0, 0, _("%s: field `%s' not defined"),
"LC_MEASUREMENT", "measurement");
/* Use as the default value the value of the i18n locale. */
measurement->measurement = 1;
}
else
{
if (measurement->measurement > 3)
error (0, 0, _("%s: invalid value for field `%s'"),
"LC_MEASUREMENT", "meassurement");
}
}
void
measurement_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_measurement_t *measurement =
locale->categories[LC_MEASUREMENT].measurement;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT)];
size_t cnt = 0;
data.magic = LIMAGIC (LC_MEASUREMENT);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT);
iov[cnt].iov_base = (void *) &data;
iov[cnt].iov_len = sizeof (data);
++cnt;
iov[cnt].iov_base = (void *) idx;
iov[cnt].iov_len = sizeof (idx);
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = &measurement->measurement;
iov[cnt].iov_len = 1;
++cnt;
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT));
write_locale_data (output_path, "LC_MEASUREMENT",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT), iov);
}
/* The parser for the LC_MEASUREMENT section of the locale definition. */
void
measurement_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_measurement_t *measurement;
struct token *now;
struct token *arg;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_MEASUREMENT' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_measurement,
LC_MEASUREMENT, "LC_MEASUREMENT", ignore_content);
return;
}
/* Prepare the data structures. */
measurement_startup (ldfile, result, ignore_content);
measurement = result->categories[LC_MEASUREMENT].measurement;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define INT_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_number) \
goto err_label; \
else if (measurement->cat != 0) \
lr_error (ldfile, _("%s: field `%s' declared more than once"), \
"LC_MEASUREMENT", #cat); \
else if (!ignore_content) \
measurement->cat = arg->val.num; \
break
INT_ELEM (measurement);
case tok_end:
/* Next we assume `LC_MEASUREMENT'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"),
"LC_MEASUREMENT");
else if (arg->tok != tok_lc_measurement)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_MEASUREMENT");
lr_ignore_rest (ldfile, arg->tok == tok_lc_measurement);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_MEASUREMENT");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"),
"LC_MEASUREMENT");
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
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
@ -21,28 +21,18 @@
# include <config.h>
#endif
#include <alloca.h>
#include <langinfo.h>
#include <sys/types.h>
#include <regex.h>
#include <string.h>
#include <libintl.h>
#include <sys/uio.h>
#ifdef HAVE_REGEX
# include <regex.h>
#else
# include <rx.h>
#endif
/* Undefine following line in production version. */
/* #define NDEBUG 1 */
#include <assert.h>
#include "locales.h"
#include "stringtrans.h"
#include "linereader.h"
#include "localedef.h"
#include "localeinfo.h"
extern void *xmalloc (size_t __n);
#include "locfile.h"
/* The real definition of the struct for the LC_MESSAGES locale. */
@ -55,44 +45,51 @@ struct locale_messages_t
};
void
static void
messages_startup (struct linereader *lr, struct localedef_t *locale,
struct charset_t *charset)
int ignore_content)
{
struct locale_messages_t *messages;
if (!ignore_content)
locale->categories[LC_MESSAGES].messages =
(struct locale_messages_t *) xcalloc (1,
sizeof (struct locale_messages_t));
/* We have a definition for LC_MESSAGES. */
copy_posix.mask &= ~(1 << LC_MESSAGES);
/* It is important that we always use UCS1 encoding for strings now. */
encoding_method = ENC_UCS1;
locale->categories[LC_MESSAGES].messages = messages =
(struct locale_messages_t *) xmalloc (sizeof (struct locale_messages_t));
memset (messages, '\0', sizeof (struct locale_messages_t));
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
messages_finish (struct localedef_t *locale)
messages_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_messages_t *messages
= locale->categories[LC_MESSAGES].messages;
/* The fields YESSTR and NOSTR are optional. */
if (messages->yesstr == NULL)
messages->yesstr = "";
if (messages->nostr == NULL)
messages->nostr = "";
if (messages->yesexpr == NULL)
{
if (!be_quiet)
error (0, 0, _("field `%s' in category `%s' undefined"),
"yesexpr", "LC_MESSAGES");
error (0, 0, _("%s: field `%s' undefined"), "LC_MESSAGES", "yesexpr");
messages->yesexpr = "";
}
else if (messages->yesexpr[0] == '\0')
{
if (!be_quiet)
error (0, 0, _("\
%s: value for field `%s' must not be an empty string"),
"LC_MESSAGES", "yesexpr");
}
else
{
int result;
regex_t re;
/* Test whether it is a correct regular expression. */
/* Test whether it are correct regular expressions. */
result = regcomp (&re, messages->yesexpr, REG_EXTENDED);
if (result != 0 && !be_quiet)
{
@ -100,23 +97,32 @@ messages_finish (struct localedef_t *locale)
(void) regerror (result, &re, errbuf, BUFSIZ);
error (0, 0, _("\
no correct regular expression for field `%s' in category `%s': %s"),
"yesexpr", "LC_MESSAGES", errbuf);
%s: no correct regular expression for field `%s': %s"),
"LC_MESSAGES", "yesexpr", errbuf);
}
else if (result != 0)
regfree (&re);
}
if (messages->noexpr == NULL)
{
if (!be_quiet)
error (0, 0, _("field `%s' in category `%s' undefined"),
"noexpr", "LC_MESSAGES");
error (0, 0, _("%s: field `%s' undefined"), "LC_MESSAGES", "noexpr");
messages->noexpr = "";
}
else if (messages->noexpr[0] == '\0')
{
if (!be_quiet)
error (0, 0, _("\
%s: value for field `%s' must not be an empty string"),
"LC_MESSAGES", "noexpr");
}
else
{
int result;
regex_t re;
/* Test whether it is a correct regular expression. */
/* Test whether it are correct regular expressions. */
result = regcomp (&re, messages->noexpr, REG_EXTENDED);
if (result != 0 && !be_quiet)
{
@ -124,33 +130,26 @@ no correct regular expression for field `%s' in category `%s': %s"),
(void) regerror (result, &re, errbuf, BUFSIZ);
error (0, 0, _("\
no correct regular expression for field `%s' in category `%s': %s"),
"noexpr", "LC_MESSAGES", errbuf);
%s: no correct regular expression for field `%s': %s"),
"LC_MESSAGES", "noexpr", errbuf);
}
else if (result != 0)
regfree (&re);
}
}
void
messages_output (struct localedef_t *locale, const char *output_path)
messages_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_messages_t *messages
= locale->categories[LC_MESSAGES].messages;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES)];
struct locale_file data;
u_int32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES)];
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES)];
size_t cnt = 0;
if ((locale->binary & (1 << LC_MESSAGES)) != 0)
{
iov[0].iov_base = messages;
iov[0].iov_len = locale->len[LC_MESSAGES];
write_locale_data (output_path, "LC_MESSAGES", 1, iov);
return;
}
data.magic = LIMAGIC (LC_MESSAGES);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES);
iov[cnt].iov_base = (void *) &data;
@ -162,22 +161,22 @@ messages_output (struct localedef_t *locale, const char *output_path)
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) (messages->yesexpr ?: "");
iov[cnt].iov_base = (char *) messages->yesexpr;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (messages->noexpr ?: "");
iov[cnt].iov_base = (char *) messages->noexpr;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (messages->yesstr ?: "");
iov[cnt].iov_base = (char *) messages->yesstr;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (messages->nostr ?: "");
iov[cnt].iov_base = (char *) messages->nostr;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES));
@ -187,61 +186,112 @@ messages_output (struct localedef_t *locale, const char *output_path)
}
/* The parser for the LC_MESSAGES section of the locale definition. */
void
messages_add (struct linereader *lr, struct localedef_t *locale,
enum token_t tok, struct token *code,
struct charset_t *charset)
messages_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct locale_messages_t *messages
= locale->categories[LC_MESSAGES].messages;
struct repertoire_t *repertoire = NULL;
struct locale_messages_t *messages;
struct token *now;
enum token_t nowtok;
switch (tok)
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_MESSAGES' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
case tok_yesexpr:
if (code->val.str.start == NULL)
{
lr_error (lr, _("unknown character in field `%s' of category `%s'"),
"yesexpr", "LC_MESSAGES");
messages->yesexpr = "";
}
else
messages->yesexpr = code->val.str.start;
break;
case tok_noexpr:
if (code->val.str.start == NULL)
{
lr_error (lr, _("unknown character in field `%s' of category `%s'"),
"noexpr", "LC_MESSAGES");
messages->noexpr = "";
}
else
messages->noexpr = code->val.str.start;
break;
case tok_yesstr:
if (code->val.str.start == NULL)
{
lr_error (lr, _("unknown character in field `%s' of category `%s'"),
"yesstr", "LC_MESSAGES");
messages->yesstr = "";
}
else
messages->yesstr = code->val.str.start;
break;
case tok_nostr:
if (code->val.str.start == NULL)
{
lr_error (lr, _("unknown character in field `%s' of category `%s'"),
"nostr", "LC_MESSAGES");
messages->nostr = "";
}
else
messages->nostr = code->val.str.start;
break;
default:
assert (! "unknown token in category `LC_MESSAGES': should not happen");
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_messages, LC_MESSAGES,
"LC_MESSAGES", ignore_content);
return;
}
/* Prepare the data structures. */
messages_startup (ldfile, result, ignore_content);
messages = result->categories[LC_MESSAGES].messages;
while (1)
{
struct token *arg;
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
if (messages->cat != NULL) \
{ \
lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_MESSAGES", #cat); \
lr_ignore_rest (ldfile, 0); \
break; \
} \
now = lr_token (ldfile, charmap, repertoire); \
if (now->tok != tok_string) \
goto syntax_error; \
else if (!ignore_content && now->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_MESSAGES", #cat); \
messages->cat = ""; \
} \
else if (!ignore_content) \
messages->cat = now->val.str.startmb; \
break
STR_ELEM (yesexpr);
STR_ELEM (noexpr);
STR_ELEM (yesstr);
STR_ELEM (nostr);
case tok_end:
/* Next we assume `LC_MESSAGES'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"), "LC_MESSAGES");
else if (arg->tok != tok_lc_messages)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_MESSAGES");
lr_ignore_rest (ldfile, arg->tok == tok_lc_messages);
return;
default:
syntax_error:
SYNTAX_ERROR (_("%s: syntax error"), "LC_MESSAGES");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_MESSAGES");
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
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
@ -21,26 +21,22 @@
# include <config.h>
#endif
#include <byteswap.h>
#include <langinfo.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <libintl.h>
#include <sys/uio.h>
/* Undefine following line in production version. */
/* #define NDEBUG 1 */
#include <assert.h>
#include "locales.h"
#include "linereader.h"
#include "localedef.h"
#include "localeinfo.h"
#include "stringtrans.h"
extern void *xmalloc (size_t __n);
extern void *xrealloc (void *__ptr, size_t __n);
#include "locfile.h"
/* The real definition of the struct for the LC_NUMERIC locale. */
/* The real definition of the struct for the LC_MONETARY locale. */
struct locale_monetary_t
{
const char *int_curr_symbol;
@ -48,8 +44,7 @@ struct locale_monetary_t
const char *mon_decimal_point;
const char *mon_thousands_sep;
char *mon_grouping;
size_t mon_grouping_max;
size_t mon_grouping_act;
size_t mon_grouping_len;
const char *positive_sign;
const char *negative_sign;
signed char int_frac_digits;
@ -60,10 +55,38 @@ struct locale_monetary_t
signed char n_sep_by_space;
signed char p_sign_posn;
signed char n_sign_posn;
signed char int_p_cs_precedes;
signed char int_p_sep_by_space;
signed char int_n_cs_precedes;
signed char int_n_sep_by_space;
signed char int_p_sign_posn;
signed char int_n_sign_posn;
const char *duo_int_curr_symbol;
const char *duo_currency_symbol;
signed char duo_int_frac_digits;
signed char duo_frac_digits;
signed char duo_p_cs_precedes;
signed char duo_p_sep_by_space;
signed char duo_n_cs_precedes;
signed char duo_n_sep_by_space;
signed char duo_p_sign_posn;
signed char duo_n_sign_posn;
signed char duo_int_p_cs_precedes;
signed char duo_int_p_sep_by_space;
signed char duo_int_n_cs_precedes;
signed char duo_int_n_sep_by_space;
signed char duo_int_p_sign_posn;
signed char duo_int_n_sign_posn;
uint32_t uno_valid_from;
uint32_t uno_valid_to;
uint32_t duo_valid_from;
uint32_t duo_valid_to;
uint32_t conversion_rate[2];
uint32_t conversion_rate_ob[2];
};
/* The contents of the field int_curr_symbol have to be taken from
/* The content iof the field int_curr_symbol has to be taken from
ISO-4217. We test for correct values. */
#define DEFINE_INT_CURR(str) str,
static const char *const valid_int_curr[] =
@ -76,52 +99,73 @@ static const char *const valid_int_curr[] =
/* Prototypes for local functions. */
static int curr_strcmp(const char *s1, const char **s2);
static int curr_strcmp (const char *s1, const char **s2);
void
static void
monetary_startup (struct linereader *lr, struct localedef_t *locale,
struct charset_t *charset)
int ignore_content)
{
struct locale_monetary_t *monetary;
if (!ignore_content)
{
struct locale_monetary_t *monetary;
/* We have a definition for LC_MONETARY. */
copy_posix.mask &= ~(1 << LC_MONETARY);
locale->categories[LC_MONETARY].monetary = monetary =
(struct locale_monetary_t *) xmalloc (sizeof (*monetary));
/* It is important that we always use UCS1 encoding for strings now. */
encoding_method = ENC_UCS1;
memset (monetary, '\0', sizeof (struct locale_monetary_t));
locale->categories[LC_MONETARY].monetary = monetary =
(struct locale_monetary_t *) xmalloc (sizeof (struct locale_monetary_t));
monetary->mon_grouping = NULL;
monetary->mon_grouping_len = 0;
memset (monetary, '\0', sizeof (struct locale_monetary_t));
monetary->int_frac_digits = -2;
monetary->frac_digits = -2;
monetary->p_cs_precedes = -2;
monetary->p_sep_by_space = -2;
monetary->n_cs_precedes = -2;
monetary->n_sep_by_space = -2;
monetary->p_sign_posn = -2;
monetary->n_sign_posn = -2;
monetary->int_p_cs_precedes = -2;
monetary->int_p_sep_by_space = -2;
monetary->int_n_cs_precedes = -2;
monetary->int_n_sep_by_space = -2;
monetary->int_p_sign_posn = -2;
monetary->int_n_sign_posn = -2;
monetary->duo_int_frac_digits = -2;
monetary->duo_frac_digits = -2;
monetary->duo_p_cs_precedes = -2;
monetary->duo_p_sep_by_space = -2;
monetary->duo_n_cs_precedes = -2;
monetary->duo_n_sep_by_space = -2;
monetary->duo_p_sign_posn = -2;
monetary->duo_n_sign_posn = -2;
monetary->duo_int_p_cs_precedes = -2;
monetary->duo_int_p_sep_by_space = -2;
monetary->duo_int_n_cs_precedes = -2;
monetary->duo_int_n_sep_by_space = -2;
monetary->duo_int_p_sign_posn = -2;
monetary->duo_int_n_sign_posn = -2;
}
monetary->mon_grouping_max = 80;
monetary->mon_grouping =
(char *) xmalloc (monetary->mon_grouping_max);
monetary->mon_grouping_act = 0;
monetary->int_frac_digits = -2;
monetary->frac_digits = -2;
monetary->p_cs_precedes = -2;
monetary->p_sep_by_space = -2;
monetary->n_cs_precedes = -2;
monetary->n_sep_by_space = -2;
monetary->p_sign_posn = -2;
monetary->n_sign_posn = -2;
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
monetary_finish (struct localedef_t *locale)
monetary_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_monetary_t *monetary
= locale->categories[LC_MONETARY].monetary;
#define TEST_ELEM(cat) \
#define TEST_ELEM(cat) \
if (monetary->cat == NULL && !be_quiet) \
error (0, 0, _("field `%s' in category `%s' undefined"), \
#cat, "LC_MONETARY")
{ \
error (0, 0, _("%s: field `%s' not defined"), \
"LC_MONETARY", #cat); \
monetary->cat = ""; \
}
TEST_ELEM (int_curr_symbol);
TEST_ELEM (currency_symbol);
@ -133,21 +177,21 @@ monetary_finish (struct localedef_t *locale)
/* The international currency symbol must come from ISO 4217. */
if (monetary->int_curr_symbol != NULL)
{
if (strlen (monetary->int_curr_symbol) != 4
&& monetary->int_curr_symbol[0] != '\0')
if (strlen (monetary->int_curr_symbol) != 4)
{
if (!be_quiet)
error (0, 0, _("\
value of field `int_curr_symbol' in category `LC_MONETARY' has wrong length"));
%s: value of field `int_curr_symbol' has wrong length"),
"LC_MONETARY");
}
else if (monetary->int_curr_symbol[0] != '\0'
&& bsearch (monetary->int_curr_symbol, valid_int_curr,
NR_VALID_INT_CURR, sizeof (const char *),
(comparison_fn_t) curr_strcmp) == NULL
else if (bsearch (monetary->int_curr_symbol, valid_int_curr,
NR_VALID_INT_CURR, sizeof (const char *),
(comparison_fn_t) curr_strcmp) == NULL
&& !be_quiet)
error (0, 0, _("\
value of field `int_curr_symbol' in category `LC_MONETARY' does \
not correspond to a valid name in ISO 4217"));
%s: value of field `int_curr_symbol' does \
not correspond to a valid name in ISO 4217"),
"LC_MONETARY");
}
/* The decimal point must not be empty. This is not said explicitly
@ -156,27 +200,27 @@ not correspond to a valid name in ISO 4217"));
if (monetary->mon_decimal_point[0] == '\0' && !be_quiet)
{
error (0, 0, _("\
value for field `%s' in category `%s' must not be the empty string"),
"mon_decimal_point", "LC_MONETARY");
%s: value for field `%s' must not be the empty string"),
"LC_MONETARY", "mon_decimal_point");
}
if (monetary->mon_grouping_act == 0 && !be_quiet)
error (0, 0, _("field `%s' in category `%s' undefined"),
"mon_grouping", "LC_MONETARY");
if (monetary->mon_grouping_len == 0 && !be_quiet)
error (0, 0, _("%s: field `%s' not defined"),
"LC_MONETARY", "mon_grouping");
#undef TEST_ELEM
#define TEST_ELEM(cat, min, max) \
#define TEST_ELEM(cat, min, max) \
if (monetary->cat == -2 && !be_quiet) \
error (0, 0, _("field `%s' in category `%s' undefined"), \
#cat, "LC_MONETARY"); \
error (0, 0, _("%s: field `%s' not defined"), \
"LC_MONETARY", #cat); \
else if ((monetary->cat < min || monetary->cat > max) && !be_quiet) \
error (0, 0, _("\
value for field `%s' in category `%s' must be in range %d...%d"), \
#cat, "LC_MONETARY", min, max)
%s: value for field `%s' must be in range %d...%d"), \
"LC_MONETARY", #cat, min, max)
#if 0
/* The following two tests are not really necessary because all values
the variable could have are valid. */
/* The following two test are not really necessary because all values
the variable could have are valid. */
TEST_ELEM (int_frac_digits, -128, 127); /* No range check. */
TEST_ELEM (frac_digits, -128, 127); /* No range check. */
#endif
@ -186,29 +230,78 @@ value for field `%s' in category `%s' must be in range %d...%d"), \
TEST_ELEM (n_sep_by_space, -1, 2);
TEST_ELEM (p_sign_posn, -1, 4);
TEST_ELEM (n_sign_posn, -1, 4);
/* The non-POSIX.2 extensions are optional. */
if (monetary->duo_int_curr_symbol == NULL)
monetary->duo_int_curr_symbol = monetary->int_curr_symbol;
if (monetary->duo_currency_symbol == NULL)
monetary->duo_currency_symbol = monetary->currency_symbol;
if (monetary->duo_int_frac_digits == -2)
monetary->duo_int_frac_digits = monetary->int_frac_digits;
if (monetary->duo_frac_digits == -2)
monetary->duo_frac_digits = monetary->frac_digits;
#undef TEST_ELEM
#define TEST_ELEM(cat, alt, min, max) \
if (monetary->cat == -2 && !be_quiet) \
monetary->cat = monetary->alt; \
else if ((monetary->cat < min || monetary->cat > max) && !be_quiet) \
error (0, 0, _("\
%s: value for field `%s' must be in range %d...%d"), \
"LC_MONETARY", #cat, min, max)
TEST_ELEM (int_p_cs_precedes, p_cs_precedes, -1, 1);
TEST_ELEM (int_p_sep_by_space, p_sep_by_space, -1, 2);
TEST_ELEM (int_n_cs_precedes, n_cs_precedes, -1, 1);
TEST_ELEM (int_n_sep_by_space, n_sep_by_space, -1, 2);
TEST_ELEM (int_p_sign_posn, p_sign_posn, -1, 4);
TEST_ELEM (int_n_sign_posn, n_sign_posn, -1, 4);
TEST_ELEM (duo_p_cs_precedes, p_cs_precedes, -1, 1);
TEST_ELEM (duo_p_sep_by_space, p_sep_by_space, -1, 2);
TEST_ELEM (duo_n_cs_precedes, n_cs_precedes, -1, 1);
TEST_ELEM (duo_n_sep_by_space, n_sep_by_space, -1, 2);
TEST_ELEM (duo_int_p_cs_precedes, int_p_cs_precedes, -1, 1);
TEST_ELEM (duo_int_p_sep_by_space, int_p_sep_by_space, -1, 2);
TEST_ELEM (duo_int_n_cs_precedes, int_n_cs_precedes, -1, 1);
TEST_ELEM (duo_int_n_sep_by_space, int_n_sep_by_space, -1, 2);
TEST_ELEM (duo_p_sign_posn, p_sign_posn, -1, 4);
TEST_ELEM (duo_n_sign_posn, n_sign_posn, -1, 4);
TEST_ELEM (duo_int_p_sign_posn, int_p_sign_posn, -1, 4);
TEST_ELEM (duo_int_n_sign_posn, int_n_sign_posn, -1, 4);
if (monetary->uno_valid_from == 0)
monetary->uno_valid_from = 10101;
if (monetary->uno_valid_to == 0)
monetary->uno_valid_to = 99991231;
if (monetary->duo_valid_from == 0)
monetary->duo_valid_from = 10101;
if (monetary->duo_valid_to == 0)
monetary->duo_valid_to = 99991231;
if (monetary->conversion_rate[0] == 0)
{
monetary->conversion_rate[0] = 1;
monetary->conversion_rate[1] = 1;
}
monetary->conversion_rate_ob[0] = bswap_32 (monetary->conversion_rate[0]);
monetary->conversion_rate_ob[1] = bswap_32 (monetary->conversion_rate[1]);
}
void
monetary_output (struct localedef_t *locale, const char *output_path)
monetary_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_monetary_t *monetary
= locale->categories[LC_MONETARY].monetary;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)];
struct locale_file data;
u_int32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)];
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)];
size_t cnt = 0;
if ((locale->binary & (1 << LC_MONETARY)) != 0)
{
iov[0].iov_base = monetary;
iov[0].iov_len = locale->len[LC_MONETARY];
write_locale_data (output_path, "LC_MONETARY", 1, iov);
return;
}
data.magic = LIMAGIC (LC_MONETARY);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY);
iov[cnt].iov_base = (void *) &data;
@ -220,40 +313,37 @@ monetary_output (struct localedef_t *locale, const char *output_path)
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) (monetary->int_curr_symbol ?: "");
iov[cnt].iov_base = (void *) monetary->int_curr_symbol;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (monetary->currency_symbol ?: "");
iov[cnt].iov_base = (void *) monetary->currency_symbol;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (monetary->mon_decimal_point ?: "");
iov[cnt].iov_base = (void *) monetary->mon_decimal_point;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (monetary->mon_thousands_sep ?: "");
iov[cnt].iov_base = (void *) monetary->mon_thousands_sep;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = alloca (monetary->mon_grouping_act + 1);
iov[cnt].iov_len = monetary->mon_grouping_act + 1;
memcpy (iov[cnt].iov_base, monetary->mon_grouping,
monetary->mon_grouping_act);
((char *) iov[cnt].iov_base)[monetary->mon_grouping_act] = '\0';
iov[cnt].iov_base = monetary->mon_grouping;
iov[cnt].iov_len = monetary->mon_grouping_len;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (monetary->positive_sign ?: "");
iov[cnt].iov_base = (void *) monetary->positive_sign;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) (monetary->negative_sign ?: "");
iov[cnt].iov_base = (void *) monetary->negative_sign;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
@ -295,109 +385,422 @@ monetary_output (struct localedef_t *locale, const char *output_path)
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->n_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY));
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->int_p_cs_precedes;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->int_p_sep_by_space;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->int_n_cs_precedes;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->int_n_sep_by_space;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->int_p_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->int_n_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) monetary->duo_int_curr_symbol;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) monetary->duo_currency_symbol;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_frac_digits;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_frac_digits;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_p_cs_precedes;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_p_sep_by_space;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_n_cs_precedes;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_n_sep_by_space;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_p_cs_precedes;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_p_sep_by_space;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_n_cs_precedes;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_n_sep_by_space;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_p_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_n_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_p_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_int_n_sign_posn;
iov[cnt].iov_len = 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->uno_valid_from;
iov[cnt].iov_len = 4;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->uno_valid_to;
iov[cnt].iov_len = 4;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_valid_from;
iov[cnt].iov_len = 4;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->duo_valid_to;
iov[cnt].iov_len = 4;
++cnt;
#if BYTE_ORDER == LITTLE_ENDIAN
# define conversion_rate_el conversion_rate
# define conversion_rate_eb conversion_rate_ob
#else
# define conversion_rate_el conversion_rate_ob
# define conversion_rate_eb conversion_rate
#endif
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->conversion_rate_el;
iov[cnt].iov_len = 8;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) &monetary->conversion_rate_eb;
iov[cnt].iov_len = 8;
++cnt;
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY));
write_locale_data (output_path, "LC_MONETARY",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY), iov);
}
void
monetary_add (struct linereader *lr, struct localedef_t *locale,
enum token_t tok, struct token *code,
struct charset_t *charset)
{
struct locale_monetary_t *monetary
= locale->categories[LC_MONETARY].monetary;
switch (tok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
if (monetary->cat != NULL) \
lr_error (lr, _("\
field `%s' in category `%s' declared more than once"), \
#cat, "LC_MONETARY"); \
else if (code->val.str.start == NULL) \
{ \
lr_error (lr, _("unknown character in field `%s' of category `%s'"),\
#cat, "LC_MONETARY"); \
monetary->cat = ""; \
} \
else \
monetary->cat = code->val.str.start; \
break
STR_ELEM (int_curr_symbol);
STR_ELEM (currency_symbol);
STR_ELEM (mon_decimal_point);
STR_ELEM (mon_thousands_sep);
STR_ELEM (positive_sign);
STR_ELEM (negative_sign);
#define INT_ELEM(cat) \
case tok_##cat: \
if (monetary->cat != -2) \
lr_error (lr, _("\
field `%s' in category `%s' declared more than once"), \
#cat, "LC_MONETARY"); \
else if (code->tok == tok_minus1) \
monetary->cat = -1; \
else \
monetary->cat = code->val.num; \
break
INT_ELEM (int_frac_digits);
INT_ELEM (frac_digits);
INT_ELEM (p_cs_precedes);
INT_ELEM (p_sep_by_space);
INT_ELEM (n_cs_precedes);
INT_ELEM (n_sep_by_space);
INT_ELEM (p_sign_posn);
INT_ELEM (n_sign_posn);
case tok_mon_grouping:
if (monetary->mon_grouping_act == monetary->mon_grouping_max)
{
monetary->mon_grouping_max *= 2;
monetary->mon_grouping =
(char *) xrealloc (monetary->mon_grouping,
monetary->mon_grouping_max);
}
if (monetary->mon_grouping[monetary->mon_grouping_act - 1]
== '\177')
lr_error (lr, _("\
`-1' must be last entry in `%s' field in `%s' category"),
"mon_grouping", "LC_MONETARY");
else
{
if (code->tok == tok_minus1)
monetary->mon_grouping[monetary->mon_grouping_act++] = '\177';
else if (code->val.num == 0)
/* A value of 0 disables grouping from here on but we must
not store a NUL character since this terminates the
string. Use something different which must not be used
otherwise. */
monetary->mon_grouping[monetary->mon_grouping_act++] = '\377';
else if (code->val.num > 126)
lr_error (lr, _("\
values for field `%s' in category `%s' must be smaller than 127"),
"mon_grouping", "LC_MONETARY");
else
monetary->mon_grouping[monetary->mon_grouping_act++]
= code->val.num;
}
break;
default:
assert (! "unknown token in category `LC_MONETARY': should not happen");
}
}
static int
curr_strcmp(const char *s1, const char **s2)
curr_strcmp (const char *s1, const char **s2)
{
return strcmp (s1, *s2);
}
/* The parser for the LC_MONETARY section of the locale definition. */
void
monetary_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_monetary_t *monetary;
struct token *now;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_MONETARY' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_monetary, LC_MONETARY,
"LC_MONETARY", ignore_content);
return;
}
/* Prepare the data structures. */
monetary_startup (ldfile, result, ignore_content);
monetary = result->categories[LC_MONETARY].monetary;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_string) \
goto err_label; \
else if (monetary->cat != NULL) \
lr_error (ldfile, _("%s: field `%s' declared more than once"), \
"LC_MONETARY", #cat); \
else if (!ignore_content && now->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_MONETARY", #cat); \
monetary->cat = ""; \
} \
else if (!ignore_content) \
monetary->cat = now->val.str.startmb; \
lr_ignore_rest (ldfile, 1); \
break
STR_ELEM (int_curr_symbol);
STR_ELEM (currency_symbol);
STR_ELEM (mon_decimal_point);
STR_ELEM (mon_thousands_sep);
STR_ELEM (positive_sign);
STR_ELEM (negative_sign);
STR_ELEM (duo_int_curr_symbol);
STR_ELEM (duo_currency_symbol);
#define INT_ELEM(cat) \
case tok_##cat: \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_minus1 && now->tok != tok_number) \
goto err_label; \
else if (monetary->cat != -2) \
lr_error (ldfile, _("%s: field `%s' declared more than once"), \
"LC_MONETARY", #cat); \
else if (!ignore_content) \
monetary->cat = now->tok == tok_minus1 ? -1 : now->val.num; \
break
INT_ELEM (int_frac_digits);
INT_ELEM (frac_digits);
INT_ELEM (p_cs_precedes);
INT_ELEM (p_sep_by_space);
INT_ELEM (n_cs_precedes);
INT_ELEM (n_sep_by_space);
INT_ELEM (p_sign_posn);
INT_ELEM (n_sign_posn);
INT_ELEM (int_p_cs_precedes);
INT_ELEM (int_p_sep_by_space);
INT_ELEM (int_n_cs_precedes);
INT_ELEM (int_n_sep_by_space);
INT_ELEM (int_p_sign_posn);
INT_ELEM (int_n_sign_posn);
INT_ELEM (duo_int_frac_digits);
INT_ELEM (duo_frac_digits);
INT_ELEM (duo_p_cs_precedes);
INT_ELEM (duo_p_sep_by_space);
INT_ELEM (duo_n_cs_precedes);
INT_ELEM (duo_n_sep_by_space);
INT_ELEM (duo_p_sign_posn);
INT_ELEM (duo_n_sign_posn);
INT_ELEM (duo_int_p_cs_precedes);
INT_ELEM (duo_int_p_sep_by_space);
INT_ELEM (duo_int_n_cs_precedes);
INT_ELEM (duo_int_n_sep_by_space);
INT_ELEM (duo_int_p_sign_posn);
INT_ELEM (duo_int_n_sign_posn);
INT_ELEM (uno_valid_from);
INT_ELEM (uno_valid_to);
INT_ELEM (duo_valid_from);
INT_ELEM (duo_valid_to);
case tok_mon_grouping:
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_minus1 && now->tok != tok_number)
goto err_label;
else
{
size_t act = 0;
size_t max = 10;
char *grouping = ignore_content ? NULL : xmalloc (max);
do
{
if (act + 1 >= max)
{
max *= 2;
grouping = xrealloc (grouping, max);
}
if (act > 0 && grouping[act - 1] == '\177')
{
lr_error (ldfile, _("\
%s: `-1' must be last entry in `%s' field"),
"LC_MONETARY", "mon_grouping");
lr_ignore_rest (ldfile, 0);
break;
}
if (now->tok == tok_minus1)
{
if (!ignore_content)
grouping[act++] = '\177';
}
else if (now->val.num == 0)
{
/* A value of 0 disables grouping from here on but
we must not store a NUL character since this
terminates the string. Use something different
which must not be used otherwise. */
if (!ignore_content)
grouping[act++] = '\377';
}
else if (now->val.num > 126)
lr_error (ldfile, _("\
%s: values for field `%s' must be smaller than 127"),
"LC_MONETARY", "mon_grouping");
else if (!ignore_content)
grouping[act++] = now->val.num;
/* Next must be semicolon. */
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_semicolon)
break;
now = lr_token (ldfile, charmap, NULL);
}
while (now->tok == tok_minus1 || now->tok == tok_number);
if (now->tok != tok_eol)
goto err_label;
if (!ignore_content)
{
grouping[act++] = '\0';
monetary->mon_grouping = xrealloc (grouping, act);
monetary->mon_grouping_len = act;
}
}
break;
case tok_conversion_rate:
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_number)
goto err_label;
if (now->val.num == 0)
{
invalid_conversion_rate:
lr_error (ldfile, _("conversion rate valze cannot be zero"));
if (!ignore_content)
{
monetary->conversion_rate[0] = 1;
monetary->conversion_rate[1] = 1;
}
break;
}
if (!ignore_content)
monetary->conversion_rate[0] = now->val.num;
/* Next must be a semicolon. */
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_semicolon)
goto err_label;
/* And another number. */
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_number)
goto err_label;
if (now->val.num == 0)
goto invalid_conversion_rate;
if (!ignore_content)
monetary->conversion_rate[1] = now->val.num;
/* The rest of the line must be empty. */
lr_ignore_rest (ldfile, 1);
break;
case tok_end:
/* Next we assume `LC_MONETARY'. */
now = lr_token (ldfile, charmap, NULL);
if (now->tok == tok_eof)
break;
if (now->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"), "LC_MONETARY");
else if (now->tok != tok_lc_monetary)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_MONETARY");
lr_ignore_rest (ldfile, now->tok == tok_lc_monetary);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_MONETARY");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_MONETARY");
}

276
locale/programs/ld-name.c Normal file
View File

@ -0,0 +1,276 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <langinfo.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include "localeinfo.h"
#include "locfile.h"
/* The real definition of the struct for the LC_NAME locale. */
struct locale_name_t
{
const char *name_fmt;
const char *name_gen;
const char *name_mr;
const char *name_mrs;
const char *name_miss;
const char *name_ms;
};
static void
name_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
{
if (!ignore_content)
locale->categories[LC_NAME].name =
(struct locale_name_t *) xcalloc (1, sizeof (struct locale_name_t));
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
name_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_name_t *name = locale->categories[LC_NAME].name;
if (name->name_fmt == NULL)
{
error (0, 0, _("%s: field `%s' not defined"), "LC_NAME", "name_fmt");
/* Use as the default value the value of the i18n locale. */
name->name_fmt = "%p%t%g%t%m%t%f";
}
else
{
/* We must check whether the format string contains only the
allowed escape sequences. */
const char *cp = name->name_fmt;
if (*cp == '\0')
error (0, 0, _("%s: field `%s' must not be empty"),
"LC_NAME", "name_fmt");
else
while (*cp != '\0')
{
if (*cp == '%')
{
if (*++cp == 'R')
/* Romanize-flag. */
++cp;
if (strchr ("fFgGlomMpsSt", *cp) == NULL)
{
error (0, 0, _("\
%s: invalid escape sequence in field `%s'"),
"LC_NAME", "name_fmt");
break;
}
}
++cp;
}
}
#define TEST_ELEM(cat) \
if (name->cat == NULL) \
{ \
if (verbose) \
error (0, 0, _("%s: field `%s' not defined"), "LC_NAME", #cat); \
name->cat = ""; \
}
TEST_ELEM (name_gen);
TEST_ELEM (name_mr);
TEST_ELEM (name_mrs);
TEST_ELEM (name_miss);
TEST_ELEM (name_ms);
}
void
name_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_name_t *name = locale->categories[LC_NAME].name;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_NAME)];
size_t cnt = 0;
data.magic = LIMAGIC (LC_NAME);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_NAME);
iov[cnt].iov_base = (void *) &data;
iov[cnt].iov_len = sizeof (data);
++cnt;
iov[cnt].iov_base = (void *) idx;
iov[cnt].iov_len = sizeof (idx);
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) name->name_fmt;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) name->name_gen;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) name->name_mr;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) name->name_mrs;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) name->name_miss;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) name->name_ms;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME));
write_locale_data (output_path, "LC_NAME",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME), iov);
}
/* The parser for the LC_NAME section of the locale definition. */
void
name_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_name_t *name;
struct token *now;
struct token *arg;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_NAME' must be empty. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_name, LC_NAME,
"LC_NAME", ignore_content);
return;
}
/* Prepare the data structures. */
name_startup (ldfile, result, ignore_content);
name = result->categories[LC_NAME].name;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
if (name->cat != NULL) \
lr_error (ldfile, _("%s: field `%s' declared more than once"), \
"LC_NAME", #cat); \
else if (!ignore_content && arg->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("%s: unknown character in field `%s'"), \
"LC_NAME", #cat); \
name->cat = ""; \
} \
else if (!ignore_content) \
name->cat = arg->val.str.startmb; \
break
STR_ELEM (name_fmt);
STR_ELEM (name_gen);
STR_ELEM (name_mr);
STR_ELEM (name_mrs);
STR_ELEM (name_miss);
STR_ELEM (name_ms);
case tok_end:
/* Next we assume `LC_NAME'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"), "LC_NAME");
else if (arg->tok != tok_lc_name)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_NAME");
lr_ignore_rest (ldfile, arg->tok == tok_lc_name);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_NAME");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_NAME");
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
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
@ -21,21 +21,16 @@
# include <config.h>
#endif
#include <alloca.h>
#include <langinfo.h>
#include <string.h>
#include <libintl.h>
#include <sys/uio.h>
/* Undefine following line in production version. */
/* #define NDEBUG 1 */
#include <assert.h>
#include "locales.h"
#include "linereader.h"
#include "localedef.h"
#include "localeinfo.h"
#include "stringtrans.h"
void *xmalloc (size_t __n);
void *xrealloc (void *__ptr, size_t __n);
#include "locfile.h"
/* The real definition of the struct for the LC_NUMERIC locale. */
@ -44,43 +39,38 @@ struct locale_numeric_t
const char *decimal_point;
const char *thousands_sep;
char *grouping;
size_t grouping_max;
size_t grouping_act;
size_t grouping_len;
};
void
static void
numeric_startup (struct linereader *lr, struct localedef_t *locale,
struct charset_t *charset)
int ignore_content)
{
struct locale_numeric_t *numeric;
if (!ignore_content)
{
struct locale_numeric_t *numeric;
/* We have a definition for LC_NUMERIC. */
copy_posix.mask &= ~(1 << LC_NUMERIC);
locale->categories[LC_NUMERIC].numeric = numeric =
(struct locale_numeric_t *) xcalloc (1, sizeof (*numeric));
/* It is important that we always use UCS1 encoding for strings now. */
encoding_method = ENC_UCS1;
numeric->grouping = NULL;
numeric->grouping_len = 0;
}
locale->categories[LC_NUMERIC].numeric = numeric =
(struct locale_numeric_t *) xmalloc (sizeof (struct locale_numeric_t));
memset (numeric, '\0', sizeof (struct locale_numeric_t));
numeric->grouping_max = 80;
numeric->grouping = (char *) xmalloc (numeric->grouping_max);
numeric->grouping_act = 0;
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
numeric_finish (struct localedef_t *locale)
numeric_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric;
#define TEST_ELEM(cat) \
if (numeric->cat == NULL && !be_quiet) \
error (0, 0, _("field `%s' in category `%s' undefined"), \
#cat, "LC_NUMERIC")
error (0, 0, _("%s: field `%s' not defined"), "LC_NUMERIC", #cat)
TEST_ELEM (decimal_point);
TEST_ELEM (thousands_sep);
@ -91,35 +81,25 @@ numeric_finish (struct localedef_t *locale)
if (numeric->decimal_point[0] == '\0' && !be_quiet)
{
error (0, 0, _("\
value for field `%s' in category `%s' must not be the empty string"),
"decimal_point", "LC_NUMERIC");
%s: value for field `%s' must not be the empty string"),
"LC_NUMERIC", "decimal_point");
}
if (numeric->grouping_act == 0 && !be_quiet)
error (0, 0, _("field `%s' in category `%s' undefined"),
"grouping", "LC_NUMERIC");
if (numeric->grouping_len == 0 && !be_quiet)
error (0, 0, _("%s: field `%s' not defined"), "LC_NUMERIC", "grouping");
}
void
numeric_output (struct localedef_t *locale, const char *output_path)
numeric_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)];
struct locale_file data;
u_int32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)];
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)];
size_t cnt = 0;
if ((locale->binary & (1 << LC_NUMERIC)) != 0)
{
iov[0].iov_base = numeric;
iov[0].iov_len = locale->len[LC_NUMERIC];
write_locale_data (output_path, "LC_NUMERIC", 1, iov);
return;
}
data.magic = LIMAGIC (LC_NUMERIC);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC);
iov[cnt].iov_base = (void *) &data;
@ -141,10 +121,8 @@ numeric_output (struct localedef_t *locale, const char *output_path)
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = alloca (numeric->grouping_act + 1);
iov[cnt].iov_len = numeric->grouping_act + 1;
memcpy (iov[cnt].iov_base, numeric->grouping, numeric->grouping_act);
((char *) iov[cnt].iov_base)[numeric->grouping_act] = '\0';
iov[cnt].iov_base = numeric->grouping;
iov[cnt].iov_len = numeric->grouping_len;
assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC));
@ -153,66 +131,173 @@ numeric_output (struct localedef_t *locale, const char *output_path)
}
/* The parser for the LC_NUMERIC section of the locale definition. */
void
numeric_add (struct linereader *lr, struct localedef_t *locale,
enum token_t tok, struct token *code,
struct charset_t *charset)
numeric_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric;
struct repertoire_t *repertoire = NULL;
struct locale_numeric_t *numeric;
struct token *now;
enum token_t nowtok;
switch (tok)
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_NUMERIC' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
#define STR_ELEM(cat) \
case tok_##cat: \
if (numeric->cat != NULL) \
lr_error (lr, _("\
field `%s' in category `%s' declared more than once"), \
#cat, "LC_NUMERIC"); \
else if (code->val.str.start == NULL) \
{ \
lr_error (lr, _("unknown character in field `%s' of category `%s'"),\
#cat, "LC_NUMERIC"); \
numeric->cat = ""; \
} \
else \
numeric->cat = code->val.str.start; \
break
STR_ELEM (decimal_point);
STR_ELEM (thousands_sep);
case tok_grouping:
if (numeric->grouping_act == numeric->grouping_max)
{
numeric->grouping_max *= 2;
numeric->grouping = (char *) xrealloc (numeric->grouping,
numeric->grouping_max);
}
if (numeric->grouping_act > 0
&& (numeric->grouping[numeric->grouping_act - 1] == '\177'))
{
lr_error (lr, _("\
`-1' must be last entry in `%s' field in `%s' category"),
"grouping", "LC_NUMERIC");
--numeric->grouping_act;
}
if (code->tok == tok_minus1)
numeric->grouping[numeric->grouping_act++] = '\177';
else if (code->val.num == 0)
/* A value of 0 disables grouping from here on but we must
not store a NUL character since this terminates the string.
Use something different which must not be used otherwise. */
numeric->grouping[numeric->grouping_act++] = '\377';
else if (code->val.num > 126)
lr_error (lr, _("\
values for field `%s' in category `%s' must be smaller than 127"),
"grouping", "LC_NUMERIC");
else
numeric->grouping[numeric->grouping_act++] = code->val.num;
break;
default:
assert (! "unknown token in category `LC_NUMERIC': should not happen");
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_numeric, LC_NUMERIC,
"LC_NUMERIC", ignore_content);
return;
}
/* Prepare the data structures. */
numeric_startup (ldfile, result, ignore_content);
numeric = result->categories[LC_NUMERIC].numeric;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_string) \
goto err_label; \
if (numeric->cat != NULL) \
lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_NUMERIC", #cat); \
else if (!ignore_content && now->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_NUMERIC", #cat); \
numeric->cat = ""; \
} \
else if (!ignore_content) \
numeric->cat = now->val.str.startmb; \
break
STR_ELEM (decimal_point);
STR_ELEM (thousands_sep);
case tok_grouping:
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_minus1 && now->tok != tok_number)
goto err_label;
else
{
size_t act = 0;
size_t max = 10;
char *grouping = ignore_content ? NULL : xmalloc (max);
do
{
if (act + 1 >= max)
{
max *= 2;
grouping = xrealloc (grouping, max);
}
if (act > 0 && grouping[act - 1] == '\177')
{
lr_error (ldfile, _("\
%s: `-1' must be last entry in `%s' field"), "LC_NUMERIC", "grouping");
lr_ignore_rest (ldfile, 0);
break;
}
if (now->tok == tok_minus1)
{
if (!ignore_content)
grouping[act++] = '\177';
}
else if (now->val.num == 0)
{
/* A value of 0 disables grouping from here on but
we must not store a NUL character since this
terminates the string. Use something different
which must not be used otherwise. */
if (!ignore_content)
grouping[act++] = '\377';
}
else if (now->val.num > 126)
lr_error (ldfile, _("\
%s: values for field `%s' must be smaller than 127"),
"LC_NUMERIC", "grouping");
else if (!ignore_content)
grouping[act++] = now->val.num;
/* Next must be semicolon. */
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_semicolon)
break;
now = lr_token (ldfile, charmap, NULL);
}
while (now->tok == tok_minus1 || now->tok == tok_number);
if (now->tok != tok_eol)
goto err_label;
if (!ignore_content)
{
grouping[act++] = '\0';
numeric->grouping = xrealloc (grouping, act);
numeric->grouping_len = act;
}
}
break;
case tok_end:
/* Next we assume `LC_NUMERIC'. */
now = lr_token (ldfile, charmap, NULL);
if (now->tok == tok_eof)
break;
if (now->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"), "LC_NUMERIC");
else if (now->tok != tok_lc_numeric)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_NUMERIC");
lr_ignore_rest (ldfile, now->tok == tok_lc_numeric);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_NUMERIC");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_NUMERIC");
}

235
locale/programs/ld-paper.c Normal file
View File

@ -0,0 +1,235 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <byteswap.h>
#include <error.h>
#include <langinfo.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include "localeinfo.h"
#include "locfile.h"
/* The real definition of the struct for the LC_PAPER locale. */
struct locale_paper_t
{
uint32_t height;
uint32_t height_ob;
uint32_t width;
uint32_t width_ob;
};
static void
paper_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
{
if (!ignore_content)
locale->categories[LC_PAPER].paper =
(struct locale_paper_t *) xcalloc (1, sizeof (struct locale_paper_t));
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
paper_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_paper_t *paper = locale->categories[LC_PAPER].paper;
if (paper->height == 0)
{
error (0, 0, _("%s: field `%s' not defined"), "LC_PAPER", "height");
/* Use as default values the values from the i18n locale. */
paper->height = 297;
}
paper->height_ob = bswap_32 (paper->height);
if (paper->width == 0)
{
error (0, 0, _("%s: field `%s' not defined"), "LC_PAPER", "width");
/* Use as default values the values from the i18n locale. */
paper->width = 210;
}
paper->width_ob = bswap_32 (paper->width);
}
void
paper_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_paper_t *paper = locale->categories[LC_PAPER].paper;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_PAPER)];
size_t cnt = 0;
data.magic = LIMAGIC (LC_PAPER);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_PAPER);
iov[cnt].iov_base = (void *) &data;
iov[cnt].iov_len = sizeof (data);
++cnt;
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define height_eb height_ob
# define height_el height
# define width_eb width_ob
# define width_el width
#else
# define height_eb height
# define height_el height_ob
# define width_eb width
# define width_el width_ob
#endif
iov[cnt].iov_base = (void *) idx;
iov[cnt].iov_len = sizeof (idx);
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = &paper->height_eb;
iov[cnt].iov_len = 4;
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = &paper->height_el;
iov[cnt].iov_len = 4;
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = &paper->width_eb;
iov[cnt].iov_len = 4;
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = &paper->width_el;
iov[cnt].iov_len = 4;
++cnt;
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER));
write_locale_data (output_path, "LC_PAPER",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER), iov);
}
/* The parser for the LC_PAPER section of the locale definition. */
void
paper_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_paper_t *paper;
struct token *now;
struct token *arg;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_PAPER' must be empty. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_paper, LC_PAPER,
"LC_PAPER", ignore_content);
return;
}
/* Prepare the data structures. */
paper_startup (ldfile, result, ignore_content);
paper = result->categories[LC_PAPER].paper;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define INT_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_number) \
goto err_label; \
else if (paper->cat != 0) \
lr_error (ldfile, _("%s: field `%s' declared more than once"), \
"LC_PAPER", #cat); \
else if (!ignore_content) \
paper->cat = arg->val.num; \
break
INT_ELEM (height);
INT_ELEM (width);
case tok_end:
/* Next we assume `LC_PAPER'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"), "LC_PAPER");
else if (arg->tok != tok_lc_paper)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_PAPER");
lr_ignore_rest (ldfile, arg->tok == tok_lc_paper);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_PAPER");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_PAPER");
}

View File

@ -0,0 +1,283 @@
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <error.h>
#include <langinfo.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include "localeinfo.h"
#include "locfile.h"
/* The real definition of the struct for the LC_TELEPHONE locale. */
struct locale_telephone_t
{
const char *tel_int_fmt;
const char *tel_dom_fmt;
const char *int_select;
const char *int_prefix;
};
static void
telephone_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
{
if (!ignore_content)
locale->categories[LC_TELEPHONE].telephone = (struct locale_telephone_t *)
xcalloc (1, sizeof (struct locale_telephone_t));
lr->translate_strings = 1;
lr->return_widestr = 0;
}
void
telephone_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_telephone_t *telephone =
locale->categories[LC_TELEPHONE].telephone;
if (telephone->tel_int_fmt == NULL)
{
error (0, 0, _("%s: field `%s' not defined"),
"LC_TELEPHONE", "tel_int_fmt");
/* Use as the default value the value of the i18n locale. */
telephone->tel_int_fmt = "+%c %a %l";
}
else
{
/* We must check whether the format string contains only the
allowed escape sequences. */
const char *cp = telephone->tel_int_fmt;
if (*cp == '\0')
error (0, 0, _("%s: field `%s' must not be empty"),
"LC_TELEPHONE", "tel_int_fmt");
else
while (*cp != '\0')
{
if (*cp == '%')
{
if (strchr ("aAlc", *++cp) == NULL)
{
error (0, 0, _("\
%s: invalid escape sequence in field `%s'"),
"LC_TELEPHONE", "tel_int_fmt");
break;
}
}
++cp;
}
}
if (telephone->tel_dom_fmt == NULL)
telephone->tel_dom_fmt = "";
else if (telephone->tel_dom_fmt[0] != '\0')
{
/* We must check whether the format string contains only the
allowed escape sequences. */
const char *cp = telephone->tel_dom_fmt;
while (*cp != '\0')
{
if (*cp == '%')
{
if (strchr ("aAlc", *++cp) == NULL)
{
error (0, 0, _("%s: invalid escape sequence in field `%s'"),
"LC_TELEPHONE", "tel_dom_fmt");
break;
}
}
++cp;
}
}
#define TEST_ELEM(cat) \
if (telephone->cat == NULL) \
{ \
if (verbose) \
error (0, 0, _("%s: field `%s' not defined"), "LC_TELEPHONE", #cat); \
telephone->cat = ""; \
}
TEST_ELEM (int_select);
TEST_ELEM (int_prefix);
}
void
telephone_output (struct localedef_t *locale, struct charmap_t *charmap,
const char *output_path)
{
struct locale_telephone_t *telephone =
locale->categories[LC_TELEPHONE].telephone;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE)];
size_t cnt = 0;
data.magic = LIMAGIC (LC_TELEPHONE);
data.n = _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE);
iov[cnt].iov_base = (void *) &data;
iov[cnt].iov_len = sizeof (data);
++cnt;
iov[cnt].iov_base = (void *) idx;
iov[cnt].iov_len = sizeof (idx);
++cnt;
idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) telephone->tel_int_fmt;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) telephone->tel_dom_fmt;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) telephone->int_select;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
iov[cnt].iov_base = (void *) telephone->int_prefix;
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE));
write_locale_data (output_path, "LC_TELEPHONE",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE), iov);
}
/* The parser for the LC_TELEPHONE section of the locale definition. */
void
telephone_read (struct linereader *ldfile, struct localedef_t *result,
struct charmap_t *charmap, const char *repertoire_name,
int ignore_content)
{
struct repertoire_t *repertoire = NULL;
struct locale_telephone_t *telephone;
struct token *now;
struct token *arg;
enum token_t nowtok;
/* Get the repertoire we have to use. */
if (repertoire_name != NULL)
repertoire = repertoire_read (repertoire_name);
/* The rest of the line containing `LC_TELEPHONE' must be free. */
lr_ignore_rest (ldfile, 1);
do
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
while (nowtok == tok_eol);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
handle_copy (ldfile, charmap, repertoire, tok_lc_telephone, LC_TELEPHONE,
"LC_TELEPHONE", ignore_content);
return;
}
/* Prepare the data structures. */
telephone_startup (ldfile, result, ignore_content);
telephone = result->categories[LC_TELEPHONE].telephone;
while (1)
{
/* Of course we don't proceed beyond the end of file. */
if (nowtok == tok_eof)
break;
/* Ingore empty lines. */
if (nowtok == tok_eol)
{
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
continue;
}
switch (nowtok)
{
#define STR_ELEM(cat) \
case tok_##cat: \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
if (telephone->cat != NULL) \
lr_error (ldfile, _("%s: field `%s' declared more than once"), \
"LC_TELEPHONE", #cat); \
else if (!ignore_content && arg->val.str.startmb == NULL) \
{ \
lr_error (ldfile, _("%s: unknown character in field `%s'"), \
"LC_TELEPHONE", #cat); \
telephone->cat = ""; \
} \
else if (!ignore_content) \
telephone->cat = arg->val.str.startmb; \
break
STR_ELEM (tel_int_fmt);
STR_ELEM (tel_dom_fmt);
STR_ELEM (int_select);
STR_ELEM (int_prefix);
case tok_end:
/* Next we assume `LC_TELEPHONE'. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
if (arg->tok == tok_eol)
lr_error (ldfile, _("%s: incomplete `END' line"), "LC_TELEPHONE");
else if (arg->tok != tok_lc_telephone)
lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_TELEPHONE");
lr_ignore_rest (ldfile, arg->tok == tok_lc_telephone);
return;
default:
err_label:
SYNTAX_ERROR (_("%s: syntax error"), "LC_TELEPHONE");
}
/* Prepare for the next round. */
now = lr_token (ldfile, charmap, NULL);
nowtok = now->tok;
}
/* When we come here we reached the end of the file. */
lr_error (ldfile, _("%s: premature end of file"), "LC_TELEPHONE");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -28,22 +28,20 @@
#include <stdlib.h>
#include <string.h>
#include "charmap.h"
#include "error.h"
#include "linereader.h"
#include "charset.h"
#include "localedef.h"
#include "stringtrans.h"
void *xmalloc (size_t __n);
void *xrealloc (void *__p, size_t __n);
char *xstrdup (const char *__str);
/* Prototypes for local functions. */
static struct token *get_toplvl_escape (struct linereader *lr);
static struct token *get_symname (struct linereader *lr);
static struct token *get_ident (struct linereader *lr);
static struct token *get_string (struct linereader *lr,
const struct charset_t *charset);
const struct charmap_t *charmap,
const struct repertoire_t *repertoire);
struct linereader *
@ -126,9 +124,14 @@ lr_next (struct linereader *lr)
if (n > 1 && lr->buf[n - 2] == lr->escape_char && lr->buf[n - 1] == '\n')
{
#if 0
/* XXX Is this correct? */
/* An escaped newline character is substituted with a single <SP>. */
--n;
lr->buf[n - 1] = ' ';
#else
n -= 2;
#endif
}
lr->buf[n] = '\0';
@ -149,7 +152,8 @@ extern char *program_name;
struct token *
lr_token (struct linereader *lr, const struct charset_t *charset)
lr_token (struct linereader *lr, const struct charmap_t *charmap,
const struct repertoire_t *repertoire)
{
int ch;
@ -193,12 +197,29 @@ lr_token (struct linereader *lr, const struct charset_t *charset)
return get_toplvl_escape (lr);
/* Match ellipsis. */
if (ch == '.' && strncmp (&lr->buf[lr->idx], "..", 2) == 0)
if (ch == '.')
{
lr_getc (lr);
lr_getc (lr);
lr->token.tok = tok_ellipsis;
return &lr->token;
if (strncmp (&lr->buf[lr->idx], "...", 3) == 0)
{
lr_getc (lr);
lr_getc (lr);
lr_getc (lr);
lr->token.tok = tok_ellipsis4;
return &lr->token;
}
if (strncmp (&lr->buf[lr->idx], "..", 2) == 0)
{
lr_getc (lr);
lr_getc (lr);
lr->token.tok = tok_ellipsis3;
return &lr->token;
}
if (lr->buf[lr->idx] == '.')
{
lr_getc (lr);
lr->token.tok = tok_ellipsis2;
return &lr->token;
}
}
switch (ch)
@ -238,7 +259,7 @@ lr_token (struct linereader *lr, const struct charset_t *charset)
return &lr->token;
case '"':
return get_string (lr, charset);
return get_string (lr, charmap, repertoire);
case '-':
ch = lr_getc (lr);
@ -261,7 +282,7 @@ get_toplvl_escape (struct linereader *lr)
/* This is supposed to be a numeric value. We return the
numerical value and the number of bytes. */
size_t start_idx = lr->idx - 1;
unsigned int value = 0;
char *bytes = lr->token.val.charcode.bytes;
int nbytes = 0;
int ch;
@ -287,11 +308,11 @@ get_toplvl_escape (struct linereader *lr)
|| (base != 16 && (ch < '0' || ch >= (int) ('0' + base))))
{
esc_error:
lr->token.val.str.start = &lr->buf[start_idx];
lr->token.val.str.startmb = &lr->buf[start_idx];
while (ch != EOF && !isspace (ch))
ch = lr_getc (lr);
lr->token.val.str.len = lr->idx - start_idx;
lr->token.val.str.lenmb = lr->idx - start_idx;
lr->token.tok = tok_error;
return &lr->token;
@ -300,7 +321,7 @@ get_toplvl_escape (struct linereader *lr)
if (isdigit (ch))
byte = ch - '0';
else
byte = _tolower (ch) - 'a' + 10;
byte = tolower (ch) - 'a' + 10;
ch = lr_getc (lr);
if ((base == 16 && !isxdigit (ch))
@ -311,7 +332,7 @@ get_toplvl_escape (struct linereader *lr)
if (isdigit (ch))
byte += ch - '0';
else
byte += _tolower (ch) - 'a' + 10;
byte += tolower (ch) - 'a' + 10;
ch = lr_getc (lr);
if (base != 16 && isdigit (ch))
@ -322,10 +343,7 @@ get_toplvl_escape (struct linereader *lr)
ch = lr_getc (lr);
}
value *= 256;
value += byte;
++nbytes;
bytes[nbytes++] = byte;
}
while (ch == lr->escape_char && nbytes < 4);
@ -335,23 +353,52 @@ get_toplvl_escape (struct linereader *lr)
lr_ungetn (lr, 1);
lr->token.tok = tok_charcode;
lr->token.val.charcode.val = value;
lr->token.val.charcode.nbytes = nbytes;
return &lr->token;
}
#define ADDC(ch) \
do \
{ \
if (bufact == bufmax) \
{ \
bufmax *= 2; \
buf = xrealloc (buf, bufmax); \
} \
buf[bufact++] = (ch); \
} \
#define ADDC(ch) \
do \
{ \
if (bufact == bufmax) \
{ \
bufmax *= 2; \
buf = xrealloc (buf, bufmax); \
} \
buf[bufact++] = (ch); \
} \
while (0)
#define ADDS(s, l) \
do \
{ \
size_t _l = (l); \
if (bufact + _l > bufmax) \
{ \
if (bufact < _l) \
bufact = _l; \
bufmax *= 2; \
buf = xrealloc (buf, bufmax); \
} \
memcpy (&buf[bufact], s, _l); \
bufact += _l; \
} \
while (0)
#define ADDWC(ch) \
do \
{ \
if (buf2act == buf2max) \
{ \
buf2max *= 2; \
buf2 = xrealloc (buf2, buf2max * 4); \
} \
buf2[buf2act++] = (ch); \
} \
while (0)
@ -399,9 +446,8 @@ get_symname (struct linereader *lr)
if (cp == &buf[bufact - 1])
{
/* Yes, it is. */
lr->token.tok = bufact == 6 ? tok_ucs2 : tok_ucs4;
lr->token.val.charcode.val = strtoul (buf, NULL, 16);
lr->token.val.charcode.nbytes = lr->token.tok == tok_ucs2 ? 2 : 4;
lr->token.tok = tok_ucs4;
lr->token.val.ucs4 = strtoul (buf + 1, NULL, 16);
return &lr->token;
}
@ -422,8 +468,8 @@ get_symname (struct linereader *lr)
buf[bufact] = '\0';
buf = xrealloc (buf, bufact + 1);
lr->token.val.str.start = buf;
lr->token.val.str.len = bufact - 1;
lr->token.val.str.startmb = buf;
lr->token.val.str.lenmb = bufact - 1;
}
return &lr->token;
@ -446,8 +492,18 @@ get_ident (struct linereader *lr)
while (!isspace ((ch = lr_getc (lr))) && ch != '"' && ch != ';'
&& ch != '<' && ch != ',')
/* XXX Handle escape sequences? */
ADDC (ch);
{
if (ch == lr->escape_char)
{
ch = lr_getc (lr);
if (ch == '\n' || ch == EOF)
{
lr_error (lr, _("invalid escape sequence"));
break;
}
}
ADDC (ch);
}
lr_ungetn (lr, 1);
@ -465,8 +521,8 @@ get_ident (struct linereader *lr)
buf[bufact] = '\0';
buf = xrealloc (buf, bufact + 1);
lr->token.val.str.start = buf;
lr->token.val.str.len = bufact;
lr->token.val.str.startmb = buf;
lr->token.val.str.lenmb = bufact;
}
return &lr->token;
@ -474,113 +530,247 @@ get_ident (struct linereader *lr)
static struct token *
get_string (struct linereader *lr, const struct charset_t *charset)
get_string (struct linereader *lr, const struct charmap_t *charmap,
const struct repertoire_t *repertoire)
{
int illegal_string = 0;
char *buf, *cp;
int return_widestr = lr->return_widestr;
char *buf;
char *buf2 = NULL;
size_t bufact;
size_t bufmax = 56;
int ch;
/* We must return two different strings. */
buf = xmalloc (bufmax);
bufact = 0;
while ((ch = lr_getc (lr)) != '"' && ch != '\n' && ch != EOF)
if (ch != '<' || charset == NULL)
{
if (ch == lr->escape_char)
{
ch = lr_getc (lr);
if (ch == '\n' || ch == EOF)
break;
}
ADDC (ch);
}
else
{
/* We have to get the value of the symbol. */
unsigned int value;
size_t startidx = bufact;
if (!lr->translate_strings)
ADDC ('<');
while ((ch = lr_getc (lr)) != '>' && ch != '\n' && ch != EOF)
{
if (ch == lr->escape_char)
{
ch = lr_getc (lr);
if (ch == '\n' || ch == EOF)
break;
}
ADDC (ch);
}
if (ch == '\n' || ch == EOF)
lr_error (lr, _("unterminated string"));
else
if (!lr->translate_strings)
ADDC ('>');
if (lr->translate_strings)
{
value = charset_find_value (&charset->char_table, &buf[startidx],
bufact - startidx);
if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
illegal_string = 1;
bufact = startidx;
if (bufmax - bufact < 8)
{
bufmax *= 2;
buf = (char *) xrealloc (buf, bufmax);
}
cp = &buf[bufact];
if (encode_char (value, &cp))
illegal_string = 1;
bufact = cp - buf;
}
}
/* Catch errors with trailing escape character. */
if (bufact > 0 && buf[bufact - 1] == lr->escape_char
&& (bufact == 1 || buf[bufact - 2] != lr->escape_char))
{
lr_error (lr, _("illegal escape sequence at end of string"));
--bufact;
}
else if (ch == '\n' || ch == EOF)
lr_error (lr, _("unterminated string"));
/* Terminate string if necessary. */
if (lr->translate_strings)
{
cp = &buf[bufact];
if (encode_char (0, &cp))
illegal_string = 1;
bufact = cp - buf;
}
else
ADDC ('\0');
/* We know it'll be a string. */
lr->token.tok = tok_string;
if (illegal_string)
/* If we need not translate the strings (i.e., expand <...> parts)
we can run a simple loop. */
if (!lr->translate_strings)
{
free (buf);
lr->token.val.str.start = NULL;
lr->token.val.str.len = 0;
int ch;
buf2 = NULL;
while ((ch = lr_getc (lr)) != '"' && ch != '\n' && ch != EOF)
ADDC (ch);
/* Catch errors with trailing escape character. */
if (bufact > 0 && buf[bufact - 1] == lr->escape_char
&& (bufact == 1 || buf[bufact - 2] != lr->escape_char))
{
lr_error (lr, _("illegal escape sequence at end of string"));
--bufact;
}
else if (ch == '\n' || ch == EOF)
lr_error (lr, _("unterminated string"));
ADDC ('\0');
}
else
{
buf = xrealloc (buf, bufact + 1);
int illegal_string = 0;
size_t buf2act = 0;
size_t buf2max = 56 * sizeof (uint32_t);
int ch;
int warned = 0;
lr->token.val.str.start = buf;
lr->token.val.str.len = bufact;
/* We have to provide the wide character result as well. */
if (return_widestr)
buf2 = xmalloc (buf2max);
/* Read until the end of the string (or end of the line or file). */
while ((ch = lr_getc (lr)) != '"' && ch != '\n' && ch != EOF)
{
size_t startidx;
uint32_t wch;
struct charseq *seq;
if (ch != '<')
{
/* The standards leave it up to the implementation to decide
what to do with character which stand for themself. We
could jump through hoops to find out the value relative to
the charmap and the repertoire map, but instead we leave
it up to the locale definition author to write a better
definition. We assume here that every character which
stands for itself is encoded using ISO 8859-1. Using the
escape character is allowed. */
if (ch == lr->escape_char)
{
ch = lr_getc (lr);
if (ch == '\n' || ch == EOF)
break;
}
if (verbose && !warned)
{
lr_error (lr, _("\
non-symbolic character value should not be used"));
warned = 1;
}
ADDC (ch);
if (return_widestr)
ADDWC ((uint32_t) ch);
continue;
}
/* Now we have to search for the end of the symbolic name, i.e.,
the closing '>'. */
startidx = bufact;
while ((ch = lr_getc (lr)) != '>' && ch != '\n' && ch != EOF)
{
if (ch == lr->escape_char)
{
ch = lr_getc (lr);
if (ch == '\n' || ch == EOF)
break;
}
ADDC (ch);
}
if (ch == '\n' || ch == EOF)
/* Not a correct string. */
break;
if (bufact == startidx)
{
/* <> is no correct name. Ignore it and also signal an
error. */
illegal_string = 1;
continue;
}
/* It might be a Uxxxx symbol. */
if (buf[startidx] == 'U'
&& (bufact - startidx == 5 || bufact - startidx == 9))
{
char *cp = buf + startidx + 1;
while (cp < &buf[bufact] && isxdigit (*cp))
++cp;
if (cp == &buf[bufact])
{
const char *symbol = NULL;
/* Yes, it is. */
ADDC ('\0');
wch = strtoul (buf + startidx + 1, NULL, 16);
/* Now forget about the name we just added. */
bufact = startidx;
if (return_widestr)
ADDWC (wch);
/* Now determine from the repertoire the name of the
character and find it in the charmap. */
if (repertoire != NULL)
symbol = repertoire_find_symbol (repertoire, wch);
if (symbol == NULL)
{
/* We cannot generate a string since we cannot map
from the Unicode number to the character symbol. */
lr_error (lr,
_("character <U%0*X> not in repertoire map"),
wch > 0xffff ? 8 : 4, wch);
illegal_string = 1;
}
else
{
seq = charmap_find_value (charmap, symbol,
strlen (symbol));
if (seq == NULL)
{
/* Not a known name. */
lr_error (lr,
_("symbol `%s' not in charmap"), symbol);
illegal_string = 1;
}
else
ADDS (seq->bytes, seq->nbytes);
}
continue;
}
}
if (return_widestr)
{
/* We now have the symbolic name in buf[startidx] to
buf[bufact-1]. Now find out the value for this
character in the repertoire map as well as in the
charmap (in this order). */
wch = repertoire_find_value (repertoire, &buf[startidx],
bufact - startidx);
if (wch == ILLEGAL_CHAR_VALUE)
{
/* This name is not in the repertoire map. */
lr_error (lr, _("symbol `%.*s' not in repertoire map"),
bufact - startidx, &buf[startidx]);
illegal_string = 1;
}
else
ADDWC (wch);
}
/* Now the same for the multibyte representation. */
seq = charmap_find_value (charmap, &buf[startidx],
bufact - startidx);
if (seq == NULL)
{
/* This name is not in the charmap. */
lr_error (lr, _("symbol `%.*s' not in charmap"),
bufact - startidx, &buf[startidx]);
illegal_string = 1;
/* Now forget about the name we just added. */
bufact = startidx;
}
else
{
/* Now forget about the name we just added. */
bufact = startidx;
ADDS (seq->bytes, seq->nbytes);
}
}
if (ch == '\n' || ch == EOF)
{
lr_error (lr, _("unterminated string"));
illegal_string = 1;
}
if (illegal_string)
{
free (buf);
if (buf2 != NULL)
free (buf2);
lr->token.val.str.startmb = NULL;
lr->token.val.str.lenmb = 0;
return &lr->token;
}
ADDC ('\0');
if (return_widestr)
{
ADDWC (0);
lr->token.val.str.startwc = xrealloc (buf2,
buf2act * sizeof (uint32_t));
lr->token.val.str.lenwc = buf2act;
}
}
lr->token.val.str.startmb = xrealloc (buf, bufact);
lr->token.val.str.lenmb = bufact;
return &lr->token;
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
Contributed by Ulrich Drepper, <drepper@gnu.org>.
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
@ -22,13 +22,16 @@
#include <ctype.h>
#include <libintl.h>
#include <stdint.h>
#include <stdio.h>
#include "charmap.h"
#include "error.h"
#include "locfile-token.h"
#include "repertoire.h"
typedef const struct keyword_t *(*kw_hash_fct_t) (const char *, int);
typedef const struct keyword_t *(*kw_hash_fct_t) (const char *, unsigned int);
struct charset_t;
@ -39,15 +42,20 @@ struct token
{
struct
{
char *start;
size_t len;
char *startmb;
size_t lenmb;
uint32_t *startwc;
size_t lenwc;
} str;
unsigned long int num;
struct
{
unsigned int val;
/* This element is sized on the safe expectation that no single
character in any character set uses more then 16 bytes. */
unsigned char bytes[16];
int nbytes;
} charcode;
uint32_t ucs4;
} val;
};
@ -69,18 +77,20 @@ struct linereader
struct token token;
int translate_strings;
int return_widestr;
kw_hash_fct_t hash_fct;
};
/* Functions defined in linereader.c. */
struct linereader *lr_open (const char *fname, kw_hash_fct_t hf);
int lr_eof (struct linereader *lr);
void lr_close (struct linereader *lr);
int lr_next (struct linereader *lr);
struct token *lr_token (struct linereader *lr,
const struct charset_t *charset);
extern struct linereader *lr_open (const char *fname, kw_hash_fct_t hf);
extern int lr_eof (struct linereader *lr);
extern void lr_close (struct linereader *lr);
extern int lr_next (struct linereader *lr);
extern struct token *lr_token (struct linereader *lr,
const struct charmap_t *charmap,
const struct repertoire_t *repertoire);
#define lr_error(lr, fmt, args...) \

View File

@ -109,7 +109,7 @@ locale_special (const char *name, int show_category_name,
{
printf ("%s<%s>", first ? "" : ",",
&__collate_symbol_strings[__collate_symbol_hash[2 * cnt]]);
#if 1
#if 0
{
size_t idx = __collate_symbol_hash[2 * cnt + 1];
size_t cls;

View File

@ -1,7 +1,7 @@
/* Implementation of the locale program according to POSIX 9945-2.
Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
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
@ -129,7 +129,7 @@ struct category
/* We have all categories defined in `categories.def'. Now construct
the description and data structure used for all categories. */
#define DEFINE_ELEMENT(Item, More...) { Item, ## More },
#define DEFINE_CATEGORY(category, name, items, postload, in, check, out) \
#define DEFINE_CATEGORY(category, name, items, postload) \
static struct cat_item category##_desc[] = \
{ \
NO_PAREN items \
@ -140,7 +140,7 @@ struct category
static struct category category[] =
{
#define DEFINE_CATEGORY(category, name, items, postload, in, check, out) \
#define DEFINE_CATEGORY(category, name, items, postload) \
[category] = { _NL_NUM_##category, name, NELEMS (category##_desc), \
category##_desc },
#include "categories.def"

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
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
@ -30,26 +30,16 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef _POSIX2_LOCALEDEF
# include <sys/mman.h>
#endif
#include <sys/mman.h>
#include <sys/stat.h>
#include "error.h"
#include "charset.h"
#include "charmap.h"
#include "locfile.h"
#include "locales.h"
/* This is a special entry of the copylist. For all categories we don't
have a definition we use the data for the POSIX locale. */
struct copy_def_list_t copy_posix =
{
next: NULL,
name: "POSIX",
mask: (1 << LC_ALL) - 1,
locale: NULL
};
/* Undefine the following line in the production version. */
/* #define NDEBUG 1 */
#include <assert.h>
/* List of copied locales. */
@ -74,7 +64,10 @@ static const char *charmap_file;
static const char *input_file;
/* Name of the repertoire map file. */
const char *repertoiremap;
const char *repertoire_global;
/* List of all locales. */
static struct localedef_t *locales;
/* Name and version of program. */
@ -88,11 +81,10 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
static const struct argp_option options[] =
{
{ NULL, 0, NULL, 0, N_("Input Files:") },
{ "charmap", 'f', N_("FILE"), 0,
{ "charmap", 'f', "FILE", 0,
N_("Symbolic character names defined in FILE") },
{ "inputfile", 'i', N_("FILE"), 0,
N_("Source definitions are found in FILE") },
{ "repertoire-map", 'u', N_("FILE"), 0,
{ "inputfile", 'i', "FILE", 0, N_("Source definitions are found in FILE") },
{ "repertoire-map", 'u', "FILE", 0,
N_("FILE contains mapping from symbolic names to UCS4 values") },
{ NULL, 0, NULL, 0, N_("Output control:") },
@ -125,7 +117,7 @@ static struct argp argp =
/* Prototypes for global functions. */
void *xmalloc (size_t __n);
extern void *xmalloc (size_t __n);
/* Prototypes for local functions. */
static void error_print (void);
@ -138,12 +130,12 @@ main (int argc, char *argv[])
{
const char *output_path;
int cannot_write_why;
struct charset_t *charset;
struct localedef_t *localedef;
struct copy_def_list_t *act_add_locdef;
struct charmap_t *charmap;
struct localedef_t global;
int remaining;
/* Set initial values for global variables. */
copy_list = NULL;
posix_conformance = getenv ("POSIXLY_CORRECT") != NULL;
error_print_progname = error_print;
@ -187,135 +179,37 @@ main (int argc, char *argv[])
error (3, 0, _("FATAL: system does not define `_POSIX2_LOCALEDEF'"));
/* Process charmap file. */
charset = charmap_read (charmap_file);
charmap = charmap_read (charmap_file);
/* Add the first entry in the locale list. */
memset (&global, '\0', sizeof (struct localedef_t));
global.name = input_file;
global.needed = ALL_LOCALES;
locales = &global;
/* Now read the locale file. */
localedef = locfile_read (input_file, charset);
if (localedef->failed != 0)
if (locfile_read (&global, charmap) != 0)
error (4, errno, _("cannot open locale definition file `%s'"), input_file);
/* Make sure all categories are defined. */
copy_posix.next = copy_list;
copy_list = &copy_posix;
/* Perhaps we saw some `copy' instructions. Process the given list.
We use a very simple algorithm: we look up the list from the
beginning every time. */
do
/* Perhaps we saw some `copy' instructions. */
while (1)
{
int cat = 0;
struct localedef_t *runp = locales;
for (act_add_locdef = copy_list; act_add_locdef != NULL;
act_add_locdef = act_add_locdef->next)
{
for (cat = LC_CTYPE; cat <= LC_MESSAGES; ++cat)
if ((act_add_locdef->mask & (1 << cat)) != 0)
{
act_add_locdef->mask &= ~(1 << cat);
break;
}
if (cat <= LC_MESSAGES)
break;
}
while (runp != NULL && runp->needed == runp->avail)
runp = runp->next;
if (act_add_locdef != NULL)
{
int avail = 0;
if (runp == NULL)
/* Everything read. */
break;
if (act_add_locdef->locale == NULL)
{
/* Saving the mask is an ugly trick to prevent the reader
from modifying `copy_posix' if we currently process it. */
int save_mask = act_add_locdef->mask;
act_add_locdef->locale = locfile_read (act_add_locdef->name,
charset);
act_add_locdef->mask = save_mask;
}
if (! act_add_locdef->locale->failed)
{
avail = act_add_locdef->locale->categories[cat].generic != NULL;
if (avail)
{
localedef->categories[cat].generic
= act_add_locdef->locale->categories[cat].generic;
localedef->avail |= 1 << cat;
}
}
if (! avail)
{
static const char *locale_names[] =
{
"LC_COLLATE", "LC_CTYPE", "LC_MONETARY",
"LC_NUMERIC", "LC_TIME", "LC_MESSAGES"
};
char *fname;
int fd;
struct stat st;
asprintf (&fname, LOCALEDIR "/%s/%s", act_add_locdef->name,
locale_names[cat]);
fd = open (fname, O_RDONLY);
if (fd == -1)
{
free (fname);
asprintf (&fname, LOCALEDIR "/%s/%s/SYS_%s",
act_add_locdef->name, locale_names[cat],
locale_names[cat]);
fd = open (fname, O_RDONLY);
if (fd == -1)
error (5, 0, _("\
locale file `%s', used in `copy' statement, not found"),
act_add_locdef->name);
}
if (fstat (fd, &st) < 0)
error (5, errno, _("\
cannot `stat' locale file `%s'"),
fname);
localedef->len[cat] = st.st_size;
#ifdef _POSIX_MAPPED_FILES
localedef->categories[cat].generic
= mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (localedef->categories[cat].generic == MAP_FAILED)
#endif /* _POSIX_MAPPED_FILES */
{
size_t left = st.st_size;
void *read_ptr;
localedef->categories[cat].generic
= xmalloc (st.st_size);
read_ptr = localedef->categories[cat].generic;
do
{
long int n;
n = read (fd, read_ptr, left);
if (n == -1)
error (5, errno, _("cannot read locale file `%s'"),
fname);
read_ptr += n;
left -= n;
}
while (left > 0);
}
close (fd);
free (fname);
localedef->binary |= 1 << cat;
}
}
if (locfile_read (runp, charmap) != 0)
error (4, errno, _("cannot open locale definition file `%s'"),
runp->name);
}
while (act_add_locdef != NULL);
/* Check the categories we processed in source form. */
check_all_categories (localedef, charset);
check_all_categories (locales, charmap);
/* We are now able to write the data files. If warning were given we
do it only if it is explicitly requested (--force). */
@ -325,7 +219,7 @@ cannot `stat' locale file `%s'"),
error (4, cannot_write_why, _("cannot write output files to `%s'"),
output_path);
else
write_all_categories (localedef, charset, output_path);
write_all_categories (locales, charmap, output_path);
}
else
error (4, 0, _("no output file produced because warning were issued"));
@ -357,7 +251,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
input_file = arg;
break;
case 'u':
repertoiremap = arg;
repertoire_global = arg;
break;
case 'v':
verbose = 1;
@ -406,50 +300,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
}
void
def_to_process (const char *name, int category)
{
struct copy_def_list_t *new, **rp;
for (rp = &copy_list; *rp != NULL; rp = &(*rp)->next)
if (strcmp (name, (*rp)->name) == 0)
break;
if (*rp == NULL)
{
size_t cnt;
*rp = (struct copy_def_list_t *) xmalloc (sizeof (**rp));
(*rp)->next = NULL;
(*rp)->name = name;
(*rp)->mask = 0;
(*rp)->locale = NULL;
for (cnt = 0; cnt < 6; ++cnt)
{
(*rp)->binary[cnt].data = NULL;
(*rp)->binary[cnt].len = 0;
}
}
new = *rp;
if ((new->mask & category) != 0)
/* We already have the information. This cannot happen. */
error (5, 0, _("\
category data requested more than once: should not happen"));
new->mask |= category;
}
/* The address of this function will be assigned to the hook in the error
functions. */
static void
error_print ()
error_print (void)
{
/* We don't want the program name to be printed in messages. Emacs'
compile.el does not like this. */
}
@ -461,13 +316,15 @@ construct_output_path (char *path)
{
const char *normal = NULL;
char *result;
char *endp;
if (strchr (path, '/') == NULL)
{
/* This is a system path. First examine whether the locale name
contains a reference to the codeset. This should be
normalized. */
char *startp, *endp;
char *startp;
size_t n;
startp = path;
/* We must be prepared for finding a CEN name or a location of
@ -493,17 +350,20 @@ construct_output_path (char *path)
the end of the function we need another byte for the trailing
'/'. */
if (normal == NULL)
asprintf (&result, "%s/%s%c", LOCALEDIR, path, '\0');
n = asprintf (&result, "%s/%s%c", LOCALEDIR, path, '\0');
else
asprintf (&result, "%s/%.*s%s%s%c", LOCALEDIR, startp - path, path,
normal, endp, '\0');
n = asprintf (&result, "%s/%.*s%s%s%c", LOCALEDIR, startp - path, path,
normal, endp, '\0');
endp = result + n;
}
else
{
/* This is a user path. Please note the additional byte in the
memory allocation. */
result = xmalloc (strlen (path) + 2);
strcpy (result, path);
size_t len = strlen (path) + 1;
result = xmalloc (len + 1);
endp = mempcpy (result, path, len);
}
errno = 0;
@ -516,11 +376,13 @@ construct_output_path (char *path)
mkdir (result, 0777);
}
strcat (result, "/");
*endp++ = '/';
*endp = '\0';
return result;
}
/* Normalize codeset name. There is no standard for the codeset
names. Normalization allows the user to use any of the common
names. */
@ -555,7 +417,7 @@ normalize_codeset (codeset, name_len)
for (cnt = 0; cnt < name_len; ++cnt)
if (isalpha (codeset[cnt]))
*wp++ = _tolower (codeset[cnt]);
*wp++ = tolower (codeset[cnt]);
else if (isdigit (codeset[cnt]))
*wp++ = codeset[cnt];
@ -564,3 +426,52 @@ normalize_codeset (codeset, name_len)
return (const char *) retval;
}
struct localedef_t *
add_to_readlist (int locale, const char *name, const char *repertoire_name)
{
struct localedef_t *runp = locales;
while (runp != NULL && strcmp (name, runp->name) != 0)
runp = runp->next;
if (runp == NULL)
{
/* Add a new entry at the end. */
struct localedef_t *newp = xcalloc (1, sizeof (struct localedef_t));
newp->name = name;
newp->repertoire_name = repertoire_name;
if (locales == NULL)
runp = locales = newp;
else
{
runp = locales;
while (runp->next != NULL)
runp = runp->next;
runp = runp->next = newp;
}
}
if ((runp->needed & (1 << locale)) != 0)
error (5, 0, _("circular dependencies between locale definitions"));
runp->needed |= 1 << locale;
return runp;
}
struct localedef_t *
find_locale (int locale, const char *name, const char *repertoire_name,
struct charmap_t *charmap)
{
struct localedef_t *result = add_to_readlist (locale, name, repertoire_name);
if (locfile_read (result, charmap) != 0)
error (4, errno, _("cannot open locale definition file `%s'"),
result->name);
return result;
}

131
locale/programs/localedef.h Normal file
View File

@ -0,0 +1,131 @@
/* General definitions for localedef(1).
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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. */
#ifndef _LOCALEDEF_H
#define _LOCALEDEF_H 1
/* Get the basic locale definitions. */
#include <locale.h>
#include <stddef.h>
#include "repertoire.h"
/* We need a bitmask for the locales. */
enum
{
CTYPE_LOCALE = 1 << LC_CTYPE,
NUMERIC_LOCALE = 1 << LC_NUMERIC,
TIME_LOCALE = 1 << LC_TIME,
COLLATE_LOCALE = 1 << LC_COLLATE,
MONETARY_LOCALE = 1 << LC_MONETARY,
MESSAGES_LOCALE = 1 << LC_MESSAGES,
PAPER_LOCALE = 1 << LC_PAPER,
NAME_LOCALE = 1 << LC_NAME,
ADDRESS_LOCALE = 1 << LC_ADDRESS,
TELEPHONE_LOCALE = 1 << LC_TELEPHONE,
MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT,
IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION,
ALL_LOCALES = (1 << LC_CTYPE
| 1 << LC_NUMERIC
| 1 << LC_TIME
| 1 << LC_COLLATE
| 1 << LC_MONETARY
| 1 << LC_MESSAGES
| 1 << LC_PAPER
| 1 << LC_NAME
| 1 << LC_ADDRESS
| 1 << LC_TELEPHONE
| 1 << LC_MEASUREMENT
| 1 << LC_IDENTIFICATION)
};
/* Opaque types for the different locales. */
struct locale_ctype_t;
struct locale_collate_t;
struct locale_monetary_t;
struct locale_numeric_t;
struct locale_time_t;
struct locale_messages_t;
struct locale_paper_t;
struct locale_name_t;
struct locale_address_t;
struct locale_telephone_t;
struct locale_measurement_t;
struct locale_identification_t;
/* Definitions for the locale. */
struct localedef_t
{
struct localedef_t *next;
const char *name;
int needed;
int avail;
union
{
void *generic;
struct locale_ctype_t *ctype;
struct locale_collate_t *collate;
struct locale_monetary_t *monetary;
struct locale_numeric_t *numeric;
struct locale_time_t *time;
struct locale_messages_t *messages;
struct locale_paper_t *paper;
struct locale_name_t *name;
struct locale_address_t *address;
struct locale_telephone_t *telephone;
struct locale_measurement_t *measurement;
struct locale_identification_t *identification;
} categories[12];
size_t len[12];
const char *repertoire_name;
};
/* Global variables of the localedef program. */
extern int verbose;
extern int be_quiet;
extern const char *repertoire_global;
/* Prototypes for a few program-wide used functions. */
extern void *xmalloc (size_t __n);
extern void *xcalloc (size_t __n, size_t __size);
extern void *xrealloc (void *__p, size_t __n);
extern char *xstrdup (const char *__str);
/* Mark given locale as to be read. */
extern struct localedef_t *add_to_readlist (int locale, const char *name,
const char *repertoire_name);
/* Find the information for the locale NAME. */
extern struct localedef_t *find_locale (int locale, const char *name,
const char *repertoire_name,
struct charmap_t *charmap);
#endif /* localedef.h */

View File

@ -1,7 +1,7 @@
%{
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -24,77 +24,175 @@
%}
struct keyword_t ;
%%
escape_char, tok_escape_char, 0
comment_char, tok_comment_char, 0
repertoiremap, tok_repertoiremap, 0
LC_CTYPE, tok_lc_ctype, 0
END, tok_end, 0
copy, tok_copy, 0
upper, tok_upper, 0
lower, tok_lower, 0
alpha, tok_alpha, 0
digit, tok_digit, 0
alnum, tok_alnum, 0
space, tok_space, 0
cntrl, tok_cntrl, 0
punct, tok_punct, 0
graph, tok_graph, 0
print, tok_print, 0
xdigit, tok_xdigit, 0
blank, tok_blank, 0
charclass, tok_charclass, 0
charconv, tok_charconv, 0
toupper, tok_toupper, 0
tolower, tok_tolower, 0
LC_COLLATE, tok_lc_collate, 0
collating-element, tok_collating_element, 0
collating-symbol, tok_collating_symbol, 0
order_start, tok_order_start, 0
order_end, tok_order_end, 0
from, tok_from, 0
forward, tok_forward, 0
backward, tok_backward, 0
position, tok_position, 0
UNDEFINED, tok_undefined, 0
IGNORE, tok_ignore, 0
LC_MONETARY, tok_lc_monetary, 0
int_curr_symbol, tok_int_curr_symbol, 0
currency_symbol, tok_currency_symbol, 0
mon_decimal_point, tok_mon_decimal_point, 0
mon_thousands_sep, tok_mon_thousands_sep, 0
mon_grouping, tok_mon_grouping, 0
positive_sign, tok_positive_sign, 0
negative_sign, tok_negative_sign, 0
int_frac_digits, tok_int_frac_digits, 0
frac_digits, tok_frac_digits, 0
p_cs_precedes, tok_p_cs_precedes, 0
p_sep_by_space, tok_p_sep_by_space, 0
n_cs_precedes, tok_n_cs_precedes, 0
n_sep_by_space, tok_n_sep_by_space, 0
p_sign_posn, tok_p_sign_posn, 0
n_sign_posn, tok_n_sign_posn, 0
LC_NUMERIC, tok_lc_numeric, 0
decimal_point, tok_decimal_point, 0
thousands_sep, tok_thousands_sep, 0
grouping, tok_grouping, 0
LC_TIME, tok_lc_time, 0
abday, tok_abday, 0
day, tok_day, 0
abmon, tok_abmon, 0
mon, tok_mon, 0
d_t_fmt, tok_d_t_fmt, 0
d_fmt, tok_d_fmt, 0
t_fmt, tok_t_fmt, 0
am_pm, tok_am_pm, 0
t_fmt_ampm, tok_t_fmt_ampm, 0
era, tok_era, 0
era_year, tok_era_year, 0
era_d_fmt, tok_era_d_fmt, 0
era_d_t_fmt, tok_era_d_t_fmt, 0
era_t_fmt, tok_era_t_fmt, 0
alt_digits, tok_alt_digits, 0
LC_MESSAGES, tok_lc_messages, 0
yesexpr, tok_yesexpr, 0
noexpr, tok_noexpr, 0
yesstr, tok_yesstr, 0
nostr, tok_nostr, 0
escape_char, tok_escape_char, 0
comment_char, tok_comment_char, 0
repertoiremap, tok_repertoiremap, 0
include, tok_include, 0
LC_CTYPE, tok_lc_ctype, 0
END, tok_end, 0
copy, tok_copy, 0
upper, tok_upper, 0
lower, tok_lower, 0
alpha, tok_alpha, 0
digit, tok_digit, 0
outdigit, tok_outdigit, 0
alnum, tok_alnum, 0
space, tok_space, 0
cntrl, tok_cntrl, 0
punct, tok_punct, 0
graph, tok_graph, 0
print, tok_print, 0
xdigit, tok_xdigit, 0
blank, tok_blank, 0
charclass, tok_charclass, 0
class, tok_class, 0
charconv, tok_charconv, 0
toupper, tok_toupper, 0
tolower, tok_tolower, 0
map, tok_map, 0
translit_start, tok_translit_start, 0
translit_end, tok_translit_end, 0
default_missing, tok_default_missing, 0
LC_COLLATE, tok_lc_collate, 0
coll_weight_max, tok_coll_weight_max, 0
section-symbol, tok_section_symbol, 0
collating-element, tok_collating_element, 0
collating-symbol, tok_collating_symbol, 0
symbol-equivalence, tok_symbol_equivalence, 0
order_start, tok_order_start, 0
order_end, tok_order_end, 0
from, tok_from, 0
forward, tok_forward, 0
backward, tok_backward, 0
position, tok_position, 0
UNDEFINED, tok_undefined, 0
IGNORE, tok_ignore, 0
reorder-after, tok_reorder_after, 0
reorder-end, tok_reorder_end, 0
reorder-sections-after, tok_reorder_sections_after, 0
reorder-sections-end, tok_reorder_sections_end, 0
define, tok_define, 0
undef, tok_undef, 0
ifdef, tok_ifdef, 0
else, tok_else, 0
elif, tok_elif, 0
endif, tok_endif, 0
LC_MONETARY, tok_lc_monetary, 0
int_curr_symbol, tok_int_curr_symbol, 0
currency_symbol, tok_currency_symbol, 0
mon_decimal_point, tok_mon_decimal_point, 0
mon_thousands_sep, tok_mon_thousands_sep, 0
mon_grouping, tok_mon_grouping, 0
positive_sign, tok_positive_sign, 0
negative_sign, tok_negative_sign, 0
int_frac_digits, tok_int_frac_digits, 0
frac_digits, tok_frac_digits, 0
p_cs_precedes, tok_p_cs_precedes, 0
p_sep_by_space, tok_p_sep_by_space, 0
n_cs_precedes, tok_n_cs_precedes, 0
n_sep_by_space, tok_n_sep_by_space, 0
p_sign_posn, tok_p_sign_posn, 0
n_sign_posn, tok_n_sign_posn, 0
int_p_cs_precedes, tok_int_p_cs_precedes, 0
int_p_sep_by_space, tok_int_p_sep_by_space, 0
int_n_cs_precedes, tok_int_n_cs_precedes, 0
int_n_sep_by_space, tok_int_n_sep_by_space, 0
int_p_sign_posn, tok_int_p_sign_posn, 0
int_n_sign_posn, tok_int_n_sign_posn, 0
duo_int_curr_symbol, tok_duo_int_curr_symbol, 0
duo_currency_symbol, tok_duo_currency_symbol, 0
duo_int_frac_digits, tok_duo_int_frac_digits, 0
duo_frac_digits, tok_duo_frac_digits, 0
duo_p_cs_precedes, tok_duo_p_cs_precedes, 0
duo_p_sep_by_space, tok_duo_p_sep_by_space, 0
duo_n_cs_precedes, tok_duo_n_cs_precedes, 0
duo_n_sep_by_space, tok_duo_n_sep_by_space, 0
duo_int_p_cs_precedes, tok_duo_int_p_cs_precedes, 0
duo_int_p_sep_by_space, tok_duo_int_p_sep_by_space, 0
duo_int_n_cs_precedes, tok_duo_int_n_cs_precedes, 0
duo_int_n_sep_by_space, tok_duo_int_n_sep_by_space, 0
duo_p_sign_posn, tok_duo_p_sign_posn, 0
duo_n_sign_posn, tok_duo_n_sign_posn, 0
duo_int_p_sign_posn, tok_duo_int_p_sign_posn, 0
duo_int_n_sign_posn, tok_duo_int_n_sign_posn, 0
uno_valid_from, tok_uno_valid_from, 0
uno_valid_to, tok_uno_valid_to, 0
duo_valid_from, tok_duo_valid_from, 0
duo_valid_to, tok_duo_valid_to, 0
conversion_rate, tok_conversion_rate, 0
LC_NUMERIC, tok_lc_numeric, 0
decimal_point, tok_decimal_point, 0
thousands_sep, tok_thousands_sep, 0
grouping, tok_grouping, 0
LC_TIME, tok_lc_time, 0
abday, tok_abday, 0
day, tok_day, 0
week, tok_week, 0
abmon, tok_abmon, 0
mon, tok_mon, 0
d_t_fmt, tok_d_t_fmt, 0
d_fmt, tok_d_fmt, 0
t_fmt, tok_t_fmt, 0
am_pm, tok_am_pm, 0
t_fmt_ampm, tok_t_fmt_ampm, 0
era, tok_era, 0
era_year, tok_era_year, 0
era_d_fmt, tok_era_d_fmt, 0
era_d_t_fmt, tok_era_d_t_fmt, 0
era_t_fmt, tok_era_t_fmt, 0
alt_digits, tok_alt_digits, 0
first_weekday, tok_first_weekday, 0
first_workday, tok_first_workday, 0
cal_direction, tok_cal_direction, 0
timezone, tok_timezone, 0
LC_MESSAGES, tok_lc_messages, 0
yesexpr, tok_yesexpr, 0
noexpr, tok_noexpr, 0
yesstr, tok_yesstr, 0
nostr, tok_nostr, 0
LC_PAPER, tok_lc_paper, 0
height, tok_height, 0
width, tok_width, 0
LC_NAME, tok_lc_name, 0
name_fmt, tok_name_fmt, 0
name_gen, tok_name_gen, 0
name_mr, tok_name_mr, 0
name_mrs, tok_name_mrs, 0
name_miss, tok_name_miss, 0
name_ms, tok_name_ms, 0
LC_ADDRESS, tok_lc_address, 0
postal_fmt, tok_postal_fmt, 0
country_name, tok_country_name, 0
country_post, tok_country_post, 0
country_ab2, tok_country_ab2, 0
country_ab3, tok_country_ab3, 0
country_num, tok_country_num, 0
country_car, tok_country_car, 0
country_isbn, tok_country_isbn, 0
lang_name, tok_lang_name, 0
lang_ab, tok_lang_ab, 0
lang_term, tok_lang_term, 0
lang_lib, tok_lang_lib, 0
LC_TELEPHONE, tok_lc_telephone, 0
tel_int_fmt, tok_tel_int_fmt, 0
tel_dom_fmt, tok_tel_dom_fmt, 0
int_select, tok_int_select, 0
int_prefix, tok_int_prefix, 0
LC_MEASUREMENT, tok_lc_measurement, 0
measurement, tok_measurement, 0
LC_IDENTIFICATION, tok_lc_identification, 0
title, tok_title, 0
source, tok_source, 0
address, tok_address, 0
contact, tok_contact, 0
email, tok_email, 0
tel, tok_tel, 0
fax, tok_fax, 0
language, tok_language, 0
territory, tok_territory, 0
audience, tok_audience, 0
application, tok_application, 0
abbreviation, tok_abbreviation, 0
revision, tok_revision, 0
date, tok_date, 0
category, tok_category, 0

View File

@ -1,8 +1,8 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: gperf -acCgopt -k1,2,5,$ -N locfile_hash programs/locfile-kw.gperf */
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
/* ANSI-C code produced by gperf version 2.7.1 (19981006 egcs) */
/* Command-line: gperf -acCgopt -k1,2,5,9,$ -L ANSI-C -N locfile_hash programs/locfile-kw.gperf */
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -24,174 +24,368 @@
#include "locfile-token.h"
struct keyword_t ;
#define TOTAL_KEYWORDS 74
#define TOTAL_KEYWORDS 172
#define MIN_WORD_LENGTH 3
#define MAX_WORD_LENGTH 17
#define MAX_WORD_LENGTH 22
#define MIN_HASH_VALUE 3
#define MAX_HASH_VALUE 178
/* maximum key range = 176, duplicates = 0 */
#define MAX_HASH_VALUE 545
/* maximum key range = 543, duplicates = 0 */
#ifdef __GNUC__
inline
__inline
#endif
static unsigned int
hash (register const char *str, register int len)
hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
static const unsigned short asso_values[] =
{
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 0, 0, 0,
0, 0, 179, 0, 179, 179, 0, 179, 0, 45,
179, 179, 0, 0, 0, 5, 179, 179, 179, 10,
179, 179, 179, 179, 179, 5, 179, 0, 5, 0,
15, 20, 5, 20, 40, 20, 179, 25, 15, 50,
10, 0, 0, 179, 45, 50, 0, 30, 0, 5,
10, 60, 179, 179, 179, 179, 179, 179,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
5, 0, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 20, 546, 0, 0, 0,
5, 30, 0, 0, 546, 546, 0, 546, 0, 0,
546, 546, 10, 0, 5, 10, 546, 546, 546, 0,
546, 546, 546, 546, 546, 30, 546, 0, 10, 125,
5, 0, 105, 30, 5, 95, 546, 0, 105, 155,
135, 50, 75, 0, 5, 45, 0, 55, 0, 30,
25, 25, 10, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546, 546, 546, 546, 546,
546, 546, 546, 546, 546, 546
};
register int hval = len;
switch (hval)
{
default:
case 9:
hval += asso_values[(unsigned char)str[8]];
case 8:
case 7:
case 6:
case 5:
hval += asso_values[str[4]];
hval += asso_values[(unsigned char)str[4]];
case 4:
case 3:
case 2:
hval += asso_values[str[1]];
hval += asso_values[(unsigned char)str[1]];
case 1:
hval += asso_values[str[0]];
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval + asso_values[str[len - 1]];
return hval + asso_values[(unsigned char)str[len - 1]];
}
#ifdef __GNUC__
inline
__inline
#endif
const struct keyword_t *
locfile_hash (register const char *str, register int len)
locfile_hash (register const char *str, register unsigned int len)
{
static const struct keyword_t wordlist[] =
{
{"",}, {"",}, {"",},
{"END", tok_end, 0},
{"",}, {"",},
{"IGNORE", tok_ignore, 0},
{"LC_TIME", tok_lc_time, 0},
{"LC_CTYPE", tok_lc_ctype, 0},
{"",},
{"t_fmt", tok_t_fmt, 0},
{"LC_MESSAGES", tok_lc_messages, 0},
{"",}, {"",},
{"UNDEFINED", tok_undefined, 0},
{"LC_NUMERIC", tok_lc_numeric, 0},
{"",},
{"collating-element", tok_collating_element, 0},
{"position", tok_position, 0},
{"",},
{"alpha", tok_alpha, 0},
{"",}, {"",},
{"positive_sign", tok_positive_sign, 0},
{"",},
{"d_fmt", tok_d_fmt, 0},
{"",},
{"forward", tok_forward, 0},
{"",}, {"",},
{"abmon", tok_abmon, 0},
{"collating-symbol", tok_collating_symbol, 0},
{"d_t_fmt", tok_d_t_fmt, 0},
{"backward", tok_backward, 0},
{"",},
{"punct", tok_punct, 0},
{"",}, {"",}, {"",},
{"p_sep_by_space", tok_p_sep_by_space, 0},
{"digit", tok_digit, 0},
{"",}, {"",}, {"",}, {"",},
{"cntrl", tok_cntrl, 0},
{"p_sign_posn", tok_p_sign_posn, 0},
{"",},
{"charconv", tok_charconv, 0},
{"n_sep_by_space", tok_n_sep_by_space, 0},
{"print", tok_print, 0},
{"xdigit", tok_xdigit, 0},
{"toupper", tok_toupper, 0},
{"negative_sign", tok_negative_sign, 0},
{"",},
{"LC_COLLATE", tok_lc_collate, 0},
{"n_sign_posn", tok_n_sign_posn, 0},
{"tolower", tok_tolower, 0},
{"",}, {"",},
{"int_curr_symbol", tok_int_curr_symbol, 0},
{"noexpr", tok_noexpr, 0},
{"",},
{"mon", tok_mon, 0},
{"copy", tok_copy, 0},
{"t_fmt_ampm", tok_t_fmt_ampm, 0},
{"LC_MONETARY", tok_lc_monetary, 0},
{"mon_thousands_sep", tok_mon_thousands_sep, 0},
{"era", tok_era, 0},
{"",}, {"",}, {"",}, {"",},
{"p_cs_precedes", tok_p_cs_precedes, 0},
{"era_t_fmt", tok_era_t_fmt, 0},
{"blank", tok_blank, 0},
{"",},
{"comment_char", tok_comment_char, 0},
{"day", tok_day, 0},
{"",},
{"currency_symbol", tok_currency_symbol, 0},
{"",},
{"mon_decimal_point", tok_mon_decimal_point, 0},
{"n_cs_precedes", tok_n_cs_precedes, 0},
{"",}, {"",}, {"",}, {"",}, {"",},
{"era_d_fmt", tok_era_d_fmt, 0},
{"alt_digits", tok_alt_digits, 0},
{"era_d_t_fmt", tok_era_d_t_fmt, 0},
{"",},
{"grouping", tok_grouping, 0},
{"",},
{"space", tok_space, 0},
{"",}, {"",},
{"decimal_point", tok_decimal_point, 0},
{"charclass", tok_charclass, 0},
{"int_frac_digits", tok_int_frac_digits, 0},
{"order_start", tok_order_start, 0},
{"mon_grouping", tok_mon_grouping, 0},
{"thousands_sep", tok_thousands_sep, 0},
{"from", tok_from, 0},
{"nostr", tok_nostr, 0},
{"",}, {"",}, {"",}, {"",},
{"lower", tok_lower, 0},
{"",}, {"",}, {"",},
{"order_end", tok_order_end, 0},
{"",},
{"frac_digits", tok_frac_digits, 0},
{"",}, {"",}, {"",},
{"alnum", tok_alnum, 0},
{"",}, {"",},
{"repertoiremap", tok_repertoiremap, 0},
{"",},
{"upper", tok_upper, 0},
{"escape_char", tok_escape_char, 0},
{"",}, {"",}, {"",},
{"abday", tok_abday, 0},
{"yesstr", tok_yesstr, 0},
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"",},
{"yesexpr", tok_yesexpr, 0},
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"graph", tok_graph, 0},
{"",}, {"",}, {"",}, {"",},
{"am_pm", tok_am_pm, 0},
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"",}, {"",}, {"",}, {"",},
{"era_year", tok_era_year, 0},
{""}, {""}, {""},
{"END", tok_end, 0},
{""}, {""}, {""},
{"LC_TIME", tok_lc_time, 0},
{"era", tok_era, 0},
{"date", tok_date, 0},
{"LC_ADDRESS", tok_lc_address, 0},
{""},
{"LC_TELEPHONE", tok_lc_telephone, 0},
{"LC_CTYPE", tok_lc_ctype, 0},
{"era_t_fmt", tok_era_t_fmt, 0},
{"LC_COLLATE", tok_lc_collate, 0},
{"height", tok_height, 0},
{"LC_IDENTIFICATION", tok_lc_identification, 0},
{""},
{"era_d_fmt", tok_era_d_fmt, 0},
{"LC_NUMERIC", tok_lc_numeric, 0},
{""}, {""}, {""},
{"UNDEFINED", tok_undefined, 0},
{""},
{"reorder-end", tok_reorder_end, 0},
{"LC_NAME", tok_lc_name, 0},
{"reorder-after", tok_reorder_after, 0},
{"LC_MEASUREMENT", tok_lc_measurement, 0},
{""},
{"LC_MONETARY", tok_lc_monetary, 0},
{""},
{"day", tok_day, 0},
{"week", tok_week, 0},
{"t_fmt", tok_t_fmt, 0},
{"yesstr", tok_yesstr, 0},
{""},
{"LC_PAPER", tok_lc_paper, 0},
{""},
{"d_fmt", tok_d_fmt, 0},
{"LC_MESSAGES", tok_lc_messages, 0},
{""},
{"era_year", tok_era_year, 0},
{""}, {""},
{"IGNORE", tok_ignore, 0},
{""}, {""}, {""},
{"graph", tok_graph, 0},
{""}, {""},
{"backward", tok_backward, 0},
{""}, {""}, {""},
{"address", tok_address, 0},
{""}, {""}, {""}, {""},
{"yesexpr", tok_yesexpr, 0},
{"audience", tok_audience, 0},
{""},
{"abday", tok_abday, 0},
{""}, {""}, {""}, {""}, {""},
{"order_start", tok_order_start, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
{"order_end", tok_order_end, 0},
{"reorder-sections-end", tok_reorder_sections_end, 0},
{""},
{"reorder-sections-after", tok_reorder_sections_after, 0},
{""}, {""},
{"print", tok_print, 0},
{""}, {""}, {""}, {""}, {""}, {""},
{"tolower", tok_tolower, 0},
{""},
{"translit_start", tok_translit_start, 0},
{""}, {""},
{"translit_end", tok_translit_end, 0},
{""}, {""},
{"title", tok_title, 0},
{""}, {""},
{"repertoiremap", tok_repertoiremap, 0},
{""},
{"digit", tok_digit, 0},
{""}, {""},
{"tel", tok_tel, 0},
{"else", tok_else, 0},
{"alpha", tok_alpha, 0},
{""}, {""},
{"timezone", tok_timezone, 0},
{""}, {""}, {""}, {""}, {""}, {""},
{"blank", tok_blank, 0},
{"tel_dom_fmt", tok_tel_dom_fmt, 0},
{""}, {""}, {""},
{"space", tok_space, 0},
{"era_d_t_fmt", tok_era_d_t_fmt, 0},
{"duo_valid_to", tok_duo_valid_to, 0},
{""}, {""}, {""},
{"xdigit", tok_xdigit, 0},
{""},
{"fax", tok_fax, 0},
{""},
{"punct", tok_punct, 0},
{""},
{"toupper", tok_toupper, 0},
{"symbol-equivalence", tok_symbol_equivalence, 0},
{""},
{"width", tok_width, 0},
{"escape_char", tok_escape_char, 0},
{""}, {""},
{"lang_name", tok_lang_name, 0},
{"upper", tok_upper, 0},
{"define", tok_define, 0},
{"d_t_fmt", tok_d_t_fmt, 0},
{"grouping", tok_grouping, 0},
{""}, {""}, {""},
{"lang_ab", tok_lang_ab, 0},
{"lang_lib", tok_lang_lib, 0},
{"territory", tok_territory, 0},
{""}, {""},
{"abbreviation", tok_abbreviation, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
{"alt_digits", tok_alt_digits, 0},
{""},
{"forward", tok_forward, 0},
{"language", tok_language, 0},
{""},
{"lower", tok_lower, 0},
{""}, {""},
{"name_fmt", tok_name_fmt, 0},
{""}, {""}, {""},
{"name_mr", tok_name_mr, 0},
{""}, {""}, {""}, {""},
{"contact", tok_contact, 0},
{"thousands_sep", tok_thousands_sep, 0},
{""}, {""},
{"country_ab3", tok_country_ab3, 0},
{""},
{"category", tok_category, 0},
{""}, {""},
{"country_ab2", tok_country_ab2, 0},
{""},
{"revision", tok_revision, 0},
{""}, {""}, {""}, {""}, {""}, {""},
{"nostr", tok_nostr, 0},
{""}, {""}, {""},
{"copy", tok_copy, 0},
{""}, {""}, {""},
{"outdigit", tok_outdigit, 0},
{""}, {""},
{"tel_int_fmt", tok_tel_int_fmt, 0},
{""}, {""},
{"elif", tok_elif, 0},
{""}, {""},
{"name_ms", tok_name_ms, 0},
{"name_mrs", tok_name_mrs, 0},
{""}, {""},
{"measurement", tok_measurement, 0},
{"collating-element", tok_collating_element, 0},
{""},
{"p_sep_by_space", tok_p_sep_by_space, 0},
{""},
{"source", tok_source, 0},
{"duo_p_cs_precedes", tok_duo_p_cs_precedes, 0},
{"duo_p_sep_by_space", tok_duo_p_sep_by_space, 0},
{""}, {""}, {""}, {""},
{"map", tok_map, 0},
{"duo_valid_from", tok_duo_valid_from, 0},
{""}, {""}, {""},
{"first_weekday", tok_first_weekday, 0},
{""},
{"conversion_rate", tok_conversion_rate, 0},
{""}, {""},
{"first_workday", tok_first_workday, 0},
{""}, {""}, {""}, {""},
{"decimal_point", tok_decimal_point, 0},
{""}, {""}, {""},
{"duo_int_p_sep_by_space", tok_duo_int_p_sep_by_space, 0},
{""}, {""},
{"duo_frac_digits", tok_duo_frac_digits, 0},
{""},
{"uno_valid_to", tok_uno_valid_to, 0},
{""}, {""},
{"default_missing", tok_default_missing, 0},
{""},
{"country_post", tok_country_post, 0},
{"charconv", tok_charconv, 0},
{"name_miss", tok_name_miss, 0},
{""}, {""}, {""},
{"position", tok_position, 0},
{"from", tok_from, 0},
{"t_fmt_ampm", tok_t_fmt_ampm, 0},
{"noexpr", tok_noexpr, 0},
{""}, {""}, {""},
{"coll_weight_max", tok_coll_weight_max, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{"n_sep_by_space", tok_n_sep_by_space, 0},
{"abmon", tok_abmon, 0},
{""},
{"duo_n_cs_precedes", tok_duo_n_cs_precedes, 0},
{"duo_n_sep_by_space", tok_duo_n_sep_by_space, 0},
{""},
{"postal_fmt", tok_postal_fmt, 0},
{"frac_digits", tok_frac_digits, 0},
{"include", tok_include, 0},
{""}, {""}, {""},
{"duo_int_p_cs_precedes", tok_duo_int_p_cs_precedes, 0},
{""}, {""}, {""}, {""}, {""}, {""},
{"positive_sign", tok_positive_sign, 0},
{"section-symbol", tok_section_symbol, 0},
{""}, {""}, {""},
{"name_gen", tok_name_gen, 0},
{"duo_currency_symbol", tok_duo_currency_symbol, 0},
{""}, {""},
{"duo_int_n_sep_by_space", tok_duo_int_n_sep_by_space, 0},
{"negative_sign", tok_negative_sign, 0},
{""},
{"duo_p_sign_posn", tok_duo_p_sign_posn, 0},
{"country_car", tok_country_car, 0},
{"comment_char", tok_comment_char, 0},
{"p_cs_precedes", tok_p_cs_precedes, 0},
{""}, {""}, {""},
{"country_name", tok_country_name, 0},
{""},
{"duo_int_frac_digits", tok_duo_int_frac_digits, 0},
{"class", tok_class, 0},
{"collating-symbol", tok_collating_symbol, 0},
{""}, {""}, {""},
{"currency_symbol", tok_currency_symbol, 0},
{"p_sign_posn", tok_p_sign_posn, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
{"mon_thousands_sep", tok_mon_thousands_sep, 0},
{"mon", tok_mon, 0},
{""}, {""}, {""}, {""}, {""}, {""},
{"endif", tok_endif, 0},
{""},
{"mon_grouping", tok_mon_grouping, 0},
{""},
{"charclass", tok_charclass, 0},
{""},
{"duo_int_n_cs_precedes", tok_duo_int_n_cs_precedes, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
{"uno_valid_from", tok_uno_valid_from, 0},
{""}, {""}, {""}, {""}, {""},
{"email", tok_email, 0},
{""}, {""}, {""}, {""},
{"duo_n_sign_posn", tok_duo_n_sign_posn, 0},
{""}, {""},
{"n_cs_precedes", tok_n_cs_precedes, 0},
{""}, {""}, {""},
{"mon_decimal_point", tok_mon_decimal_point, 0},
{""},
{"duo_int_p_sign_posn", tok_duo_int_p_sign_posn, 0},
{""}, {""}, {""}, {""}, {""}, {""},
{"n_sign_posn", tok_n_sign_posn, 0},
{""}, {""}, {""}, {""}, {""},
{"int_p_cs_precedes", tok_int_p_cs_precedes, 0},
{"int_p_sep_by_space", tok_int_p_sep_by_space, 0},
{""}, {""}, {""}, {""},
{"cal_direction", tok_cal_direction, 0},
{"duo_int_curr_symbol", tok_duo_int_curr_symbol, 0},
{"undef", tok_undef, 0},
{""}, {""}, {""}, {""},
{"int_select", tok_int_select, 0},
{"application", tok_application, 0},
{""}, {""}, {""},
{"ifdef", tok_ifdef, 0},
{""},
{"country_isbn", tok_country_isbn, 0},
{""}, {""},
{"alnum", tok_alnum, 0},
{""}, {""}, {""}, {""},
{"int_frac_digits", tok_int_frac_digits, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{"int_prefix", tok_int_prefix, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{"duo_int_n_sign_posn", tok_duo_int_n_sign_posn, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{"lang_term", tok_lang_term, 0},
{""}, {""},
{"int_n_cs_precedes", tok_int_n_cs_precedes, 0},
{"int_n_sep_by_space", tok_int_n_sep_by_space, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
{"am_pm", tok_am_pm, 0},
{""}, {""}, {""}, {""},
{"cntrl", tok_cntrl, 0},
{"country_num", tok_country_num, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{"int_p_sign_posn", tok_int_p_sign_posn, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
{"int_curr_symbol", tok_int_curr_symbol, 0},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
{"int_n_sign_posn", tok_int_n_sign_posn, 0}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@ -202,7 +396,7 @@ locfile_hash (register const char *str, register int len)
{
register const char *s = wordlist[key].name;
if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
return &wordlist[key];
}
}

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -28,17 +28,19 @@ enum token_t
tok_eol,
tok_bsymbol,
tok_ident,
tok_ellipsis,
tok_ellipsis2,
tok_ellipsis3,
tok_ellipsis4,
tok_semicolon,
tok_comma,
tok_open_brace,
tok_close_brace,
tok_charcode,
tok_ucs2,
tok_ucs4,
tok_number,
tok_minus1,
tok_string,
tok_include,
tok_escape_char,
tok_comment_char,
@ -48,6 +50,8 @@ enum token_t
tok_g1esc,
tok_g2esc,
tok_g3esc,
tok_escseq,
tok_addset,
tok_charids,
@ -62,6 +66,7 @@ enum token_t
tok_lc_ctype,
tok_copy,
/* Keep the following entries up to the next comment in this order! */
tok_upper,
tok_lower,
tok_alpha,
@ -74,12 +79,22 @@ enum token_t
tok_cntrl,
tok_punct,
tok_alnum,
/* OK, shuffling allowed again. */
tok_outdigit,
tok_charclass,
tok_class,
tok_toupper,
tok_tolower,
tok_map,
tok_translit_start,
tok_translit_end,
tok_default_missing,
tok_lc_collate,
tok_coll_weight_max,
tok_section_symbol,
tok_collating_element,
tok_collating_symbol,
tok_symbol_equivalence,
tok_order_start,
tok_order_end,
tok_from,
@ -88,6 +103,17 @@ enum token_t
tok_position,
tok_undefined,
tok_ignore,
tok_reorder_after,
tok_reorder_end,
tok_reorder_sections_after,
tok_reorder_sections_end,
tok_define,
tok_undef,
tok_ifdef,
tok_ifndef,
tok_else,
tok_elif,
tok_endif,
tok_lc_monetary,
tok_int_curr_symbol,
tok_currency_symbol,
@ -104,6 +130,33 @@ enum token_t
tok_n_sep_by_space,
tok_p_sign_posn,
tok_n_sign_posn,
tok_int_p_cs_precedes,
tok_int_p_sep_by_space,
tok_int_n_cs_precedes,
tok_int_n_sep_by_space,
tok_int_p_sign_posn,
tok_int_n_sign_posn,
tok_duo_int_curr_symbol,
tok_duo_currency_symbol,
tok_duo_int_frac_digits,
tok_duo_frac_digits,
tok_duo_p_cs_precedes,
tok_duo_p_sep_by_space,
tok_duo_n_cs_precedes,
tok_duo_n_sep_by_space,
tok_duo_int_p_cs_precedes,
tok_duo_int_p_sep_by_space,
tok_duo_int_n_cs_precedes,
tok_duo_int_n_sep_by_space,
tok_duo_p_sign_posn,
tok_duo_n_sign_posn,
tok_duo_int_p_sign_posn,
tok_duo_int_n_sign_posn,
tok_uno_valid_from,
tok_uno_valid_to,
tok_duo_valid_from,
tok_duo_valid_to,
tok_conversion_rate,
tok_lc_numeric,
tok_decimal_point,
tok_thousands_sep,
@ -124,11 +177,61 @@ enum token_t
tok_era_d_t_fmt,
tok_era_t_fmt,
tok_alt_digits,
tok_week,
tok_first_weekday,
tok_first_workday,
tok_cal_direction,
tok_timezone,
tok_lc_messages,
tok_yesexpr,
tok_noexpr,
tok_yesstr,
tok_nostr,
tok_lc_paper,
tok_height,
tok_lc_name,
tok_name_fmt,
tok_name_gen,
tok_name_mr,
tok_name_mrs,
tok_name_miss,
tok_name_ms,
tok_lc_address,
tok_postal_fmt,
tok_country_name,
tok_country_post,
tok_country_ab2,
tok_country_ab3,
tok_country_num,
tok_country_car,
tok_country_isbn,
tok_lang_name,
tok_lang_ab,
tok_lang_term,
tok_lang_lib,
tok_lc_telephone,
tok_tel_int_fmt,
tok_tel_dom_fmt,
tok_int_select,
tok_int_prefix,
tok_lc_measurement,
tok_measurement,
tok_lc_identification,
tok_title,
tok_source,
tok_address,
tok_contact,
tok_email,
tok_tel,
tok_fax,
tok_language,
tok_territory,
tok_audience,
tok_application,
tok_abbreviation,
tok_revision,
tok_date,
tok_category,
tok_error
};

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
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
@ -18,61 +18,241 @@
Boston, MA 02111-1307, USA. */
#ifndef _LOCFILE_H
#define _LOCFILE_H
#define _LOCFILE_H 1
#include <sys/uio.h>
#include "charset.h"
#include "linereader.h"
#include "localedef.h"
/* Opaque types for the different locales. */
struct locale_ctype_t;
struct locale_collate_t;
struct locale_monetary_t;
struct locale_numeric_t;
struct locale_time_t;
struct locale_messages_t;
struct localedef_t
/* Header of the locale data files. */
struct locale_file
{
int failed;
int avail;
int binary;
union
{
void *generic;
struct locale_ctype_t *ctype;
struct locale_collate_t *collate;
struct locale_monetary_t *monetary;
struct locale_numeric_t *numeric;
struct locale_time_t *time;
struct locale_messages_t *messages;
} categories[6];
size_t len[6];
int magic;
int n;
};
/* Declared in localedef.c. */
extern int be_quiet;
extern const char *repertoiremap;
/* Found in localedef.c. */
void def_to_process (const char *name, int category);
/* Macros used in the parser. */
#define SYNTAX_ERROR(string, args...) \
do \
{ \
lr_error (ldfile, string, ## args); \
lr_ignore_rest (ldfile, 0); \
} \
while (0)
/* General handling of `copy'. */
static inline void
handle_copy (struct linereader *ldfile, struct charmap_t *charmap,
struct repertoire_t *repertoire, enum token_t token, int locale,
const char *locale_name, int ignore_content)
{
struct token *now;
int warned = 0;
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_string)
lr_error (ldfile, _("expect string argument for `copy'"));
else if (!ignore_content)
{
if (now->val.str.startmb == NULL)
lr_error (ldfile, _("\
locale name should consist only of portable characters"));
else
(void) add_to_readlist (locale, now->val.str.startmb,
repertoire->name);
}
lr_ignore_rest (ldfile, now->tok == tok_string);
/* The rest of the line must be empty and the next keyword must be
`END xxx'. */
while (lr_token (ldfile, charmap, NULL)->tok != tok_end)
{
if (warned == 0)
{
lr_error (ldfile, _("\
no other keyword shall be specified when `copy' is used"));
warned = 1;
}
lr_ignore_rest (ldfile, 0);
}
/* Handle `END xxx'. */
if (now->tok != token)
lr_error (ldfile, _("\
`%1$s' definition does not end with `END %1$s'"), locale_name);
lr_ignore_rest (ldfile, now->tok == token);
}
/* Found in locfile.c. */
struct localedef_t *locfile_read (const char *filename,
struct charset_t *charset);
extern int locfile_read (struct localedef_t *result,
struct charmap_t *charmap);
void check_all_categories (struct localedef_t *locale,
struct charset_t *charset);
/* Check validity of all the locale data. */
extern void check_all_categories (struct localedef_t *definitions,
struct charmap_t *charmap);
void write_all_categories (struct localedef_t *locale,
struct charset_t *charset, const char *output_path);
/* Write out all locale categories. */
extern void write_all_categories (struct localedef_t *definitions,
struct charmap_t *charmap,
const char *output_path);
/* Write out the data. */
extern void write_locale_data (const char *output_path, const char *category,
size_t n_elem, struct iovec *vec);
void write_locale_data (const char *output_path, const char *category,
size_t n_elem, struct iovec *vec);
/* Entrypoints for the parsers of the individual categories. */
/* Handle LC_CTYPE category. */
extern void ctype_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void ctype_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void ctype_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_COLLATE category. */
extern void collate_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void collate_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void collate_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_MONETARY category. */
extern void monetary_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void monetary_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void monetary_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_NUMERIC category. */
extern void numeric_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void numeric_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void numeric_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_MESSAGES category. */
extern void messages_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void messages_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void messages_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_TIME category. */
extern void time_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void time_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void time_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_PAPER category. */
extern void paper_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void paper_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void paper_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_NAME category. */
extern void name_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void name_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void name_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_ADDRESS category. */
extern void address_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void address_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void address_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_TELEPHONE category. */
extern void telephone_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void telephone_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void telephone_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_MEASUREMENT category. */
extern void measurement_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void measurement_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void measurement_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
/* Handle LC_IDENTIFICATION category. */
extern void identification_read (struct linereader *ldfile,
struct localedef_t *result,
struct charmap_t *charmap,
const char *repertoire_name,
int ignore_content);
extern void identification_finish (struct localedef_t *locale,
struct charmap_t *charmap);
extern void identification_output (struct localedef_t *locale,
struct charmap_t *charmap,
const char *output_path);
#endif /* locfile.h */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@ -24,22 +24,30 @@
#include <errno.h>
#include <error.h>
#include <limits.h>
#include <obstack.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libintl.h>
#include "linereader.h"
#include "charset.h"
#include "charmap.h"
#include "repertoire.h"
#include "simple-hash.h"
extern void *xmalloc (size_t __n);
#include "localedef.h"
/* Simple keyword hashing for the repertoiremap. */
static const struct keyword_t *repertoiremap_hash (const char *str, int len);
static const struct keyword_t *repertoiremap_hash (const char *str,
unsigned int len);
static void repertoire_new_char (struct linereader *lr, hash_table *ht,
hash_table *rt, struct obstack *ob,
uint32_t value, const char *from,
const char *to, int decimal_ellipsis);
static int repertoire_compare (const void *p1, const void *p2);
/* Already known repertoire maps. */
static void *known;
struct repertoire_t *
@ -47,9 +55,17 @@ repertoire_read (const char *filename)
{
struct linereader *repfile;
struct repertoire_t *result;
struct repertoire_t **resultp;
struct repertoire_t search;
int state;
char *from_name = NULL;
char *to_name = NULL;
enum token_t ellipsis = tok_none;
search.name = filename;
resultp = tfind (&search, &known, &repertoire_compare);
if (resultp != NULL)
return *resultp;
/* Determine path. */
repfile = lr_open (filename, repertoiremap_hash);
@ -57,7 +73,7 @@ repertoire_read (const char *filename)
{
if (strchr (filename, '/') == NULL)
{
char *i18npath = __secure_getenv ("I18NPATH");
char *i18npath = getenv ("I18NPATH");
if (i18npath != NULL && *i18npath != '\0')
{
char path[strlen (filename) + 1 + strlen (i18npath)
@ -73,6 +89,13 @@ repertoire_read (const char *filename)
filename);
repfile = lr_open (path, repertoiremap_hash);
if (repfile == NULL)
{
stpcpy (stpcpy (path, next), filename);
repfile = lr_open (path, repertoiremap_hash);
}
}
}
@ -98,15 +121,22 @@ repertoire_read (const char *filename)
}
}
/* We don't want symbolic names in string to be translated. */
repfile->translate_strings = 0;
/* Allocate room for result. */
result = (struct repertoire_t *) xmalloc (sizeof (struct repertoire_t));
memset (result, '\0', sizeof (struct repertoire_t));
result->name = xstrdup (filename);
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
obstack_init (&result->mem_pool);
if (init_hash (&result->char_table, 256))
if (init_hash (&result->char_table, 256)
|| init_hash (&result->reverse_table, 256)
|| init_hash (&result->seq_table, 256))
{
free (result);
return NULL;
@ -118,7 +148,7 @@ repertoire_read (const char *filename)
while (1)
{
/* What's on? */
struct token *now = lr_token (repfile, NULL);
struct token *now = lr_token (repfile, NULL, NULL);
enum token_t nowtok = now->tok;
struct token *arg;
@ -137,7 +167,7 @@ repertoire_read (const char *filename)
if (nowtok == tok_escape_char || nowtok == tok_comment_char)
{
/* We know that we need an argument. */
arg = lr_token (repfile, NULL);
arg = lr_token (repfile, NULL, NULL);
if (arg->tok != tok_ident)
{
@ -148,7 +178,7 @@ repertoire_read (const char *filename)
continue;
}
if (arg->val.str.len != 1)
if (arg->val.str.lenmb != 1)
{
lr_error (repfile, _("\
argument to <%s> must be a single character"),
@ -160,9 +190,9 @@ argument to <%s> must be a single character"),
}
if (nowtok == tok_escape_char)
repfile->escape_char = *arg->val.str.start;
repfile->escape_char = *arg->val.str.startmb;
else
repfile->comment_char = *arg->val.str.start;
repfile->comment_char = *arg->val.str.startmb;
lr_ignore_rest (repfile, 1);
continue;
@ -209,8 +239,8 @@ argument to <%s> must be a single character"),
obstack_free (&result->mem_pool, from_name);
from_name = (char *) obstack_copy0 (&result->mem_pool,
now->val.str.start,
now->val.str.len);
now->val.str.startmb,
now->val.str.lenmb);
to_name = NULL;
state = 3;
@ -219,8 +249,10 @@ argument to <%s> must be a single character"),
case 3:
/* We have two possibilities: We can see an ellipsis or an
encoding value. */
if (nowtok == tok_ellipsis)
if (nowtok == tok_ellipsis3 || nowtok == tok_ellipsis4
|| nowtok == tok_ellipsis2)
{
ellipsis = nowtok;
state = 4;
continue;
}
@ -232,7 +264,7 @@ argument to <%s> must be a single character"),
state = 2;
errno = 0;
if (nowtok != tok_ucs2 && nowtok != tok_ucs4)
if (nowtok != tok_ucs4)
{
lr_error (repfile,
_("syntax error in repertoire map definition: %s"),
@ -243,8 +275,10 @@ argument to <%s> must be a single character"),
}
/* We've found a new valid definition. */
charset_new_char (repfile, &result->char_table, 4,
now->val.charcode.val, from_name, to_name);
repertoire_new_char (repfile, &result->char_table,
&result->reverse_table, &result->mem_pool,
now->val.ucs4, from_name, to_name,
ellipsis != tok_ellipsis2);
/* Ignore the rest of the line. */
lr_ignore_rest (repfile, 0);
@ -268,8 +302,8 @@ argument to <%s> must be a single character"),
/* Copy the to-name in a safe place. */
to_name = (char *) obstack_copy0 (&result->mem_pool,
repfile->token.val.str.start,
repfile->token.val.str.len);
repfile->token.val.str.startmb,
repfile->token.val.str.lenmb);
state = 5;
continue;
@ -291,12 +325,26 @@ argument to <%s> must be a single character"),
lr_close (repfile);
if (tsearch (result, &known, &repertoire_compare) == NULL)
/* Something went wrong. */
error (0, errno, _("cannot safe new repertoire map"));
return result;
}
static int
repertoire_compare (const void *p1, const void *p2)
{
struct repertoire_t *r1 = (struct repertoire_t *) p1;
struct repertoire_t *r2 = (struct repertoire_t *) p2;
return strcmp (r1->name, r2->name);
}
static const struct keyword_t *
repertoiremap_hash (const char *str, int len)
repertoiremap_hash (const char *str, unsigned int len)
{
static const struct keyword_t wordlist[0] =
{
@ -317,3 +365,134 @@ repertoiremap_hash (const char *str, int len)
return NULL;
}
static void
repertoire_new_char (struct linereader *lr, hash_table *ht, hash_table *rt,
struct obstack *ob, uint32_t value, const char *from,
const char *to, int decimal_ellipsis)
{
char *from_end;
char *to_end;
const char *cp;
char *buf = NULL;
int prefix_len, len1, len2;
unsigned int from_nr, to_nr, cnt;
if (to == NULL)
{
insert_entry (ht, from, strlen (from),
(void *) (unsigned long int) value);
/* Please note that it isn't a bug if a symbol is defined more
than once. All later definitions are simply discarded. */
insert_entry (rt, obstack_copy (ob, &value, sizeof (value)),
sizeof (value), (void *) from);
return;
}
/* We have a range: the names must have names with equal prefixes
and an equal number of digits, where the second number is greater
or equal than the first. */
len1 = strlen (from);
len2 = strlen (to);
if (len1 != len2)
{
invalid_range:
lr_error (lr, _("invalid names for character range"));
return;
}
cp = &from[len1 - 1];
if (decimal_ellipsis)
while (isdigit (*cp) && cp >= from)
--cp;
else
while (isxdigit (*cp) && cp >= from)
{
if (!isdigit (*cp) && !isupper (*cp))
lr_error (lr, _("\
hexadecimal range format should use only capital characters"));
--cp;
}
prefix_len = (cp - from) + 1;
if (cp == &from[len1 - 1] || strncmp (from, to, prefix_len) != 0)
goto invalid_range;
errno = 0;
from_nr = strtoul (&from[prefix_len], &from_end, decimal_ellipsis ? 10 : 16);
if (*from_end != '\0' || (from_nr == ULONG_MAX && errno == ERANGE)
|| ((to_nr = strtoul (&to[prefix_len], &to_end,
decimal_ellipsis ? 10 : 16)) == ULONG_MAX
&& errno == ERANGE)
|| *to_end != '\0')
{
lr_error (lr, _("<%s> and <%s> are invalid names for range"));
return;
}
if (from_nr > to_nr)
{
lr_error (lr, _("upper limit in range is not smaller then lower limit"));
return;
}
for (cnt = from_nr; cnt <= to_nr; ++cnt)
{
uint32_t this_value = value + (cnt - from_nr);
obstack_printf (ob, decimal_ellipsis ? "%.*s%0*d" : "%.*s%0*X",
prefix_len, from, len1 - prefix_len, cnt);
insert_entry (ht, buf, len1,
(void *) (unsigned long int) this_value);
/* Please note we don't examine the return value since it is no error
if we have two definitions for a symbol. */
insert_entry (rt, obstack_copy (ob, &this_value, sizeof (this_value)),
sizeof (this_value), (void *) from);
}
}
uint32_t
repertoire_find_value (const struct repertoire_t *rep, const char *name,
size_t len)
{
void *result;
if (find_entry ((hash_table *) &rep->char_table, name, len, &result) < 0)
return ILLEGAL_CHAR_VALUE;
return (uint32_t) ((unsigned long int) result);
}
const char *
repertoire_find_symbol (const struct repertoire_t *rep, uint32_t ucs)
{
void *result;
if (find_entry ((hash_table *) &rep->reverse_table, &ucs, sizeof (ucs),
&result) < 0)
return NULL;
return (const char *) result;
}
struct charseq *
repertoire_find_seq (const struct repertoire_t *rep, uint32_t ucs)
{
void *result;
if (find_entry ((hash_table *) &rep->seq_table, &ucs, sizeof (ucs),
&result) < 0)
return NULL;
return (struct charseq *) result;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@ -21,18 +21,43 @@
#define _REPERTOIREMAP_H 1
#include <obstack.h>
#include <stdint.h>
#include "charmap.h"
#include "simple-hash.h"
#include "linereader.h"
struct repertoire_t
{
const char *name;
struct obstack mem_pool;
hash_table char_table;
hash_table reverse_table;
hash_table seq_table;
};
/* We need one value to mark the error case. Let's use 0xffffffff.
I.e., it is placed in the last page of ISO 10646. For now only the
first is used and we have plenty of room. */
#define ILLEGAL_CHAR_VALUE ((uint32_t) 0xffffffffu)
/* Another value is needed to signal that a value is not yet determined. */
#define UNINITIALIZED_CHAR_VALUE ((uint32_t) 0xfffffffeu)
/* Prototypes for repertoire map handling functions. */
struct repertoire_t *repertoire_read (const char *filename);
extern struct repertoire_t *repertoire_read (const char *filename);
/* Return UCS4 value of character with given NAME. */
extern uint32_t repertoire_find_value (const struct repertoire_t *repertoire,
const char *name, size_t len);
/* Return symbol for given UCS4 value. */
extern const char *repertoire_find_symbol (const struct repertoire_t *repertoire,
uint32_t ucs);
/* Query the has table to memoize mapping from UCS4 to byte sequences. */
extern struct charseq *repertoire_find_seq (const struct repertoire_t *rep,
uint32_t ucs);
#endif /* repertoiremap.h */

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
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
@ -24,8 +24,8 @@
typedef struct hash_table
{
unsigned long size;
unsigned long filled;
unsigned long int size;
unsigned long int filled;
void *first;
void *table;
struct obstack mem_pool;
@ -33,18 +33,18 @@ typedef struct hash_table
hash_table;
int init_hash __P ((hash_table *htab, unsigned long int init_size));
int delete_hash __P ((hash_table *htab));
int insert_entry __P ((hash_table *htab, const void *key, size_t keylen,
void *data));
int find_entry __P ((hash_table *htab, const void *key, size_t keylen,
void **result));
int set_entry __P ((hash_table *htab, const void *key, size_t keylen,
void *newval));
extern int init_hash __P ((hash_table *htab, unsigned long int init_size));
extern int delete_hash __P ((hash_table *htab));
extern int insert_entry __P ((hash_table *htab, const void *key, size_t keylen,
void *data));
extern int find_entry __P ((hash_table *htab, const void *key, size_t keylen,
void **result));
extern int set_entry __P ((hash_table *htab, const void *key, size_t keylen,
void *newval));
int iterate_table __P ((hash_table *htab, void **ptr,
const void **key, size_t *keylen, void **data));
extern int iterate_table __P ((hash_table *htab, void **ptr,
const void **key, size_t *keylen, void **data));
unsigned long next_prime __P ((unsigned long int seed));
extern unsigned long int next_prime __P ((unsigned long int seed));
#endif /* simple-hash.h */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@ -21,6 +21,7 @@
# include <config.h>
#endif
#include <assert.h>
#include <stdlib.h>
#include "charset.h"
@ -77,8 +78,11 @@ translate_string (char *str, struct charset_t *charset)
tp = &str[1];
while (tp[0] != '\0' && tp[0] != '>')
if (tp[0] == '\\' && tp[1] != '\0')
tp += 2;
if (tp[0] == '\\')
if (tp[1] != '\0')
tp += 2;
else
++tp;
else
++tp;

View File

@ -34,16 +34,17 @@
This contains the built-in "C"/"POSIX" locale's data for CATEGORY.
Both are weak references; if &_nl_current_CATEGORY is zero,
then nothing is using the locale data. */
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
extern struct locale_data *_nl_current_##category; \
extern struct locale_data _nl_C_##category;
#include "categories.def"
#undef DEFINE_CATEGORY
/* Array indexed by category of pointers to _nl_current_CATEGORY slots. */
/* Array indexed by category of pointers to _nl_current_CATEGORY slots.
Elements are zero for categories whose data is never used. */
struct locale_data * *const _nl_current[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = &_nl_current_##category,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -56,7 +57,7 @@ struct locale_data * *const _nl_current[] =
Elements are zero for categories whose data is never used. */
struct locale_data *const _nl_C[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = &_nl_C_##category,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -64,14 +65,10 @@ struct locale_data *const _nl_C[] =
/* Define an array of category names (also the environment variable names),
indexed by integral category.
We have entries of fixed width (16 for now) do avoid an array of
pointers. Update the size of the outer array if new, longer locale
names are introduced. */
const char _nl_category_names[][16] =
indexed by integral category. */
const char *const _nl_category_names[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = category_name,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -80,7 +77,7 @@ const char _nl_category_names[][16] =
/* An array of their lengths, for convenience. */
const size_t _nl_category_name_sizes[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = sizeof (category_name) - 1,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -91,7 +88,7 @@ const size_t _nl_category_name_sizes[] =
/* Declare the postload functions used below. */
#undef NO_POSTLOAD
#define NO_POSTLOAD _nl_postload_ctype /* Harmless thing known to exist. */
#define DEFINE_CATEGORY(category, category_name, items, postload, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, postload) \
extern void postload (void);
#include "categories.def"
#undef DEFINE_CATEGORY
@ -101,7 +98,7 @@ extern void postload (void);
loading and installing that category's data. */
static void (*const _nl_category_postload[]) (void) =
{
#define DEFINE_CATEGORY(category, category_name, items, postload, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, postload) \
[category] = postload,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -112,7 +109,7 @@ static void (*const _nl_category_postload[]) (void) =
Each is malloc'd unless it is nl_C_name. */
static const char *_nl_current_names[] =
{
#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = _nl_C_name,
#include "categories.def"
#undef DEFINE_CATEGORY
@ -134,7 +131,7 @@ __libc_lock_define_initialized (, __libc_setlocale_lock)
/* Construct a new composite name. */
static inline char *
new_composite_name (int category, const char *newnames[LC_ALL])
new_composite_name (int category, const char *newnames[__LC_LAST])
{
size_t last_len = 0;
size_t cumlen = 0;
@ -142,22 +139,23 @@ new_composite_name (int category, const char *newnames[LC_ALL])
char *new, *p;
int same = 1;
for (i = 0; i < LC_ALL; ++i)
{
const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] :
_nl_current_names[i]);
last_len = strlen (name);
cumlen += _nl_category_name_sizes[i] + 1 + last_len + 1;
if (same && strcmp (name, newnames[0]) != 0)
same = 0;
}
for (i = 0; i < __LC_LAST; ++i)
if (i != LC_ALL)
{
const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] :
_nl_current_names[i]);
last_len = strlen (name);
cumlen += _nl_category_name_sizes[i] + 1 + last_len + 1;
if (i > 0 && same && strcmp (name, newnames[0]) != 0)
same = 0;
}
if (same)
{
/* All the categories use the same name. */
if (strcmp (newnames[0], _nl_C_name) == 0
|| strcmp (newnames[0], _nl_POSIX_name) == 0)
if (strcmp (newnames[0], "C") == 0
|| strcmp (newnames[0], "POSIX") == 0)
return (char *) _nl_C_name;
new = malloc (last_len + 1);
@ -169,17 +167,18 @@ new_composite_name (int category, const char *newnames[LC_ALL])
if (new == NULL)
return NULL;
p = new;
for (i = 0; i < LC_ALL; ++i)
{
/* Add "CATEGORY=NAME;" to the string. */
const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] :
_nl_current_names[i]);
p = __stpcpy (p, _nl_category_names[i]);
*p++ = '=';
p = __stpcpy (p, name);
*p++ = ';';
}
for (i = 0; i < __LC_LAST; ++i)
if (i != LC_ALL)
{
/* Add "CATEGORY=NAME;" to the string. */
const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] :
_nl_current_names[i]);
p = __stpcpy (p, _nl_category_names[i]);
*p++ = '=';
p = __stpcpy (p, name);
*p++ = ';';
}
p[-1] = '\0'; /* Clobber the last ';'. */
return new;
}
@ -221,7 +220,7 @@ setlocale (int category, const char *locale)
char *composite;
/* Sanity check for CATEGORY argument. */
if (category < 0 || category > LC_ALL)
if (category < 0 || category >= __LC_LAST)
ERROR_RETURN;
/* Does user want name of current locale? */
@ -254,12 +253,13 @@ setlocale (int category, const char *locale)
for the individual categories can be selected by using a
composite locale name. This is a semi-colon separated list
of entries of the form `CATEGORY=VALUE'. */
const char *newnames[LC_ALL];
struct locale_data *newdata[LC_ALL];
const char *newnames[__LC_LAST];
struct locale_data *newdata[__LC_LAST];
/* Set all name pointers to the argument name. */
for (category = 0; category < LC_ALL; ++category)
newnames[category] = (char *) locale;
for (category = 0; category < __LC_LAST; ++category)
if (category != LC_ALL)
newnames[category] = (char *) locale;
if (strchr (locale, ';') != NULL)
{
@ -270,12 +270,13 @@ setlocale (int category, const char *locale)
while ((cp = strchr (np, '=')) != NULL)
{
for (cnt = 0; cnt < LC_ALL; ++cnt)
if ((size_t) (cp - np) == _nl_category_name_sizes[cnt]
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL
&& (size_t) (cp - np) == _nl_category_name_sizes[cnt]
&& memcmp (np, _nl_category_names[cnt], cp - np) == 0)
break;
if (cnt == LC_ALL)
if (cnt == __LC_LAST)
/* Bogus category name. */
ERROR_RETURN;
@ -293,8 +294,8 @@ setlocale (int category, const char *locale)
break;
}
for (cnt = 0; cnt < LC_ALL; ++cnt)
if (newnames[cnt] == locale)
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL && newnames[cnt] == locale)
/* The composite name did not specify all categories. */
ERROR_RETURN;
}
@ -305,6 +306,13 @@ setlocale (int category, const char *locale)
/* Load the new data for each category. */
while (category-- > 0)
{
/* XXX hack. Remove when collation works. */
if (category == LC_COLLATE)
{
newdata[category] = NULL;
continue;
}
newdata[category] = _nl_find_locale (locale_path, locale_path_len,
category,
&newnames[category]);
@ -327,11 +335,12 @@ setlocale (int category, const char *locale)
else
{
/* Now we have loaded all the new data. Put it in place. */
for (category = 0; category < LC_ALL; ++category)
{
setdata (category, newdata[category]);
setname (category, newnames[category]);
}
for (category = 0; category < __LC_LAST; ++category)
if (category != LC_ALL)
{
setdata (category, newdata[category]);
setname (category, newnames[category]);
}
setname (LC_ALL, composite);
}
@ -343,6 +352,11 @@ setlocale (int category, const char *locale)
return composite;
}
else if (category == LC_COLLATE)
{
/* XXX Remove when LC_COLLATE works. */
return NULL;
}
else
{
struct locale_data *newdata = NULL;
@ -401,21 +415,22 @@ free_mem (void)
{
int category;
for (category = 0; category < LC_ALL; ++category)
{
struct locale_data *here = *_nl_current[category];
for (category = 0; category < __LC_LAST; ++category)
if (category != LC_ALL)
{
struct locale_data *here = *_nl_current[category];
/* If this category is already "C" don't do anything. */
if (here == _nl_C[category])
continue;
/* If this category is already "C" don't do anything. */
if (here == _nl_C[category])
continue;
/* We have to be prepared that sometime later me still might
need the locale information. */
setdata (category, _nl_C[category]);
setname (category, _nl_C_name);
/* We have to be prepared that sometime later me still might
need the locale information. */
setdata (category, _nl_C[category]);
setname (category, _nl_C_name);
_nl_unload_locale (here);
}
_nl_unload_locale (here);
}
setname (LC_ALL, _nl_C_name);
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper, <drepper@cygnus.com>.
@ -37,7 +37,7 @@ typedef struct weight_t
struct data_pair
{
int number;
const u_int32_t *value;
const uint32_t *value;
} data[0];
} weight_t;
@ -52,9 +52,9 @@ typedef struct weight_t
# define collate_hash_layers \
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS))
# define collate_undefined \
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_UNDEFINED))
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_UNDEFINED_WC))
# define collate_rules \
((u_int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULES))
((uint32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULES))
static __inline void get_weight (const STRING_TYPE **str, weight_t *result);
static __inline void
@ -67,18 +67,18 @@ get_weight (const STRING_TYPE **str, weight_t *result)
# define collate_hash_layers \
current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)].word
# define collate_undefined \
current->values[_NL_ITEM_INDEX (_NL_COLLATE_UNDEFINED)].word
current->values[_NL_ITEM_INDEX (_NL_COLLATE_UNDEFINED_WC)].word
# define collate_rules \
((u_int32_t *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULES)].string)
((uint32_t *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULES)].string)
static __inline void get_weight (const STRING_TYPE **str, weight_t *result,
struct locale_data *current,
const u_int32_t *__collate_table,
const u_int32_t *__collate_extra);
const uint32_t *__collate_tablewc,
const uint32_t *__collate_extrawc);
static __inline void
get_weight (const STRING_TYPE **str, weight_t *result,
struct locale_data *current, const u_int32_t *__collate_table,
const u_int32_t *__collate_extra)
struct locale_data *current, const uint32_t *__collate_tablewc,
const uint32_t *__collate_extrawc)
#endif
{
unsigned int ch = *((USTRING_TYPE *) (*str))++;
@ -94,9 +94,9 @@ get_weight (const STRING_TYPE **str, weight_t *result,
slot = (ch % collate_hash_size) * (collate_nrules + 1);
level = 0;
while (__collate_table[slot] != (u_int32_t) ch)
while (__collate_tablewc[slot] != (uint32_t) ch)
{
if (__collate_table[slot + 1] == 0
if (__collate_tablewc[slot + 1] == 0
|| ++level >= collate_hash_layers)
{
size_t idx = collate_undefined;
@ -104,8 +104,8 @@ get_weight (const STRING_TYPE **str, weight_t *result,
for (cnt = 0; cnt < collate_nrules; ++cnt)
{
result->data[cnt].number = __collate_extra[idx++];
result->data[cnt].value = &__collate_extra[idx];
result->data[cnt].number = __collate_extrawc[idx++];
result->data[cnt].value = &__collate_extrawc[idx];
idx += result->data[cnt].number;
}
/* The Unix standard requires that a character outside
@ -117,7 +117,7 @@ get_weight (const STRING_TYPE **str, weight_t *result,
}
}
if (__collate_table[slot + 1] != (u_int32_t) FORWARD_CHAR)
if (__collate_tablewc[slot + 1] != (uint32_t) FORWARD_CHAR)
{
/* We have a simple form. One value for each weight. */
size_t cnt;
@ -125,7 +125,7 @@ get_weight (const STRING_TYPE **str, weight_t *result,
for (cnt = 0; cnt < collate_nrules; ++cnt)
{
result->data[cnt].number = 1;
result->data[cnt].value = &__collate_table[slot + 1 + cnt];
result->data[cnt].value = &__collate_tablewc[slot + 1 + cnt];
}
return;
}
@ -134,21 +134,21 @@ get_weight (const STRING_TYPE **str, weight_t *result,
There might none, but the last list member is a catch-all case
because it is simple the character CH. The value of this entry
might be the same as UNDEFINED. */
slot = __collate_table[slot + 2];
slot = __collate_tablewc[slot + 2];
while (1)
{
size_t idx;
/* This is a comparison between a u_int32_t array (aka wchar_t) and
/* This is a comparison between a uint32_t array (aka wchar_t) and
an 8-bit string. */
for (idx = 0; __collate_extra[slot + 2 + idx] != 0; ++idx)
if (__collate_extra[slot + 2 + idx] != ((USTRING_TYPE *) *str)[idx])
for (idx = 0; __collate_extrawc[slot + 2 + idx] != 0; ++idx)
if (__collate_extrawc[slot + 2 + idx] != (uint32_t) (*str)[idx])
break;
/* When the loop finished with all characters of the collation
/* When the loop finished with all character of the collation
element used, we found the longest prefix. */
if (__collate_extra[slot + 2 + idx] == 0)
if (__collate_extrawc[slot + 2 + idx] == 0)
{
size_t cnt;
@ -156,15 +156,15 @@ get_weight (const STRING_TYPE **str, weight_t *result,
idx += slot + 3;
for (cnt = 0; cnt < collate_nrules; ++cnt)
{
result->data[cnt].number = __collate_extra[idx++];
result->data[cnt].value = &__collate_extra[idx];
result->data[cnt].number = __collate_extrawc[idx++];
result->data[cnt].value = &__collate_extrawc[idx];
idx += result->data[cnt].number;
}
return;
}
/* To next entry in list. */
slot += __collate_extra[slot];
slot += __collate_extrawc[slot];
}
}
@ -178,10 +178,10 @@ get_weight (const STRING_TYPE **str, weight_t *result,
We have this strange extra macro since the functions which use the
given locale (not the global one) cannot use the global tables. */
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
# define call_get_weight(strp, newp) get_weight (strp, newp)
# define call_get_weight(strp, newp) get_weight ((strp), (newp))
#else
# define call_get_weight(strp, newp) \
get_weight (strp, newp, current, collate_table, collate_extra)
get_weight ((strp), (newp), current, collate_table, collate_extra)
#endif
#define get_string(str, forw, backw) \

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@ -34,6 +34,23 @@
# define STRCMP strcmp
#endif
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
int
STRCOLL (s1, s2)
const STRING_TYPE *s1;
const STRING_TYPE *s2;
#else
int
STRCOLL (s1, s2, l)
const STRING_TYPE *s1;
const STRING_TYPE *s2;
__locale_t l;
#endif
{
return STRCMP (s1, s2);
}
#if 0
/* Include the shared helper functions. `strxfrm'/`wcsxfrm' also use
these functions. */
#include "../locale/weight.h"
@ -208,3 +225,4 @@ STRCOLL (s1, s2, l)
return 0;
}
#endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@ -34,6 +34,21 @@
# define STPNCPY __stpncpy
#endif
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
size_t
STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n)
#else
size_t
STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
#endif
{
if (n != 0)
STPNCPY (dest, src, n);
return STRLEN (src);
}
#if 0
/* Include the shared helper functions. `strxfrm'/`wcsxfrm' also use
these functions. */
#include "../locale/weight.h"
@ -280,3 +295,4 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
/* Return length without counting the terminating '\0'. */
return written;
}
#endif

View File

@ -86,10 +86,15 @@ extern char *tzname[];
#endif
#ifdef COMPILE_WIDE
# include <endian.h>
# define CHAR_T wchar_t
# define UCHAR_T unsigned int
# define L_(Str) L##Str
# define NLW(Sym) _NL_W##Sym
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define NLW(Sym) _NL_W##Sym##_EL
# else
# define NLW(Sym) _NL_W##Sym##_EB
# endif
# define MEMCPY(d, s, n) wmemcpy (d, s, n)
# define STRLEN(s) wcslen (s)
@ -833,11 +838,11 @@ my_strftime (s, maxsize, format, tp ut_argument)
if (era)
{
# ifdef COMPILE_WIDE
/* XXX For the time being there is no equivalent to
_nl_get_era_entry to get a wide character variant. */
wchar_t *ws;
size_t len;
widen (era->name_fmt, ws, len);
/* The wide name is after the single byte name and
format. */
char *tcp = strchr (era->name_fmt, '\0') + 1;
wchar_t *ws = (wchar_t *) (strchr (tcp, '\0') + 1);
size_t len = wcslen (ws);
cpy (len, ws);
# else
size_t len = strlen (era->name_fmt);
@ -909,13 +914,7 @@ my_strftime (s, maxsize, format, tp ut_argument)
/* Get the locale specific alternate representation of
the number NUMBER_VALUE. If none exist NULL is returned. */
# ifdef COMPILE_WIDE
const char *ncp = _nl_get_alt_digit (number_value);
wchar_t *cp = NULL;
if (ncp != NULL)
{
size_t len;
widen (ncp, cp, len);
}
const wchar_t *cp = _nl_get_walt_digit (number_value);
# else
const char *cp = _nl_get_alt_digit (number_value);
# endif
@ -1200,13 +1199,12 @@ my_strftime (s, maxsize, format, tp ut_argument)
if (era)
{
# ifdef COMPILE_WIDE
/* XXX For the time being there is no wide character
equivalent or _nl_get_era_entry. */
const char *ncp = strchr (era->name_fmt, '\0') + 1;
/* The wide name is after the single byte name and
format. */
char *tcp = strchr (era->name_fmt, '\0') + 1;
size_t len;
wchar_t *s;
widen (ncp, s, len);
subfmt = s;
subfmt = (wchar_t *) (strchr (tcp, '\0') + 1);
subfmt = wcschr (subfmt, L'\0') + 1;
# else
subfmt = strchr (era->name_fmt, '\0') + 1;
# endif

View File

@ -156,7 +156,6 @@ localtime_r (t, tp)
#ifdef _LIBC
/* This is defined in locale/C-time.c in the GNU libc. */
extern const struct locale_data _nl_C_LC_TIME;
extern const unsigned short int __mon_yday[2][13];
# define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
@ -37,23 +37,35 @@ cname_lookup (wint_t wc, __locale_t locale)
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
extern unsigned int *__ctype_names;
hash_size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE);
hash_layers = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_LAYERS);
# if BYTE_ORDER == BIG_ENDIAN
hash_size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE_EB);
hash_layers = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_LAYERS_EB);
# elif BYTE_ORDER == LITTLE_ENDIAN
hash_size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE_EL);
hash_layers = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_LAYERS_EL);
# else
# error bizarre byte order
# endif
#else
struct locale_data *current = locale->__locales[LC_CTYPE];
#if BYTE_ORDER == BIG_ENDIAN
# if BYTE_ORDER == BIG_ENDIAN
unsigned int *__ctype_names =
(unsigned int *) current->values[_NL_ITEM_INDEX (_NL_CTYPE_NAMES_EB)].string;
#elif BYTE_ORDER == LITTLE_ENDIAN
hash_size =
current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE_EB)].word;
hash_layers =
current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_LAYERS_EB)].word;
# elif BYTE_ORDER == LITTLE_ENDIAN
unsigned int *__ctype_names =
(unsigned int *) current->values[_NL_ITEM_INDEX (_NL_CTYPE_NAMES_EL)].string;
#else
# error bizarre byte order
#endif
hash_size =
current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word;
current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE_EL)].word;
hash_layers =
current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_LAYERS)].word;
current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_LAYERS_EL)].word;
# else
# error bizarre byte order
# endif
#endif
result = wc % hash_size;