diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 16:39:27 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 16:39:27 +0000 |
commit | 52629237a522c7c146d788ddaaf69946fd2729f9 (patch) | |
tree | 552402b085cff37bc251fc0f45ed9255b53cdd57 /locale | |
parent | 3896c5809b49e72fbadc57da2189ff42aa2a5d02 (diff) | |
parent | 064374be911f72dfaec8a75f06da1f9fc1827712 (diff) |
Merge commit 'refs/top-bases/t/hurdsig-boot-fix' into t/hurdsig-boot-fix
Diffstat (limited to 'locale')
104 files changed, 1368 insertions, 811 deletions
diff --git a/locale/C-address.c b/locale/C-address.c index 1d71115184..f2a77fb826 100644 --- a/locale/C-address.c +++ b/locale/C-address.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/C-collate.c b/locale/C-collate.c index 8214ff5f69..dcf264b9cb 100644 --- a/locale/C-collate.c +++ b/locale/C-collate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/locale/C-ctype.c b/locale/C-ctype.c index de7edd15e8..9397a1ec22 100644 --- a/locale/C-ctype.c +++ b/locale/C-ctype.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/locale/C-identification.c b/locale/C-identification.c index cbe15d23c3..d9f663af11 100644 --- a/locale/C-identification.c +++ b/locale/C-identification.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/C-measurement.c b/locale/C-measurement.c index 4b647ea7d9..92064d7361 100644 --- a/locale/C-measurement.c +++ b/locale/C-measurement.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/C-messages.c b/locale/C-messages.c index 16623d8bbd..915c20c01e 100644 --- a/locale/C-messages.c +++ b/locale/C-messages.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. diff --git a/locale/C-monetary.c b/locale/C-monetary.c index 5d5be36ec1..e241551e47 100644 --- a/locale/C-monetary.c +++ b/locale/C-monetary.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/locale/C-name.c b/locale/C-name.c index 291410144b..304ee8b1a3 100644 --- a/locale/C-name.c +++ b/locale/C-name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/C-numeric.c b/locale/C-numeric.c index a76f837ba0..bd67866b10 100644 --- a/locale/C-numeric.c +++ b/locale/C-numeric.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/locale/C-paper.c b/locale/C-paper.c index 1679f113ce..50e0d6ccfc 100644 --- a/locale/C-paper.c +++ b/locale/C-paper.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/C-telephone.c b/locale/C-telephone.c index 4dce81dfa7..9498b2043f 100644 --- a/locale/C-telephone.c +++ b/locale/C-telephone.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/C-time.c b/locale/C-time.c index 2f95307886..e2b3b17258 100644 --- a/locale/C-time.c +++ b/locale/C-time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -30,7 +30,7 @@ const struct __locale_data _nl_C_LC_TIME attribute_hidden = { NULL, }, /* no cached data */ UNDELETABLE, 0, - 111, + 159, { { .string = "Sun" }, { .string = "Mon" }, @@ -142,6 +142,54 @@ const struct __locale_data _nl_C_LC_TIME attribute_hidden = { .string = "" }, { .string = "%a %b %e %H:%M:%S %Z %Y" }, { .wstr = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y" }, - { .string = _nl_C_codeset } + { .string = _nl_C_codeset }, + { .string = "January" }, + { .string = "February" }, + { .string = "March" }, + { .string = "April" }, + { .string = "May" }, + { .string = "June" }, + { .string = "July" }, + { .string = "August" }, + { .string = "September" }, + { .string = "October" }, + { .string = "November" }, + { .string = "December" }, + { .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" }, + { .string = "Jan" }, + { .string = "Feb" }, + { .string = "Mar" }, + { .string = "Apr" }, + { .string = "May" }, + { .string = "Jun" }, + { .string = "Jul" }, + { .string = "Aug" }, + { .string = "Sep" }, + { .string = "Oct" }, + { .string = "Nov" }, + { .string = "Dec" }, + { .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" } } }; diff --git a/locale/C-translit.h.in b/locale/C-translit.h.in index 0cacc1e72c..e27f39e8fe 100644 --- a/locale/C-translit.h.in +++ b/locale/C-translit.h.in @@ -1,5 +1,5 @@ /* Transliteration for the C locale. -*-C-*- - Copyright (C) 2000-2016 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2000. diff --git a/locale/Makefile b/locale/Makefile index 22e0c856bd..fd9972279b 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2016 Free Software Foundation, Inc. +# Copyright (C) 1991-2018 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,7 +22,8 @@ subdir := locale include ../Makeconfig -headers = locale.h bits/locale.h langinfo.h xlocale.h +headers = langinfo.h locale.h bits/locale.h \ + bits/types/locale_t.h bits/types/__locale_t.h routines = setlocale findlocale loadlocale loadarchive \ localeconv nl_langinfo nl_langinfo_l mb_cur_max \ newlocale duplocale freelocale uselocale @@ -52,7 +53,8 @@ localedef-modules := localedef $(categories:%=ld-%) \ repertoire locarchive localedef-aux := md5 locale-modules := locale locale-spec -lib-modules := charmap-dir simple-hash xmalloc xstrdup +lib-modules := charmap-dir simple-hash xmalloc xstrdup \ + record-status GPERF = gperf @@ -60,7 +62,7 @@ GPERFFLAGS = -acCgopt -k1,2,5,9,$$ -L ANSI-C include ../Rules -CFLAGS-md5.c = -I../crypt +CFLAGS-md5.c += -I../crypt programs/%-kw.h: programs/%-kw.gperf cd programs \ @@ -85,7 +87,7 @@ localepath = "$(complocaledir):$(i18ndir)" # of the list instead of the tail, where CPPFLAGS-$(lib) gets added. # We need it before the standard -I's to see programs/config.h first. locale-CPPFLAGS = -DCOMPLOCALEDIR='"$(complocaledir)"' \ - -DLOCALE_ALIAS_PATH='"$(msgcatdir)"' \ + -DLOCALE_ALIAS_PATH='"$(localedir)"' \ -Iprograms CPPFLAGS-locale-programs = -DLOCALE_PATH='$(localepath)' \ @@ -93,12 +95,12 @@ CPPFLAGS-locale-programs = -DLOCALE_PATH='$(localepath)' \ -DREPERTOIREMAP_PATH='"$(i18ndir)/repertoiremaps"' \ -DLOCSRCDIR='"$(i18ndir)/locales"' -CFLAGS-charmap.c = -Wno-write-strings -Wno-char-subscripts -CFLAGS-locfile.c = -Wno-write-strings -Wno-char-subscripts -CFLAGS-charmap-dir.c = -Wno-write-strings +CFLAGS-charmap.c += -Wno-write-strings -Wno-char-subscripts +CFLAGS-locfile.c += -Wno-write-strings -Wno-char-subscripts +CFLAGS-charmap-dir.c += -Wno-write-strings # Set libof-* for each routine. cpp-srcs-left := $(localedef-modules) $(localedef-aux) $(locale-modules) \ $(lib-modules) lib := locale-programs -include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) +include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left)) diff --git a/locale/bits/locale.h b/locale/bits/locale.h index d5fb290669..3a3d921902 100644 --- a/locale/bits/locale.h +++ b/locale/bits/locale.h @@ -1,5 +1,5 @@ /* Definition of locale category symbol values. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 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 diff --git a/locale/xlocale.h b/locale/bits/types/__locale_t.h index e4408e2e99..a6cccf6337 100644 --- a/locale/xlocale.h +++ b/locale/bits/types/__locale_t.h @@ -1,5 +1,5 @@ -/* Definition of locale datatype. - Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Definition of struct __locale_struct and __locale_t. + Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -17,14 +17,15 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef _XLOCALE_H -#define _XLOCALE_H 1 +#ifndef _BITS_TYPES___LOCALE_T_H +#define _BITS_TYPES___LOCALE_T_H 1 -/* Structure for reentrant locale using functions. This is an - (almost) opaque type for the user level programs. The file and - this data structure is not standardized. Don't rely on it. It can - go away without warning. */ -typedef struct __locale_struct +/* POSIX.1-2008: the locale_t type, representing a locale context + (implementation-namespace version). This type should be treated + as opaque by applications; some details are exposed for the sake of + efficiency in e.g. ctype functions. */ + +struct __locale_struct { /* Note: LC_ALL is not a valid index into this array. */ struct __locale_data *__locales[13]; /* 13 = __LC_LAST. */ @@ -36,9 +37,8 @@ typedef struct __locale_struct /* Note: LC_ALL is not a valid index into this array. */ const char *__names[13]; -} *__locale_t; +}; -/* POSIX 2008 makes locale_t official. */ -typedef __locale_t locale_t; +typedef struct __locale_struct *__locale_t; -#endif /* xlocale.h */ +#endif /* bits/types/__locale_t.h */ diff --git a/locale/bits/types/locale_t.h b/locale/bits/types/locale_t.h new file mode 100644 index 0000000000..6a7aad2851 --- /dev/null +++ b/locale/bits/types/locale_t.h @@ -0,0 +1,26 @@ +/* Definition of locale_t. + Copyright (C) 2017-2018 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _BITS_TYPES_LOCALE_T_H +#define _BITS_TYPES_LOCALE_T_H 1 + +#include <bits/types/__locale_t.h> + +typedef __locale_t locale_t; + +#endif /* bits/types/locale_t.h */ diff --git a/locale/broken_cur_max.c b/locale/broken_cur_max.c index aa1a277fcb..36ce6e7f4f 100644 --- a/locale/broken_cur_max.c +++ b/locale/broken_cur_max.c @@ -1,6 +1,6 @@ /* Return number of characters in multibyte representation for current character set. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/locale/categories.def b/locale/categories.def index d8a3ab8127..56c5f88f6e 100644 --- a/locale/categories.def +++ b/locale/categories.def @@ -1,5 +1,5 @@ /* Definition of all available locale categories and their items. -*- C -*- - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -249,6 +249,10 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_DATE_FMT, "date_fmt", opt, string) DEFINE_ELEMENT (_NL_W_DATE_FMT, "wide-date_fmt", opt, wstring) DEFINE_ELEMENT (_NL_TIME_CODESET, "time-codeset", std, string) + DEFINE_ELEMENT (ALTMON_1, "alt_mon", opt, stringarray, 12, 12) + DEFINE_ELEMENT (_NL_WALTMON_1, "wide-alt_mon", opt, wstringarray, 12, 12) + DEFINE_ELEMENT (_NL_ABALTMON_1, "ab_alt_mon", opt, stringarray, 12, 12) + DEFINE_ELEMENT (_NL_WABALTMON_1, "wide-ab_alt_mon", opt, wstringarray, 12, 12) ), NO_POSTLOAD) diff --git a/locale/coll-lookup.c b/locale/coll-lookup.c index 136e24f77a..0d2c401878 100644 --- a/locale/coll-lookup.c +++ b/locale/coll-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Bruno Haible <haible@clisp.cons.org>, 2000. @@ -20,7 +20,6 @@ /* Lookup in a table of int32_t, with default value 0. */ int32_t -internal_function __collidx_table_lookup (const char *table, uint32_t wc) { uint32_t shift1 = ((const uint32_t *) table)[0]; @@ -51,7 +50,6 @@ __collidx_table_lookup (const char *table, uint32_t wc) /* Lookup in a table of uint32_t, with default value 0xffffffff. */ uint32_t -internal_function __collseq_table_lookup (const char *table, uint32_t wc) { uint32_t shift1 = ((const uint32_t *) table)[0]; diff --git a/locale/coll-lookup.h b/locale/coll-lookup.h index 1195a59fc8..f83934c83b 100644 --- a/locale/coll-lookup.h +++ b/locale/coll-lookup.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Bruno Haible <haible@clisp.cons.org>, 2000. @@ -20,8 +20,8 @@ /* Lookup in a table of int32_t, with default value 0. */ extern int32_t __collidx_table_lookup (const char *table, uint32_t wc) - internal_function; + attribute_hidden; /* Lookup in a table of uint32_t, with default value 0xffffffff. */ extern uint32_t __collseq_table_lookup (const char *table, uint32_t wc) - internal_function; + attribute_hidden; diff --git a/locale/duplocale.c b/locale/duplocale.c index bd8a191569..9965042fcd 100644 --- a/locale/duplocale.c +++ b/locale/duplocale.c @@ -1,5 +1,5 @@ /* Duplicate handle for selection of locales. - Copyright (C) 1997-2016 Free Software Foundation, Inc. + Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -29,8 +29,8 @@ __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden) -__locale_t -__duplocale (__locale_t dataset) +locale_t +__duplocale (locale_t dataset) { /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */ if (dataset == _nl_C_locobj_ptr) @@ -40,7 +40,7 @@ __duplocale (__locale_t dataset) if (dataset == LC_GLOBAL_LOCALE) dataset = &_nl_global_locale; - __locale_t result; + locale_t result; int cnt; size_t names_len = 0; diff --git a/locale/elem-hash.h b/locale/elem-hash.h index bcca1ef746..11571f4ef9 100644 --- a/locale/elem-hash.h +++ b/locale/elem-hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2016 Free Software Foundation, Inc. +/* Copyright (C) 1999-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper, <drepper@cygnus.com>. diff --git a/locale/findlocale.c b/locale/findlocale.c index 4cb9d5ea8a..872cadb5b9 100644 --- a/locale/findlocale.c +++ b/locale/findlocale.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -99,7 +99,6 @@ valid_locale_name (const char *name) } struct __locale_data * -internal_function _nl_find_locale (const char *locale_path, size_t locale_path_len, int category, const char **name) { @@ -332,7 +331,6 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, /* Calling this function assumes the lock for handling global locale data is acquired. */ void -internal_function _nl_remove_locale (int locale, struct __locale_data *data) { if (--data->usage_count == 0) diff --git a/locale/freelocale.c b/locale/freelocale.c index d8441cafd4..338e5193f0 100644 --- a/locale/freelocale.c +++ b/locale/freelocale.c @@ -1,5 +1,5 @@ /* Free data allocated by a call to setlocale_r - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -29,7 +29,7 @@ __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden) void -__freelocale (__locale_t dataset) +__freelocale (locale_t dataset) { int cnt; diff --git a/locale/global-locale.c b/locale/global-locale.c index a83e463070..6cdc41f527 100644 --- a/locale/global-locale.c +++ b/locale/global-locale.c @@ -1,5 +1,5 @@ /* Locale object representing the global locale controlled by setlocale. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 @@ -61,4 +61,4 @@ struct __locale_struct _nl_global_locale attribute_hidden = #include <tls.h> /* The tsd macros don't permit an initializer. */ -__thread __locale_t __libc_tsd_LOCALE = &_nl_global_locale; +__thread locale_t __libc_tsd_LOCALE = &_nl_global_locale; diff --git a/locale/hashval.h b/locale/hashval.h index b0843b0c50..4f486aaa16 100644 --- a/locale/hashval.h +++ b/locale/hashval.h @@ -1,5 +1,5 @@ /* Implement simple hashing table with string based keys. - Copyright (C) 1994-2016 Free Software Foundation, Inc. + Copyright (C) 1994-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, October 1994. diff --git a/locale/indigits.h b/locale/indigits.h index 88cc17539e..6be69ce123 100644 --- a/locale/indigits.h +++ b/locale/indigits.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 2000. diff --git a/locale/indigitswc.h b/locale/indigitswc.h index 7e9861068c..a0bb026a28 100644 --- a/locale/indigitswc.h +++ b/locale/indigitswc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 2000. diff --git a/locale/iso-4217.def b/locale/iso-4217.def index 414f69bca5..84cebb97da 100644 --- a/locale/iso-4217.def +++ b/locale/iso-4217.def @@ -138,6 +138,7 @@ DEFINE_INT_CURR("SHP") /* St. Helena Pound */ DEFINE_INT_CURR("SLL") /* Sierra Leone Leone */ DEFINE_INT_CURR("SOS") /* Somalia Schilling */ DEFINE_INT_CURR("SRD") /* Suriname Dollar */ +DEFINE_INT_CURR("SSP") /* South Sudanese Pound */ DEFINE_INT_CURR("STD") /* Sao Tome and Principe Dobra */ DEFINE_INT_CURR("SVC") /* El Salvador Colon */ DEFINE_INT_CURR("SYP") /* Syrian Arab Republic Pound */ @@ -167,5 +168,5 @@ DEFINE_INT_CURR("XOF") /* West African Franc (Benin, Ivory Coast, Niger, Senega DEFINE_INT_CURR("XPF") /* French polynesia, New Caledonia, Wallis and Futuna Islands */ DEFINE_INT_CURR("YER") /* Yemeni Rial */ DEFINE_INT_CURR("ZAR") /* South Africa Rand (Lesotho, Namibia) */ -DEFINE_INT_CURR("ZMK") /* Zambian Kwacha */ +DEFINE_INT_CURR("ZMW") /* Zambian Kwacha */ DEFINE_INT_CURR("ZWD") /* Zimbabwe Dollar */ diff --git a/locale/iso-639.def b/locale/iso-639.def index 4bea116180..4d0b493c7c 100644 --- a/locale/iso-639.def +++ b/locale/iso-639.def @@ -46,9 +46,12 @@ DEFINE_LANGUAGE_CODE3 ("Austronesian (Other)", map, map) DEFINE_LANGUAGE_CODE ("Avaric", av, ava, ava) DEFINE_LANGUAGE_CODE ("Avestan", ae, ave, ave) DEFINE_LANGUAGE_CODE3 ("Awadhi", awa, awa) +DEFINE_LANGUAGE_CODE3 ("Aguaruna", agr, agr) DEFINE_LANGUAGE_CODE ("Aymara, Southern", ay, ayc, ayc) DEFINE_LANGUAGE_CODE ("Aymara", ay, aym, aym) DEFINE_LANGUAGE_CODE ("Azerbaijani", az, aze, aze) +DEFINE_LANGUAGE_CODE ("North Azerbaijani", az, azj, aze) +DEFINE_LANGUAGE_CODE ("South Azerbaijani", az, azb, aze) DEFINE_LANGUAGE_CODE3 ("Balinese", ban, ban) DEFINE_LANGUAGE_CODE3 ("Baltic (Other)", bat, bat) DEFINE_LANGUAGE_CODE3 ("Baluchi", bal, bal) @@ -63,7 +66,7 @@ DEFINE_LANGUAGE_CODE3 ("Batak (Indonesia)", btk, btk) DEFINE_LANGUAGE_CODE3 ("Beja", bej, bej) DEFINE_LANGUAGE_CODE ("Belarusian", be, bel, bel) DEFINE_LANGUAGE_CODE3 ("Bemba", bem, bem) -DEFINE_LANGUAGE_CODE ("Bengali", bn, ben, ben) +DEFINE_LANGUAGE_CODE ("Bangla", bn, ben, ben) DEFINE_LANGUAGE_CODE3 ("Berber (Other)", ber, ber) DEFINE_LANGUAGE_CODE3 ("Bhili", bhb, bhb) DEFINE_LANGUAGE_CODE3 ("Bhojpuri", bho, bho) @@ -150,6 +153,7 @@ DEFINE_LANGUAGE_CODE3 ("Ewondo", ewo, ewo) DEFINE_LANGUAGE_CODE3 ("Fang", fan, fan) DEFINE_LANGUAGE_CODE3 ("Fanti", fat, fat) DEFINE_LANGUAGE_CODE ("Faroese", fo, fao, fao) +DEFINE_LANGUAGE_CODE3 ("Fiji Hindi", hif, hif) DEFINE_LANGUAGE_CODE ("Fijian", fj, fij, fij) DEFINE_LANGUAGE_CODE3 ("Filipino; Pilipino", fil, fil) DEFINE_LANGUAGE_CODE ("Finnish", fi, fin, fin) @@ -239,6 +243,7 @@ DEFINE_LANGUAGE_CODE ("Kannada", kn, kan, kan) DEFINE_LANGUAGE_CODE ("Kanuri", kr, kau, kau) DEFINE_LANGUAGE_CODE3 ("Kara-Kalpak", kaa, kaa) DEFINE_LANGUAGE_CODE3 ("Karachay-Balkar", krc, krc) +DEFINE_LANGUAGE_CODE3 ("Karbi", mjw, mjw) DEFINE_LANGUAGE_CODE3 ("Karelian", krl, krl) DEFINE_LANGUAGE_CODE3 ("Karen", kar, kar) DEFINE_LANGUAGE_CODE ("Kashmiri", ks, kas, kas) @@ -312,10 +317,12 @@ DEFINE_LANGUAGE_CODE3 ("Mari", chm, chm) DEFINE_LANGUAGE_CODE ("Marshallese", mh, mah, mah) DEFINE_LANGUAGE_CODE3 ("Marwari", mwr, mwr) DEFINE_LANGUAGE_CODE3 ("Masai", mas, mas) +DEFINE_LANGUAGE_CODE3 ("Morisyen", mfe, mfe) DEFINE_LANGUAGE_CODE3 ("Mayan languages", myn, myn) DEFINE_LANGUAGE_CODE3 ("Meadow Mari", mhr, mhr) DEFINE_LANGUAGE_CODE3 ("Mende", men, men) DEFINE_LANGUAGE_CODE3 ("Mi'kmaq; Micmac", mic, mic) +DEFINE_LANGUAGE_CODE3 ("Miskito", miq, miq) DEFINE_LANGUAGE_CODE3 ("Minangkabau", min, min) DEFINE_LANGUAGE_CODE3 ("Min Bei Chinese", mnp, mnp) DEFINE_LANGUAGE_CODE3 ("Min Dong Chinese", cdo, cdo) @@ -397,6 +404,7 @@ DEFINE_LANGUAGE_CODE ("Romanian", ro, ron, rum) DEFINE_LANGUAGE_CODE3 ("Romany", rom, rom) DEFINE_LANGUAGE_CODE ("Rundi", rn, run, run) DEFINE_LANGUAGE_CODE ("Russian", ru, rus, rus) +DEFINE_LANGUAGE_CODE3 ("Samogitian", sgs, sgs) DEFINE_LANGUAGE_CODE3 ("Salishan languages", sal, sal) DEFINE_LANGUAGE_CODE3 ("Samaritan Aramaic", sam, sam) DEFINE_LANGUAGE_CODE3 ("Sami languages (Other)", smi, smi) @@ -454,6 +462,7 @@ DEFINE_LANGUAGE_CODE ("Tagalog", tl, tgl, tgl) DEFINE_LANGUAGE_CODE ("Tahitian", ty, tah, tah) DEFINE_LANGUAGE_CODE3 ("Tai (Other)", tai, tai) DEFINE_LANGUAGE_CODE ("Tajik", tg, tgk, tgk) +DEFINE_LANGUAGE_CODE3 ("Talossan", tzl, tzl) DEFINE_LANGUAGE_CODE3 ("Tamashek", tmh, tmh) DEFINE_LANGUAGE_CODE ("Tamil", ta, tam, tam) DEFINE_LANGUAGE_CODE ("Tatar", tt, tat, tat) @@ -512,6 +521,7 @@ DEFINE_LANGUAGE_CODE ("Xhosa", xh, xho, xho) DEFINE_LANGUAGE_CODE3 ("Xiang Chinese", hsn, hsn) DEFINE_LANGUAGE_CODE3 ("Yakut", sah, sah) DEFINE_LANGUAGE_CODE3 ("Yao", yao, yao) +DEFINE_LANGUAGE_CODE3 ("Yau (Uruwa)", yuw, yuw) DEFINE_LANGUAGE_CODE3 ("Yapese", yap, yap) DEFINE_LANGUAGE_CODE ("Yiddish", yi, yid, yid) DEFINE_LANGUAGE_CODE ("Yoruba", yo, yor, yor) diff --git a/locale/langinfo.h b/locale/langinfo.h index 481e2263d7..a50cc9b568 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -1,5 +1,5 @@ /* Access to locale-dependent parameters. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -74,7 +74,8 @@ enum DAY_7, /* Saturday */ #define DAY_7 DAY_7 - /* Abbreviated month names. */ + /* Abbreviated month names, in the grammatical form used when the month + is a part of a complete date. */ ABMON_1, /* Jan */ #define ABMON_1 ABMON_1 ABMON_2, @@ -100,7 +101,8 @@ enum ABMON_12, #define ABMON_12 ABMON_12 - /* Long month names. */ + /* Long month names, in the grammatical form used when the month + is a part of a complete date. */ MON_1, /* January */ #define MON_1 MON_1 MON_2, @@ -175,7 +177,8 @@ enum _NL_WDAY_6, /* Friday */ _NL_WDAY_7, /* Saturday */ - /* Abbreviated month names. */ + /* Abbreviated month names, in the grammatical form used when the month + is a part of a complete date. */ _NL_WABMON_1, /* Jan */ _NL_WABMON_2, _NL_WABMON_3, @@ -189,7 +192,8 @@ enum _NL_WABMON_11, _NL_WABMON_12, - /* Long month names. */ + /* Long month names, in the grammatical form used when the month + is a part of a complete date. */ _NL_WMON_1, /* January */ _NL_WMON_2, _NL_WMON_3, @@ -231,6 +235,80 @@ enum _NL_TIME_CODESET, + /* Long month names, in the grammatical form used when the month + is named by itself. */ + __ALTMON_1, /* January */ + __ALTMON_2, + __ALTMON_3, + __ALTMON_4, + __ALTMON_5, + __ALTMON_6, + __ALTMON_7, + __ALTMON_8, + __ALTMON_9, + __ALTMON_10, + __ALTMON_11, + __ALTMON_12, +#ifdef __USE_GNU +# define ALTMON_1 __ALTMON_1 +# define ALTMON_2 __ALTMON_2 +# define ALTMON_3 __ALTMON_3 +# define ALTMON_4 __ALTMON_4 +# define ALTMON_5 __ALTMON_5 +# define ALTMON_6 __ALTMON_6 +# define ALTMON_7 __ALTMON_7 +# define ALTMON_8 __ALTMON_8 +# define ALTMON_9 __ALTMON_9 +# define ALTMON_10 __ALTMON_10 +# define ALTMON_11 __ALTMON_11 +# define ALTMON_12 __ALTMON_12 +#endif + + /* Long month names, in the grammatical form used when the month + is named by itself. */ + _NL_WALTMON_1, /* January */ + _NL_WALTMON_2, + _NL_WALTMON_3, + _NL_WALTMON_4, + _NL_WALTMON_5, + _NL_WALTMON_6, + _NL_WALTMON_7, + _NL_WALTMON_8, + _NL_WALTMON_9, + _NL_WALTMON_10, + _NL_WALTMON_11, + _NL_WALTMON_12, + + /* Abbreviated month names, in the grammatical form used when the month + is named by itself. */ + _NL_ABALTMON_1, /* Jan */ + _NL_ABALTMON_2, + _NL_ABALTMON_3, + _NL_ABALTMON_4, + _NL_ABALTMON_5, + _NL_ABALTMON_6, + _NL_ABALTMON_7, + _NL_ABALTMON_8, + _NL_ABALTMON_9, + _NL_ABALTMON_10, + _NL_ABALTMON_11, + _NL_ABALTMON_12, + + /* Abbreviated month names, in the grammatical form used when the month + is named by itself. */ + _NL_WABALTMON_1, /* Jan */ + _NL_WABALTMON_2, + _NL_WABALTMON_3, + _NL_WABALTMON_4, + _NL_WABALTMON_5, + _NL_WABALTMON_6, + _NL_WABALTMON_7, + _NL_WABALTMON_8, + _NL_WABALTMON_9, + _NL_WABALTMON_10, + _NL_WABALTMON_11, + _NL_WABALTMON_12, + _NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */ /* LC_COLLATE category: text sorting. @@ -583,15 +661,12 @@ enum extern char *nl_langinfo (nl_item __item) __THROW; -#ifdef __USE_XOPEN2K -/* This interface is for the extended locale model. See <locale.h> for - more information. */ - -/* Get locale datatype definition. */ -# include <xlocale.h> +#ifdef __USE_XOPEN2K8 +/* POSIX.1-2008 extended locale interface (see locale.h). */ +# include <bits/types/locale_t.h> /* Just like nl_langinfo but get the information from the locale object L. */ -extern char *nl_langinfo_l (nl_item __item, __locale_t __l); +extern char *nl_langinfo_l (nl_item __item, locale_t __l); #endif __END_DECLS diff --git a/locale/lc-address.c b/locale/lc-address.c index 85fe15a24d..18480e0337 100644 --- a/locale/lc-address.c +++ b/locale/lc-address.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_ADDRESS category. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 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 diff --git a/locale/lc-collate.c b/locale/lc-collate.c index b88d2d1f39..c2b1c04442 100644 --- a/locale/lc-collate.c +++ b/locale/lc-collate.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_COLLATE category. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/lc-ctype.c b/locale/lc-ctype.c index 20ffcd08f9..417db1a6b6 100644 --- a/locale/lc-ctype.c +++ b/locale/lc-ctype.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_CTYPE category. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/lc-identification.c b/locale/lc-identification.c index 7605e82962..841553f866 100644 --- a/locale/lc-identification.c +++ b/locale/lc-identification.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_IDENTIFICATION category. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 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 diff --git a/locale/lc-measurement.c b/locale/lc-measurement.c index 5089488f59..360ebc2c53 100644 --- a/locale/lc-measurement.c +++ b/locale/lc-measurement.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_MEASUREMENT category. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 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 diff --git a/locale/lc-messages.c b/locale/lc-messages.c index 0fdf692714..f498c483db 100644 --- a/locale/lc-messages.c +++ b/locale/lc-messages.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_MESSAGES category. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/lc-monetary.c b/locale/lc-monetary.c index 02eedd657e..ec3f1a372b 100644 --- a/locale/lc-monetary.c +++ b/locale/lc-monetary.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_MONETARY category. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/lc-name.c b/locale/lc-name.c index 8b42f6873c..b034152f30 100644 --- a/locale/lc-name.c +++ b/locale/lc-name.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_NAME category. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 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 diff --git a/locale/lc-numeric.c b/locale/lc-numeric.c index 20db1b7a96..2ae7436f0f 100644 --- a/locale/lc-numeric.c +++ b/locale/lc-numeric.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_NUMERIC category. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/lc-paper.c b/locale/lc-paper.c index a1d9c720ea..bd3270a7d2 100644 --- a/locale/lc-paper.c +++ b/locale/lc-paper.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_PAPER category. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 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 diff --git a/locale/lc-telephone.c b/locale/lc-telephone.c index 37acea16f5..c29e1db607 100644 --- a/locale/lc-telephone.c +++ b/locale/lc-telephone.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_TELEPHONE category. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 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 diff --git a/locale/lc-time.c b/locale/lc-time.c index 6a77249c05..537a3acfbe 100644 --- a/locale/lc-time.c +++ b/locale/lc-time.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_TIME category. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/loadarchive.c b/locale/loadarchive.c index 0ac11afa4a..516d30d8d1 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -1,5 +1,5 @@ /* Code to load locale data from the locale archive file. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 @@ -130,7 +130,6 @@ calculate_head_size (const struct locarhead *h) structure. If successful, sets *NAMEP to point directly into the mapped archive string table; that way, the next call can short-circuit strcmp. */ struct __locale_data * -internal_function _nl_load_locale_from_archive (int category, const char **namep) { const char *name = *namep; @@ -203,7 +202,7 @@ _nl_load_locale_from_archive (int category, const char **namep) archmapped = &headmap; /* The archive has never been opened. */ - fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); + fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); if (fd < 0) /* Cannot open the archive, for whatever reason. */ return NULL; @@ -213,7 +212,7 @@ _nl_load_locale_from_archive (int category, const char **namep) /* stat failed, very strange. */ close_and_out: if (fd >= 0) - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); return NULL; } @@ -253,7 +252,7 @@ _nl_load_locale_from_archive (int category, const char **namep) { /* We've mapped the whole file already, so we can be sure we won't need this file descriptor later. */ - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); fd = -1; } @@ -398,8 +397,8 @@ _nl_load_locale_from_archive (int category, const char **namep) if (fd == -1) { struct stat64 st; - fd = open_not_cancel_2 (archfname, - O_RDONLY|O_LARGEFILE|O_CLOEXEC); + fd = __open_nocancel (archfname, + O_RDONLY|O_LARGEFILE|O_CLOEXEC); if (fd == -1) /* Cannot open the archive, for whatever reason. */ return NULL; @@ -452,7 +451,7 @@ _nl_load_locale_from_archive (int category, const char **namep) /* We don't need the file descriptor any longer. */ if (fd >= 0) - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); fd = -1; /* We succeeded in mapping all the necessary regions of the archive. @@ -462,7 +461,7 @@ _nl_load_locale_from_archive (int category, const char **namep) if (__glibc_unlikely (lia == NULL)) return NULL; - lia->name = strdup (*namep); + lia->name = __strdup (*namep); if (__glibc_unlikely (lia->name == NULL)) { free (lia); diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 2b589eeb8c..15f93bec80 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -1,5 +1,5 @@ /* Functions to read locale data files. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -44,8 +44,12 @@ static const size_t _nl_category_num_items[] = #define NO_PAREN(arg, rest...) arg, ##rest +/* The size of the array must be specified explicitly because some of + the 'items' may be subarrays, which will cause the compiler to deduce + an incorrect size from the initializer. */ #define DEFINE_CATEGORY(category, category_name, items, a) \ -static const enum value_type _nl_value_type_##category[] = { NO_PAREN items }; +static const enum value_type _nl_value_type_##category \ + [_NL_ITEM_INDEX (_NL_NUM_##category)] = { NO_PAREN items }; #define DEFINE_ELEMENT(element, element_name, optstd, type, rest...) \ [_NL_ITEM_INDEX (element)] = type, #include "categories.def" @@ -61,7 +65,6 @@ static const enum value_type *const _nl_value_types[] = struct __locale_data * -internal_function _nl_intern_locale_data (int category, const void *data, size_t datasize) { const struct @@ -152,7 +155,7 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize) if (!LOCFILE_ALIGNED_P (idx)) goto puntdata; newdata->values[cnt].word = - *((const u_int32_t *) (newdata->filedata + idx)); + *((const uint32_t *) (newdata->filedata + idx)); } } @@ -160,7 +163,6 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize) } void -internal_function _nl_load_locale (struct loaded_l10nfile *file, int category) { int fd; @@ -173,7 +175,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) file->decided = 1; file->data = NULL; - fd = open_not_cancel_2 (file->filename, O_RDONLY | O_CLOEXEC); + fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC); if (__builtin_expect (fd, 0) < 0) /* Cannot open the file. */ return; @@ -181,7 +183,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0) { puntfd: - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); return; } if (__glibc_unlikely (S_ISDIR (st.st_mode))) @@ -191,7 +193,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) char *newp; size_t filenamelen; - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); filenamelen = strlen (file->filename); newp = (char *) alloca (filenamelen @@ -201,7 +203,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) _nl_category_names.str + _nl_category_name_idxs[category], _nl_category_name_sizes[category] + 1); - fd = open_not_cancel_2 (newp, O_RDONLY | O_CLOEXEC); + fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC); if (__builtin_expect (fd, 0) < 0) return; @@ -238,7 +240,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) char *p = (char *) filedata; while (to_read > 0) { - nread = read_not_cancel (fd, p, to_read); + nread = __read_nocancel (fd, p, to_read); if (__builtin_expect (nread, 1) <= 0) { free (filedata); @@ -257,7 +259,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) #endif /* _POSIX_MAPPED_FILES */ /* We have mapped the data, so we no longer need the descriptor. */ - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); if (__glibc_unlikely (filedata == NULL)) /* We failed to map or read the data. */ @@ -282,7 +284,6 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) } void -internal_function _nl_unload_locale (struct __locale_data *locale) { if (locale->private.cleanup) diff --git a/locale/locale.h b/locale/locale.h index 2f85c6cfb1..88781df998 100644 --- a/locale/locale.h +++ b/locale/locale.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 @@ -47,8 +47,6 @@ __BEGIN_DECLS #define LC_IDENTIFICATION __LC_IDENTIFICATION -__BEGIN_NAMESPACE_STD - /* Structure giving information about numeric and monetary notation. */ struct lconv { @@ -126,30 +124,22 @@ extern char *setlocale (int __category, const char *__locale) __THROW; /* Return the numeric/monetary information for the current locale. */ extern struct lconv *localeconv (void) __THROW; -__END_NAMESPACE_STD - #ifdef __USE_XOPEN2K8 -/* The concept of one static locale per category is not very well - thought out. Many applications will need to process its data using - information from several different locales. Another application is - the implementation of the internationalization handling in the - upcoming ISO C++ standard library. To support this another set of - the functions using locale data exist which have an additional - argument. - - Attention: all these functions are *not* standardized in any form. - This is a proof-of-concept implementation. */ - -/* Get locale datatype definition. */ -# include <xlocale.h> +/* POSIX.1-2008 extends the locale interface with functions for + explicit creation and manipulation of 'locale_t' objects + representing locale contexts, and a set of parallel + locale-sensitive text processing functions that take a locale_t + argument. This enables applications to work with data from + multiple locales simultaneously and thread-safely. */ +# include <bits/types/locale_t.h> /* Return a reference to a data structure representing a set of locale datasets. Unlike for the CATEGORY parameter for `setlocale' the CATEGORY_MASK parameter here uses a single bit for each category, made by OR'ing together LC_*_MASK bits above. */ -extern __locale_t newlocale (int __category_mask, const char *__locale, - __locale_t __base) __THROW; +extern locale_t newlocale (int __category_mask, const char *__locale, + locale_t __base) __THROW; /* These are the bits that can be set in the CATEGORY_MASK argument to `newlocale'. In the GNU implementation, LC_FOO_MASK has the value @@ -183,22 +173,22 @@ extern __locale_t newlocale (int __category_mask, const char *__locale, /* Return a duplicate of the set of locale in DATASET. All usage counters are increased if necessary. */ -extern __locale_t duplocale (__locale_t __dataset) __THROW; +extern locale_t duplocale (locale_t __dataset) __THROW; /* Free the data associated with a locale dataset previously returned by a call to `setlocale_r'. */ -extern void freelocale (__locale_t __dataset) __THROW; +extern void freelocale (locale_t __dataset) __THROW; /* Switch the current thread's locale to DATASET. If DATASET is null, instead just return the current setting. The special value LC_GLOBAL_LOCALE is the initial setting for all threads and can also be installed any time, meaning the thread uses the global settings controlled by `setlocale'. */ -extern __locale_t uselocale (__locale_t __dataset) __THROW; +extern locale_t uselocale (locale_t __dataset) __THROW; /* This value can be passed to `uselocale' and may be returned by it. Passing this value to any other function has undefined behavior. */ -# define LC_GLOBAL_LOCALE ((__locale_t) -1L) +# define LC_GLOBAL_LOCALE ((locale_t) -1L) #endif diff --git a/locale/localeconv.c b/locale/localeconv.c index 85c6d2ea4a..5ee879e7b7 100644 --- a/locale/localeconv.c +++ b/locale/localeconv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/locale/localeinfo.h b/locale/localeinfo.h index 5c4e6ef424..68822a6319 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -1,5 +1,5 @@ /* Declarations for internal libc locale interfaces - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -63,7 +63,7 @@ struct __locale_data the data. */ struct { - void (*cleanup) (struct __locale_data *) internal_function; + void (*cleanup) (struct __locale_data *); union { void *data; @@ -214,9 +214,9 @@ extern struct __locale_struct _nl_global_locale attribute_hidden; /* This fetches the thread-local locale_t pointer, either one set with uselocale or &_nl_global_locale. */ -#define _NL_CURRENT_LOCALE (__libc_tsd_get (__locale_t, LOCALE)) +#define _NL_CURRENT_LOCALE (__libc_tsd_get (locale_t, LOCALE)) #include <libc-tsd.h> -__libc_tsd_define (extern, __locale_t, LOCALE) +__libc_tsd_define (extern, locale_t, LOCALE) /* For static linking it is desireable to avoid always linking in the code @@ -260,12 +260,15 @@ extern __thread struct __locale_data *const *_nl_current_##category \ #define _NL_CURRENT_WORD(category, item) \ ((uint32_t) (*_nl_current_##category)->values[_NL_ITEM_INDEX (item)].word) -/* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */ +/* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. The symbol + _nl_current_CATEGORY_used is set to a value unequal to zero to mark this + category as used. On S390 the used relocation to load the symbol address + can only handle even addresses. */ #define _NL_CURRENT_DEFINE(category) \ __thread struct __locale_data *const *_nl_current_##category \ attribute_hidden = &_nl_global_locale.__locales[category]; \ asm (".globl " __SYMBOL_PREFIX "_nl_current_" #category "_used\n" \ - _NL_CURRENT_DEFINE_ABS (_nl_current_##category##_used, 1)); + _NL_CURRENT_DEFINE_ABS (_nl_current_##category##_used, 2)); #ifdef HAVE_ASM_SET_DIRECTIVE # define _NL_CURRENT_DEFINE_ABS(sym, val) ".set " #sym ", " #val #else @@ -299,6 +302,27 @@ extern __thread struct __locale_data *const *_nl_current_##category \ #endif +/* Extract CATEGORY locale's string for ITEM. */ +static inline const char * +_nl_lookup (locale_t l, int category, int item) +{ + return l->__locales[category]->values[_NL_ITEM_INDEX (item)].string; +} + +/* Extract CATEGORY locale's wide string for ITEM. */ +static inline const wchar_t * +_nl_lookup_wstr (locale_t l, int category, int item) +{ + return (wchar_t *) l->__locales[category] + ->values[_NL_ITEM_INDEX (item)].wstr; +} + +/* Extract the CATEGORY locale's word for ITEM. */ +static inline uint32_t +_nl_lookup_word (locale_t l, int category, int item) +{ + return l->__locales[category]->values[_NL_ITEM_INDEX (item)].word; +} /* Default search path if no LOCPATH environment variable. */ extern const char _nl_default_locale_path[] attribute_hidden; @@ -312,19 +336,18 @@ extern const char _nl_default_locale_path[] attribute_hidden; extern struct __locale_data *_nl_find_locale (const char *locale_path, size_t locale_path_len, int category, const char **name) - internal_function attribute_hidden; + attribute_hidden; /* Try to load the file described by FILE. */ extern void _nl_load_locale (struct loaded_l10nfile *file, int category) - internal_function attribute_hidden; + attribute_hidden; /* Free all resource. */ -extern void _nl_unload_locale (struct __locale_data *locale) - internal_function attribute_hidden; +extern void _nl_unload_locale (struct __locale_data *locale) attribute_hidden; /* Free the locale and give back all memory if the usage count is one. */ extern void _nl_remove_locale (int locale, struct __locale_data *data) - internal_function attribute_hidden; + attribute_hidden; /* Find the locale *NAMEP in the locale archive, and return the internalized data structure for its CATEGORY data. If this locale has @@ -333,7 +356,7 @@ extern void _nl_remove_locale (int locale, struct __locale_data *data) archive string table; that way, the next call can short-circuit strcmp. */ extern struct __locale_data *_nl_load_locale_from_archive (int category, const char **namep) - internal_function attribute_hidden; + attribute_hidden; /* Subroutine of setlocale's __libc_subfreeres hook. */ extern void _nl_archive_subfreeres (void) attribute_hidden; @@ -349,40 +372,39 @@ extern void _nl_locale_subfreeres (void) attribute_hidden; extern struct __locale_data *_nl_intern_locale_data (int category, const void *data, size_t datasize) - internal_function attribute_hidden; + attribute_hidden; /* Return `era' entry which corresponds to TP. Used in strftime. */ extern struct era_entry *_nl_get_era_entry (const struct tm *tp, struct __locale_data *lc_time) - internal_function attribute_hidden; + attribute_hidden; /* Return `era' cnt'th entry . Used in strptime. */ extern struct era_entry *_nl_select_era_entry (int cnt, struct __locale_data *lc_time) - internal_function attribute_hidden; + attribute_hidden; /* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */ extern const char *_nl_get_alt_digit (unsigned int number, struct __locale_data *lc_time) - internal_function attribute_hidden; + attribute_hidden; /* Similar, but now for wide characters. */ extern const wchar_t *_nl_get_walt_digit (unsigned int number, struct __locale_data *lc_time) - internal_function attribute_hidden; + attribute_hidden; /* Parse string as alternative digit and return numeric value. */ extern int _nl_parse_alt_digit (const char **strp, struct __locale_data *lc_time) - internal_function attribute_hidden; + attribute_hidden; /* Postload processing. */ extern void _nl_postload_ctype (void); /* Functions used for the `private.cleanup' hook. */ -extern void _nl_cleanup_time (struct __locale_data *) - internal_function attribute_hidden; +extern void _nl_cleanup_time (struct __locale_data *) attribute_hidden; #endif /* localeinfo.h */ diff --git a/locale/localename.c b/locale/localename.c index 1d29ef9a40..15148b6d82 100644 --- a/locale/localename.c +++ b/locale/localename.c @@ -1,5 +1,5 @@ /* current locale setting names - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 diff --git a/locale/locarchive.h b/locale/locarchive.h index c1acd0bd87..2ca068bad6 100644 --- a/locale/locarchive.h +++ b/locale/locarchive.h @@ -1,5 +1,5 @@ /* Definitions for locale archive handling. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 diff --git a/locale/mb_cur_max.c b/locale/mb_cur_max.c index c623c45822..5cc99df055 100644 --- a/locale/mb_cur_max.c +++ b/locale/mb_cur_max.c @@ -1,6 +1,6 @@ /* Return number of characters in multibyte representation for current character set. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/locale/newlocale.c b/locale/newlocale.c index 3deecc42df..2737a4fc22 100644 --- a/locale/newlocale.c +++ b/locale/newlocale.c @@ -1,5 +1,5 @@ /* Return a reference to locale information record. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -39,13 +39,13 @@ __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden) } while (0) -__locale_t -__newlocale (int category_mask, const char *locale, __locale_t base) +locale_t +__newlocale (int category_mask, const char *locale, locale_t base) { /* Intermediate memory for result. */ const char *newnames[__LC_LAST]; struct __locale_struct result; - __locale_t result_ptr; + locale_t result_ptr; char *locale_path; size_t locale_path_len; const char *locpath_var; @@ -86,7 +86,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base) dataset using the C locale data. */ if (category_mask == 0) { - result_ptr = (__locale_t) malloc (sizeof (struct __locale_struct)); + result_ptr = (locale_t) malloc (sizeof (struct __locale_struct)); if (result_ptr == NULL) return NULL; *result_ptr = result; diff --git a/locale/nl_langinfo.c b/locale/nl_langinfo.c index d523564629..bf868648cd 100644 --- a/locale/nl_langinfo.c +++ b/locale/nl_langinfo.c @@ -1,5 +1,5 @@ /* User interface for extracting locale-dependent parameters. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/locale/nl_langinfo_l.c b/locale/nl_langinfo_l.c index 0032c0bb30..62b3bd2817 100644 --- a/locale/nl_langinfo_l.c +++ b/locale/nl_langinfo_l.c @@ -1,5 +1,5 @@ /* User interface for extracting locale-dependent parameters. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -27,7 +27,7 @@ /* Return a string with the data for locale-dependent parameter ITEM. */ char * -__nl_langinfo_l (nl_item item, __locale_t l) +__nl_langinfo_l (nl_item item, locale_t l) { int category = _NL_ITEM_CATEGORY (item); unsigned int index = _NL_ITEM_INDEX (item); diff --git a/locale/outdigits.h b/locale/outdigits.h index 8834ad5786..757078e202 100644 --- a/locale/outdigits.h +++ b/locale/outdigits.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 2000. diff --git a/locale/outdigitswc.h b/locale/outdigitswc.h index 1167ba2123..c3036a6a51 100644 --- a/locale/outdigitswc.h +++ b/locale/outdigitswc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 2000. diff --git a/locale/programs/3level.h b/locale/programs/3level.h index 19c7daf731..836dba5d5d 100644 --- a/locale/programs/3level.h +++ b/locale/programs/3level.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Bruno Haible <haible@clisp.cons.org>, 2000. diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c index 99fcd355e0..34a8d32c92 100644 --- a/locale/programs/charmap-dir.c +++ b/locale/programs/charmap-dir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -16,7 +16,6 @@ #include <dirent.h> #include <errno.h> -#include <error.h> #include <fcntl.h> #include <libintl.h> #include <spawn.h> @@ -54,8 +53,9 @@ charmap_opendir (const char *directory) dir = opendir (directory); if (dir == NULL) { - WITH_CUR_LOCALE (error (1, errno, gettext ("\ -cannot read character map directory `%s'"), directory)); + record_error (1, errno, gettext ("\ +cannot read character map directory `%s'"), + directory); return NULL; } @@ -115,11 +115,9 @@ charmap_readdir (CHARMAP_DIR *cdir) stpcpy (stpcpy (cdir->pathname, cdir->directory), dirent->d_name); filename = cdir->pathname + cdir->directory_len; -#ifdef _DIRENT_HAVE_D_TYPE if (dirent->d_type != DT_UNKNOWN && dirent->d_type != DT_LNK) mode = DTTOIF (dirent->d_type); else -#endif { struct stat64 statbuf; diff --git a/locale/programs/charmap-dir.h b/locale/programs/charmap-dir.h index c8c916b4f6..95a7d1f88c 100644 --- a/locale/programs/charmap-dir.h +++ b/locale/programs/charmap-dir.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify diff --git a/locale/programs/charmap-kw.gperf b/locale/programs/charmap-kw.gperf index 96cebcd721..4c9512a02a 100644 --- a/locale/programs/charmap-kw.gperf +++ b/locale/programs/charmap-kw.gperf @@ -1,5 +1,5 @@ %{ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.org>. diff --git a/locale/programs/charmap-kw.h b/locale/programs/charmap-kw.h index 983d287880..0b3ed749fa 100644 --- a/locale/programs/charmap-kw.h +++ b/locale/programs/charmap-kw.h @@ -30,7 +30,7 @@ #line 1 "charmap-kw.gperf" -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.org>. diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c index d7580e05c4..2d54dd3c02 100644 --- a/locale/programs/charmap.c +++ b/locale/programs/charmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. @@ -26,7 +26,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <error.h> #include <stdint.h> #include "localedef.h" @@ -135,8 +134,9 @@ charmap_read (const char *filename, int verbose, int error_not_found, result = parse_charmap (cmfile, verbose, be_quiet); if (result == NULL && error_not_found) - WITH_CUR_LOCALE (error (0, errno, _("\ -character map file `%s' not found"), filename)); + record_error (0, errno, + _("character map file `%s' not found"), + filename); } if (result == NULL && filename != NULL && strchr (filename, '/') == NULL) @@ -192,8 +192,9 @@ character map file `%s' not found"), filename)); result = parse_charmap (cmfile, verbose, be_quiet); if (result == NULL) - WITH_CUR_LOCALE (error (4, errno, _("\ -default character map file `%s' not found"), DEFAULT_CHARMAP)); + record_error (4, errno, + _("default character map file `%s' not found"), + DEFAULT_CHARMAP); } if (result != NULL && result->code_set_name == NULL) @@ -255,9 +256,15 @@ default character map file `%s' not found"), DEFAULT_CHARMAP)); if (failed) { - WITH_CUR_LOCALE (fprintf (stderr, _("\ -character map `%s' is not ASCII compatible, locale not ISO C compliant\n"), - result->code_set_name)); + /* A user may disable the ASCII compatibility warning check, + but we must remember that the encoding is not ASCII + compatible, since it may have other implications. Later + we will set _NL_CTYPE_MAP_TO_NONASCII from this value. */ + if (warn_ascii) + record_warning (_( +"character map `%s' is not ASCII compatible, locale not ISO C compliant " +"[--no-warnings=ascii]"), + result->code_set_name); enc_not_ascii_compatible = true; } } @@ -333,10 +340,9 @@ parse_charmap (struct linereader *cmfile, int verbose, int be_quiet) result->mb_cur_min = result->mb_cur_max; if (result->mb_cur_min > result->mb_cur_max) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: <mb_cur_max> must be greater than <mb_cur_min>\n"), - cmfile->fname)); + cmfile->fname); result->mb_cur_min = result->mb_cur_max; } @@ -395,11 +401,10 @@ parse_charmap (struct linereader *cmfile, int verbose, int be_quiet) if (arg->tok != tok_number) goto badarg; - if (verbose - && ((nowtok == tok_mb_cur_max + if ((nowtok == tok_mb_cur_max && result->mb_cur_max != 0) || (nowtok == tok_mb_cur_max - && result->mb_cur_max != 0))) + && result->mb_cur_max != 0)) lr_error (cmfile, _("duplicate definition of <%s>"), nowtok == tok_mb_cur_min ? "mb_cur_min" : "mb_cur_max"); @@ -839,16 +844,16 @@ only WIDTH definitions are allowed to follow the CHARMAP definition")); continue; default: - WITH_CUR_LOCALE (error (5, 0, _("%s: error in state machine"), - __FILE__)); + record_error (5, 0, _("%s: error in state machine"), + __FILE__); /* NOTREACHED */ } break; } - if (state != 91 && !be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("%s: premature end of file"), - cmfile->fname)); + if (state != 91) + record_error (0, 0, _("%s: premature end of file"), + cmfile->fname); lr_close (cmfile); diff --git a/locale/programs/charmap.h b/locale/programs/charmap.h index 9e7066f96c..66a4385eef 100644 --- a/locale/programs/charmap.h +++ b/locale/programs/charmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. diff --git a/locale/programs/config.h b/locale/programs/config.h index f606365f2a..9956cd8446 100644 --- a/locale/programs/config.h +++ b/locale/programs/config.h @@ -1,5 +1,5 @@ /* Configuration for localedef program. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/locale/programs/ld-address.c b/locale/programs/ld-address.c index f13331941e..3972bb1969 100644 --- a/locale/programs/ld-address.c +++ b/locale/programs/ld-address.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -20,7 +20,6 @@ #endif #include <byteswap.h> -#include <error.h> #include <langinfo.h> #include <string.h> #include <stdint.h> @@ -131,9 +130,8 @@ address_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (address == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_ADDRESS")); + record_warning (_("\ +No definition for %s category found"), "LC_ADDRESS"); address_startup (NULL, locale, 0); address = locale->categories[LC_ADDRESS].address; nothing = 1; @@ -143,20 +141,20 @@ No definition for %s category found"), "LC_ADDRESS")); if (address->postal_fmt == NULL) { if (! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_ADDRESS", "postal_fmt")); + record_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. */ + /* We must check whether the format string contains only the allowed + escape sequences. Last checked against ISO 30112 WD10 [2014]. */ const char *cp = address->postal_fmt; if (*cp == '\0') - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"), - "LC_ADDRESS", "postal_fmt")); + record_error (0, 0, _("%s: field `%s' must not be empty"), + "LC_ADDRESS", "postal_fmt"); else while (*cp != '\0') { @@ -165,11 +163,11 @@ No definition for %s category found"), "LC_ADDRESS")); if (*++cp == 'R') /* Romanize-flag. */ ++cp; - if (strchr ("afdbshNtreCzTSc%", *cp) == NULL) + if (strchr ("nafdbshNtreClzTSc%", *cp) == NULL) { - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: invalid escape `%%%c' sequence in field `%s'"), - "LC_ADDRESS", *cp, "postal_fmt")); + "LC_ADDRESS", *cp, "postal_fmt"); break; } } @@ -181,8 +179,7 @@ No definition for %s category found"), "LC_ADDRESS")); if (address->cat == NULL) \ { \ if (verbose && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_ADDRESS", #cat)); \ + record_warning (_("%s: field `%s' not defined"), "LC_ADDRESS", #cat); \ address->cat = ""; \ } @@ -199,16 +196,16 @@ No definition for %s category found"), "LC_ADDRESS")); if (address->lang_term == NULL) { if (verbose && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_ADDRESS", "lang_term")); + record_warning (_("%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) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"), - "LC_ADDRESS", "lang_term")); + record_warning (_("%s: field `%s' must not be empty"), "LC_ADDRESS", + "lang_term"); cnt = sizeof (iso639) / sizeof (iso639[0]); } else @@ -218,9 +215,9 @@ No definition for %s category found"), "LC_ADDRESS")); if (strcmp (address->lang_term, iso639[cnt].term) == 0) break; if (cnt == sizeof (iso639) / sizeof (iso639[0])) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: terminology language code `%s' not defined"), - "LC_ADDRESS", address->lang_term)); + "LC_ADDRESS", address->lang_term); } if (address->lang_ab == NULL) @@ -228,8 +225,8 @@ No definition for %s category found"), "LC_ADDRESS")); if ((cnt == sizeof (iso639) / sizeof (iso639[0]) || iso639[cnt].ab[0] != '\0') && verbose && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_ADDRESS", "lang_ab")); + record_warning (_("%s: field `%s' not defined"), "LC_ADDRESS", + "lang_ab"); address->lang_ab = ""; } else if (address->lang_ab[0] == '\0') @@ -237,14 +234,14 @@ No definition for %s category found"), "LC_ADDRESS")); if ((cnt == sizeof (iso639) / sizeof (iso639[0]) || iso639[cnt].ab[0] != '\0') && verbose) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"), - "LC_ADDRESS", "lang_ab")); + record_warning (_("%s: field `%s' must not be empty"), + "LC_ADDRESS", "lang_ab"); } else if (cnt < sizeof (iso639) / sizeof (iso639[0]) && iso639[cnt].ab[0] == '\0') { - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be defined"), - "LC_ADDRESS", "lang_ab")); + record_error (0, 0, _("%s: field `%s' must not be defined"), + "LC_ADDRESS", "lang_ab"); address->lang_ab = ""; } @@ -257,16 +254,16 @@ No definition for %s category found"), "LC_ADDRESS")); if (strcmp (address->lang_ab, iso639[cnt].ab) == 0) break; if (cnt == sizeof (iso639) / sizeof (iso639[0])) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: language abbreviation `%s' not defined"), - "LC_ADDRESS", address->lang_ab)); + "LC_ADDRESS", address->lang_ab); } else if (strcmp (iso639[cnt].ab, address->lang_ab) != 0 && iso639[cnt].ab[0] != '\0') - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: `%s' value does not match `%s' value"), - "LC_ADDRESS", "lang_ab", "lang_term")); + "LC_ADDRESS", "lang_ab", "lang_term"); } if (address->lang_lib == NULL) @@ -275,8 +272,8 @@ No definition for %s category found"), "LC_ADDRESS")); else if (address->lang_lib[0] == '\0') { if (verbose) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"), - "LC_ADDRESS", "lang_lib")); + record_warning (_("%s: field `%s' must not be empty"), + "LC_ADDRESS", "lang_lib"); } else { @@ -286,22 +283,22 @@ No definition for %s category found"), "LC_ADDRESS")); if (strcmp (address->lang_lib, iso639[cnt].lib) == 0) break; if (cnt == sizeof (iso639) / sizeof (iso639[0])) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: language abbreviation `%s' not defined"), - "LC_ADDRESS", address->lang_lib)); + "LC_ADDRESS", address->lang_lib); } else if (strcmp (iso639[cnt].ab, address->lang_ab) != 0) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: `%s' value does not match `%s' value"), "LC_ADDRESS", "lang_lib", - helper == 1 ? "lang_term" : "lang_ab")); + helper == 1 ? "lang_term" : "lang_ab"); } if (address->country_num == 0) { if (verbose && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_ADDRESS", "country_num")); + record_warning (_("%s: field `%s' not defined"), "LC_ADDRESS", + "country_num"); cnt = sizeof (iso3166) / sizeof (iso3166[0]); } else @@ -311,36 +308,35 @@ No definition for %s category found"), "LC_ADDRESS")); break; if (cnt == sizeof (iso3166) / sizeof (iso3166[0])) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: numeric country code `%d' not valid"), - "LC_ADDRESS", address->country_num)); + "LC_ADDRESS", address->country_num); } if (address->country_ab2 == NULL) { if (verbose && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_ADDRESS", "country_ab2")); + record_warning (_("%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) - WITH_CUR_LOCALE (error (0, 0, - _("%s: `%s' value does not match `%s' value"), - "LC_ADDRESS", "country_ab2", "country_num")); + record_error (0, 0, _("%s: `%s' value does not match `%s' value"), + "LC_ADDRESS", "country_ab2", "country_num"); if (address->country_ab3 == NULL) { if (verbose && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_ADDRESS", "country_ab3")); + record_warning (_("%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) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: `%s' value does not match `%s' value"), - "LC_ADDRESS", "country_ab3", "country_num")); + "LC_ADDRESS", "country_ab3", "country_num"); } @@ -485,8 +481,8 @@ address_read (struct linereader *ldfile, struct localedef_t *result, address->cat = arg->val.str.startmb; \ else \ { \ - char *numbuf = (char *) xmalloc (11); \ - snprintf (numbuf, 11, "%ld", arg->val.num); \ + char *numbuf = (char *) xmalloc (21); \ + snprintf (numbuf, 21, "%ld", arg->val.num); \ address->cat = numbuf; \ } \ } \ diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c index 1e125f60fd..d2eebcfdbb 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -20,7 +20,6 @@ #endif #include <errno.h> -#include <error.h> #include <stdlib.h> #include <wchar.h> #include <stdint.h> @@ -1560,10 +1559,9 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap) if (collate == NULL) { - /* No data, no check. */ - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("No definition for %s category found"), - "LC_COLLATE")); + /* No data, no check. Issue a warning. */ + record_warning (_("No definition for %s category found"), + "LC_COLLATE"); return; } @@ -1579,9 +1577,9 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap) && ((sect->rules[i] & sort_position) != (collate->current_section->rules[i] & sort_position))) { - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: `position' must be used for a specific level in all sections or none"), - "LC_COLLATE")); + "LC_COLLATE"); break; } @@ -1602,10 +1600,9 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap) { if (runp->weights[i].w[j]->weights == NULL) { - WITH_CUR_LOCALE (error_at_line (0, 0, runp->file, - runp->line, - _("symbol `%s' not defined"), - runp->weights[i].w[j]->name)); + record_error_at_line (0, 0, runp->file, runp->line, + _("symbol `%s' not defined"), + runp->weights[i].w[j]->name); need_undefined = 1; runp->weights[i].w[j] = &collate->undefined; @@ -1678,14 +1675,13 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap) /* This should not happen. It means that we have to symbols with the same byte sequence. It is of course an error. */ - WITH_CUR_LOCALE (error_at_line (0, 0, (*eptr)->file, - (*eptr)->line, - _("\ + record_error_at_line (0, 0, (*eptr)->file, + (*eptr)->line, + _("\ symbol `%s' has the same encoding as"), (*eptr)->name); - error_at_line (0, 0, runp->file, - runp->line, - _("symbol `%s'"), - runp->name)); + + record_error_at_line (0, 0, runp->file, runp->line, + _("symbol `%s'"), runp->name); goto dont_insert; } else if (c < 0) @@ -1784,14 +1780,13 @@ symbol `%s' has the same encoding as"), (*eptr)->name); /* This should not happen. It means that we have two symbols with the same byte sequence. It is of course an error. */ - WITH_CUR_LOCALE (error_at_line (0, 0, (*eptr)->file, - (*eptr)->line, - _("\ + record_error_at_line (0, 0, (*eptr)->file, + (*eptr)->line, + _("\ symbol `%s' has the same encoding as"), (*eptr)->name); - error_at_line (0, 0, runp->file, - runp->line, - _("symbol `%s'"), - runp->name)); + + record_error_at_line (0, 0, runp->file, runp->line, + _("symbol `%s'"), runp->name); goto dont_insertwc; } else if (c < 0) @@ -1829,10 +1824,6 @@ symbol `%s' has the same encoding as"), (*eptr)->name); { /* This seems not to be enforced by recent standards. Don't emit an error, simply append UNDEFINED at the end. */ - if (0) - WITH_CUR_LOCALE (error (0, 0, _("no definition of `UNDEFINED'"))); - - /* Add UNDEFINED at the end. */ collate->undefined.mborder = (int *) obstack_alloc (&collate->mempool, nrules * sizeof (int)); @@ -1858,8 +1849,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name); /* Bail out if we have no sections because of earlier errors. */ if (sect == NULL) { - WITH_CUR_LOCALE (error (EXIT_FAILURE, 0, - _("too many errors; giving up"))); + record_error (EXIT_FAILURE, 0, _("too many errors; giving up")); return; } @@ -3408,8 +3398,8 @@ error while adding equivalent collating symbol")); } else if (state == 3) { - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: missing `reorder-end' keyword"), "LC_COLLATE")); + record_error (0, 0, _("\ +%s: missing `reorder-end' keyword"), "LC_COLLATE"); state = 4; } else if (state != 2 && state != 4) @@ -3769,11 +3759,11 @@ error while adding equivalent collating symbol")); } } else if (state == 3) - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: missing `reorder-end' keyword"), "LC_COLLATE")); + record_error (0, 0, _("\ +%s: missing `reorder-end' keyword"), "LC_COLLATE"); else if (state == 5) - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: missing `reorder-sections-end' keyword"), "LC_COLLATE")); + record_error (0, 0, _("\ +%s: missing `reorder-sections-end' keyword"), "LC_COLLATE"); } arg = lr_token (ldfile, charmap, result, NULL, verbose); if (arg->tok == tok_eof) diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c index 0fd141ca7e..f791e6b7e9 100644 --- a/locale/programs/ld-ctype.c +++ b/locale/programs/ld-ctype.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -427,9 +427,8 @@ ctype_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (ctype == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_CTYPE")); + record_warning (_("\ +No definition for %s category found"), "LC_CTYPE"); ctype_startup (NULL, locale, charmap, NULL, 0); ctype = locale->categories[LC_CTYPE].ctype; } @@ -446,9 +445,8 @@ No definition for %s category found"), "LC_CTYPE")); ctype->codeset_name = charmap->code_set_name; if (ctype->codeset_name == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No character set name specified in charmap"))); + record_error (0, 0, _("\ +No character set name specified in charmap")); ctype->codeset_name = "//UNKNOWN//"; } @@ -475,13 +473,12 @@ No character set name specified in charmap"))); { uint32_t value = ctype->charnames[cnt]; - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ character L'\\u%0*x' in class `%s' must be in class `%s'"), - value > 0xffff ? 8 : 4, - value, - valid_table[cls1].name, - valid_table[cls2].name)); + value > 0xffff ? 8 : 4, + value, + valid_table[cls1].name, + valid_table[cls2].name); } break; @@ -490,13 +487,12 @@ character L'\\u%0*x' in class `%s' must be in class `%s'"), { uint32_t value = ctype->charnames[cnt]; - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ character L'\\u%0*x' in class `%s' must not be in class `%s'"), - value > 0xffff ? 8 : 4, - value, - valid_table[cls1].name, - valid_table[cls2].name)); + value > 0xffff ? 8 : 4, + value, + valid_table[cls1].name, + valid_table[cls2].name); } break; @@ -505,8 +501,8 @@ character L'\\u%0*x' in class `%s' must not be in class `%s'"), break; default: - WITH_CUR_LOCALE (error (5, 0, _("\ -internal error in %s, line %u"), __FUNCTION__, __LINE__)); + record_error (5, 0, _("\ +internal error in %s, line %u"), __FUNCTION__, __LINE__); } } } @@ -533,12 +529,11 @@ internal error in %s, line %u"), __FUNCTION__, __LINE__)); snprintf (buf, sizeof buf, "\\%Zo", cnt); - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ character '%s' in class `%s' must be in class `%s'"), - buf, - valid_table[cls1].name, - valid_table[cls2].name)); + buf, + valid_table[cls1].name, + valid_table[cls2].name); } break; @@ -549,12 +544,11 @@ character '%s' in class `%s' must be in class `%s'"), snprintf (buf, sizeof buf, "\\%Zo", cnt); - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ character '%s' in class `%s' must not be in class `%s'"), - buf, - valid_table[cls1].name, - valid_table[cls2].name)); + buf, + valid_table[cls1].name, + valid_table[cls2].name); } break; @@ -563,8 +557,8 @@ character '%s' in class `%s' must not be in class `%s'"), break; default: - WITH_CUR_LOCALE (error (5, 0, _("\ -internal error in %s, line %u"), __FUNCTION__, __LINE__)); + record_error (5, 0, _("\ +internal error in %s, line %u"), __FUNCTION__, __LINE__); } } } @@ -579,9 +573,8 @@ internal error in %s, line %u"), __FUNCTION__, __LINE__)); (ELEM (ctype, class_collection, , space_value) & BITw (tok_blank)) == 0))) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("<SP> character not in class `%s'"), - valid_table[cnt].name)); + record_error (0, 0, _("<SP> character not in class `%s'"), + valid_table[cnt].name); } else if (((cnt = BITPOS (tok_punct), (ELEM (ctype, class_collection, , space_value) @@ -591,10 +584,9 @@ internal error in %s, line %u"), __FUNCTION__, __LINE__)); & BITw (tok_graph)) != 0))) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ <SP> character must not be in class `%s'"), - valid_table[cnt].name)); + valid_table[cnt].name); } else ELEM (ctype, class_collection, , space_value) |= BITw (tok_print); @@ -606,9 +598,8 @@ internal error in %s, line %u"), __FUNCTION__, __LINE__)); space_seq = charmap_find_value (charmap, "U00000020", 9); if (space_seq == NULL || space_seq->nbytes != 1) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -character <SP> not defined in character map"))); + record_error (0, 0, _("\ +character <SP> not defined in character map")); } else if (((cnt = BITPOS (tok_space), (ctype->class256_collection[space_seq->bytes[0]] @@ -617,9 +608,8 @@ character <SP> not defined in character map"))); (ctype->class256_collection[space_seq->bytes[0]] & BIT (tok_blank)) == 0))) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("<SP> character not in class `%s'"), - valid_table[cnt].name)); + record_error (0, 0, _("<SP> character not in class `%s'"), + valid_table[cnt].name); } else if (((cnt = BITPOS (tok_punct), (ctype->class256_collection[space_seq->bytes[0]] @@ -628,10 +618,9 @@ character <SP> not defined in character map"))); (ctype->class256_collection[space_seq->bytes[0]] & BIT (tok_graph)) != 0))) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ <SP> character must not be in class `%s'"), - valid_table[cnt].name)); + valid_table[cnt].name); } else ctype->class256_collection[space_seq->bytes[0]] |= BIT (tok_print); @@ -743,8 +732,8 @@ character <SP> not defined in character map"))); assert (ctype->mbdigits_act == ctype->wcdigits_act); ctype->wcdigits_act -= ctype->mbdigits_act % 10; ctype->mbdigits_act -= ctype->mbdigits_act % 10; - WITH_CUR_LOCALE (error (0, 0, _("\ -`digit' category has not entries in groups of ten"))); + record_error (0, 0, _("\ +`digit' category has not entries in groups of ten")); } /* Check the input digits. There must be a multiple of ten available. @@ -792,8 +781,8 @@ character <SP> not defined in character map"))); if (ctype->mbdigits[cnt] == NULL) { /* Hum, this ain't good. */ - WITH_CUR_LOCALE (error (0, 0, _("\ -no input digits defined and none of the standard names in the charmap"))); + record_error (0, 0, _("\ +no input digits defined and none of the standard names in the charmap")); ctype->mbdigits[cnt] = obstack_alloc (&((struct charmap_t *) charmap)->mem_pool, sizeof (struct charseq) + 1); @@ -857,8 +846,8 @@ no input digits defined and none of the standard names in the charmap"))); if (!warned) { - WITH_CUR_LOCALE (error (0, 0, _("\ -not all characters used in `outdigit' are available in the charmap"))); + record_error (0, 0, _("\ +not all characters used in `outdigit' are available in the charmap")); warned = 1; } @@ -874,8 +863,8 @@ not all characters used in `outdigit' are available in the charmap"))); { if (!warned) { - WITH_CUR_LOCALE (error (0, 0, _("\ -not all characters used in `outdigit' are available in the repertoire"))); + record_error (0, 0, _("\ +not all characters used in `outdigit' are available in the repertoire")); warned = 1; } @@ -1145,9 +1134,9 @@ ctype_class_new (struct linereader *lr, struct locale_ctype_t *ctype, if (ctype->nr_charclass == MAX_NR_CHARCLASS) /* Exit code 2 is prescribed in P1003.2b. */ - WITH_CUR_LOCALE (error (2, 0, _("\ + record_error (2, 0, _("\ implementation limit: no more than %Zd character classes allowed"), - MAX_NR_CHARCLASS)); + MAX_NR_CHARCLASS); ctype->classnames[ctype->nr_charclass++] = name; } @@ -1177,9 +1166,9 @@ ctype_map_new (struct linereader *lr, struct locale_ctype_t *ctype, if (ctype->map_collection_nr == MAX_NR_CHARMAP) /* Exit code 2 is prescribed in P1003.2b. */ - WITH_CUR_LOCALE (error (2, 0, _("\ + record_error (2, 0, _("\ implementation limit: no more than %d character maps allowed"), - MAX_NR_CHARMAP)); + MAX_NR_CHARMAP); ctype->mapnames[cnt] = name; @@ -2743,11 +2732,11 @@ with character code range values one must use the absolute ellipsis `...'")); { lr_error (ldfile, _("\ %s: duplicate `default_missing' definition"), "LC_CTYPE"); - WITH_CUR_LOCALE (error_at_line (0, 0, - ctype->default_missing_file, - ctype->default_missing_lineno, - _("\ -previous definition was here"))); + record_error_at_line (0, 0, + ctype->default_missing_file, + ctype->default_missing_lineno, + _("\ +previous definition was here")); } else { @@ -2885,15 +2874,14 @@ set_one_default (struct locale_ctype_t *ctype, } if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", tmp)); + "LC_CTYPE", tmp); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", tmp)); + "LC_CTYPE", tmp); else ctype->class256_collection[seq->bytes[0]] |= bit; @@ -2982,15 +2970,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U00000020", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<space>")); + "LC_CTYPE", "<space>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<space>")); + "LC_CTYPE", "<space>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space); @@ -3002,15 +2989,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U0000000C", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<form-feed>")); + "LC_CTYPE", "<form-feed>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<form-feed>")); + "LC_CTYPE", "<form-feed>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space); @@ -3023,15 +3009,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U0000000A", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<newline>")); + "LC_CTYPE", "<newline>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<newline>")); + "LC_CTYPE", "<newline>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space); @@ -3044,15 +3029,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U0000000D", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<carriage-return>")); + "LC_CTYPE", "<carriage-return>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<carriage-return>")); + "LC_CTYPE", "<carriage-return>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space); @@ -3065,15 +3049,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U00000009", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<tab>")); + "LC_CTYPE", "<tab>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<tab>")); + "LC_CTYPE", "<tab>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space); @@ -3086,15 +3069,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U0000000B", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<vertical-tab>")); + "LC_CTYPE", "<vertical-tab>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<vertical-tab>")); + "LC_CTYPE", "<vertical-tab>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space); @@ -3126,15 +3108,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U00000020", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<space>")); + "LC_CTYPE", "<space>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<space>")); + "LC_CTYPE", "<space>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_blank); @@ -3147,15 +3128,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U00000009", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<tab>")); + "LC_CTYPE", "<tab>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<tab>")); + "LC_CTYPE", "<tab>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_blank); @@ -3212,15 +3192,14 @@ set_class_defaults (struct locale_ctype_t *ctype, seq = charmap_find_value (charmap, "U00000020", 9); if (seq == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", "<space>")); + "LC_CTYPE", "<space>"); } else if (seq->nbytes != 1) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' in charmap not representable with one byte"), - "LC_CTYPE", "<space>")); + "LC_CTYPE", "<space>"); else ctype->class256_collection[seq->bytes[0]] |= BIT (tok_print); @@ -3254,17 +3233,15 @@ set_class_defaults (struct locale_ctype_t *ctype, } if (seq_from == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", tmp)); + "LC_CTYPE", tmp); } else if (seq_from->nbytes != 1) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' needed as default value not representable with one byte"), - "LC_CTYPE", tmp)); + "LC_CTYPE", tmp); } else { @@ -3279,17 +3256,15 @@ set_class_defaults (struct locale_ctype_t *ctype, } if (seq_to == NULL) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' not defined while needed as default value"), - "LC_CTYPE", tmp)); + "LC_CTYPE", tmp); } else if (seq_to->nbytes != 1) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: character `%s' needed as default value not representable with one byte"), - "LC_CTYPE", tmp)); + "LC_CTYPE", tmp); } else /* The index [0] is determined by the order of the @@ -3321,9 +3296,9 @@ set_class_defaults (struct locale_ctype_t *ctype, if (ctype->outdigits_act != 10) { if (ctype->outdigits_act != 0) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: field `%s' does not contain exactly ten entries"), - "LC_CTYPE", "outdigit")); + "LC_CTYPE", "outdigit"); for (size_t cnt = ctype->outdigits_act; cnt < 10; ++cnt) { @@ -3343,8 +3318,8 @@ set_class_defaults (struct locale_ctype_t *ctype, if (ctype->mboutdigits[cnt] == NULL) { /* Provide a replacement. */ - WITH_CUR_LOCALE (error (0, 0, _("\ -no output digits defined and none of the standard names in the charmap"))); + record_error (0, 0, _("\ +no output digits defined and none of the standard names in the charmap")); ctype->mboutdigits[cnt] = obstack_alloc (&((struct charmap_t *) charmap)->mem_pool, sizeof (struct charseq) @@ -3592,9 +3567,9 @@ translit_flatten (struct locale_ctype_t *ctype, if (other == NULL || other->categories[LC_CTYPE].ctype == NULL) { - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: transliteration data from locale `%s' not available"), - "LC_CTYPE", copy_locale)); + "LC_CTYPE", copy_locale); } else { @@ -3691,11 +3666,10 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, if (ctype->class_collection[idx] & _ISwbit (nr)) wctype_table_add (t, ctype->charnames[idx]); - if (verbose) - WITH_CUR_LOCALE (fprintf (stderr, _("\ -%s: table for class \"%s\": %lu bytes\n"), - "LC_CTYPE", ctype->classnames[nr], - (unsigned long int) t->result_size)); + record_verbose (stderr, _("\ +%s: table for class \"%s\": %lu bytes"), + "LC_CTYPE", ctype->classnames[nr], + (unsigned long int) t->result_size); } /* Room for table of mappings. */ @@ -3756,11 +3730,10 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, wctrans_table_add (t, ctype->charnames[idx], ctype->map_collection[nr][idx]); - if (verbose) - WITH_CUR_LOCALE (fprintf (stderr, _("\ -%s: table for map \"%s\": %lu bytes\n"), - "LC_CTYPE", ctype->mapnames[nr], - (unsigned long int) t->result_size)); + record_verbose (stderr, _("\ +%s: table for map \"%s\": %lu bytes"), + "LC_CTYPE", ctype->mapnames[nr], + (unsigned long int) t->result_size); } /* Extra array for class and map names. */ @@ -3881,9 +3854,8 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, /* Set the width of L'\0' to 0. */ wcwidth_table_add (t, 0, 0); - if (verbose) - WITH_CUR_LOCALE (fprintf (stderr, _("%s: table for width: %lu bytes\n"), - "LC_CTYPE", (unsigned long int) t->result_size)); + record_verbose (stderr, _("%s: table for width: %lu bytes"), + "LC_CTYPE", (unsigned long int) t->result_size); } /* Set MB_CUR_MAX. */ diff --git a/locale/programs/ld-identification.c b/locale/programs/ld-identification.c index 1e8fa84712..df0257b6c0 100644 --- a/locale/programs/ld-identification.c +++ b/locale/programs/ld-identification.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -19,7 +19,6 @@ # include <config.h> #endif -#include <error.h> #include <langinfo.h> #include <stdlib.h> #include <string.h> @@ -129,9 +128,8 @@ identification_finish (struct localedef_t *locale, empty one. */ if (identification == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_IDENTIFICATION")); + record_warning (_("\ +No definition for %s category found"), "LC_IDENTIFICATION"); identification_startup (NULL, locale, 0); identification = locale->categories[LC_IDENTIFICATION].identification; @@ -143,8 +141,8 @@ No definition for %s category found"), "LC_IDENTIFICATION")); if (identification->cat == NULL) \ { \ if (verbose && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_IDENTIFICATION", #cat)); \ + record_warning (_("%s: field `%s' not defined"), "LC_IDENTIFICATION", \ + #cat); \ identification->cat = ""; \ } @@ -164,14 +162,45 @@ No definition for %s category found"), "LC_IDENTIFICATION")); TEST_ELEM (date); for (num = 0; num < __LC_LAST; ++num) - if (num != LC_ALL && identification->category[num] == NULL) - { - if (verbose && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: no identification for category `%s'"), - "LC_IDENTIFICATION", category_name[num])); - identification->category[num] = ""; - } + { + /* We don't accept/parse this category, so skip it early. */ + if (num == LC_ALL) + continue; + + if (identification->category[num] == NULL) + { + if (verbose && ! nothing) + record_warning (_("\ +%s: no identification for category `%s'"), "LC_IDENTIFICATION", + category_name[num]); + identification->category[num] = ""; + } + else + { + /* Only list the standards we care about. This is based on the + ISO 30112 WD10 [2014] standard which supersedes all previous + revisions of the ISO 14652 standard. */ + static const char * const standards[] = + { + "posix:1993", + "i18n:2004", + "i18n:2012", + }; + size_t i; + bool matched = false; + + for (i = 0; i < sizeof (standards) / sizeof (standards[0]); ++i) + if (strcmp (identification->category[num], standards[i]) == 0) + matched = true; + + if (matched != true) + record_error (0, 0, _("\ +%s: unknown standard `%s' for category `%s'"), + "LC_IDENTIFICATION", + identification->category[num], + category_name[num]); + } + } } diff --git a/locale/programs/ld-measurement.c b/locale/programs/ld-measurement.c index c4f98111e3..4d76c716f4 100644 --- a/locale/programs/ld-measurement.c +++ b/locale/programs/ld-measurement.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -19,7 +19,6 @@ # include <config.h> #endif -#include <error.h> #include <langinfo.h> #include <string.h> #include <stdint.h> @@ -90,9 +89,8 @@ measurement_finish (struct localedef_t *locale, empty one. */ if (measurement == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_MEASUREMENT")); + record_warning (_("\ +No definition for %s category found"), "LC_MEASUREMENT"); measurement_startup (NULL, locale, 0); measurement = locale->categories[LC_MEASUREMENT].measurement; nothing = 1; @@ -102,16 +100,16 @@ No definition for %s category found"), "LC_MEASUREMENT")); if (measurement->measurement == 0) { if (! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_MEASUREMENT", "measurement")); + record_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) - WITH_CUR_LOCALE (error (0, 0, _("%s: invalid value for field `%s'"), - "LC_MEASUREMENT", "measurement")); + record_error (0, 0, _("%s: invalid value for field `%s'"), + "LC_MEASUREMENT", "measurement"); } } diff --git a/locale/programs/ld-messages.c b/locale/programs/ld-messages.c index 702190dad1..6e15571a0c 100644 --- a/locale/programs/ld-messages.c +++ b/locale/programs/ld-messages.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -93,9 +93,8 @@ messages_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (messages == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_MESSAGES")); + record_warning (_("\ +No definition for %s category found"), "LC_MESSAGES"); messages_startup (NULL, locale, 0); messages = locale->categories[LC_MESSAGES].messages; nothing = 1; @@ -110,17 +109,16 @@ No definition for %s category found"), "LC_MESSAGES")); if (messages->yesexpr == NULL) { - if (! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' undefined"), - "LC_MESSAGES", "yesexpr")); + if (! nothing) + record_error (0, 0, _("%s: field `%s' undefined"), + "LC_MESSAGES", "yesexpr"); messages->yesexpr = "^[yY]"; } else if (messages->yesexpr[0] == '\0') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: value for field `%s' must not be an empty string"), - "LC_MESSAGES", "yesexpr")); + "LC_MESSAGES", "yesexpr"); } else { @@ -134,9 +132,9 @@ No definition for %s category found"), "LC_MESSAGES")); char errbuf[BUFSIZ]; (void) regerror (result, &re, errbuf, BUFSIZ); - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: no correct regular expression for field `%s': %s"), - "LC_MESSAGES", "yesexpr", errbuf)); + "LC_MESSAGES", "yesexpr", errbuf); } else if (result != 0) regfree (&re); @@ -144,17 +142,16 @@ No definition for %s category found"), "LC_MESSAGES")); if (messages->noexpr == NULL) { - if (! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' undefined"), - "LC_MESSAGES", "noexpr")); + if (! nothing) + record_error (0, 0, _("%s: field `%s' undefined"), + "LC_MESSAGES", "noexpr"); messages->noexpr = "^[nN]"; } else if (messages->noexpr[0] == '\0') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: value for field `%s' must not be an empty string"), - "LC_MESSAGES", "noexpr")); + "LC_MESSAGES", "noexpr"); } else { @@ -168,9 +165,9 @@ No definition for %s category found"), "LC_MESSAGES")); char errbuf[BUFSIZ]; (void) regerror (result, &re, errbuf, BUFSIZ); - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: no correct regular expression for field `%s': %s"), - "LC_MESSAGES", "noexpr", errbuf)); + "LC_MESSAGES", "noexpr", errbuf); } else if (result != 0) regfree (&re); diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c index 8635d4fe5d..f927534032 100644 --- a/locale/programs/ld-monetary.c +++ b/locale/programs/ld-monetary.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -185,13 +185,12 @@ monetary_finish (struct localedef_t *locale, const struct charmap_t *charmap) = from->categories[LC_MONETARY].monetary; } - /* If there is still no definition issue an warning and create an + /* If there is still no definition issue a warning and create an empty one. */ if (monetary == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_MONETARY")); + record_warning (_("\ +No definition for %s category found"), "LC_MONETARY"); monetary_startup (NULL, locale, 0); monetary = locale->categories[LC_MONETARY].monetary; nothing = 1; @@ -201,9 +200,9 @@ No definition for %s category found"), "LC_MONETARY")); #define TEST_ELEM(cat, initval) \ if (monetary->cat == NULL) \ { \ - if (! be_quiet && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_MONETARY", #cat)); \ + if (! nothing) \ + record_error (0, 0, _("%s: field `%s' not defined"), \ + "LC_MONETARY", #cat); \ monetary->cat = initval; \ } @@ -217,26 +216,36 @@ No definition for %s category found"), "LC_MONETARY")); /* The international currency symbol must come from ISO 4217. */ if (monetary->int_curr_symbol != NULL) { - if (strlen (monetary->int_curr_symbol) != 4) + /* POSIX says this should be a 3-character symbol from ISO 4217 + along with a 4th character that is a divider, but the POSIX + locale is documented as having a special case of "", and we + support that also, so allow other locales to be created with + a blank int_curr_symbol. */ + int ics_len = strlen (monetary->int_curr_symbol); + if (ics_len != 4 && ics_len != 0) { - if (! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("\ + if (! nothing) + record_error (0, 0, _("\ %s: value of field `int_curr_symbol' has wrong length"), - "LC_MONETARY")); + "LC_MONETARY"); } - else + else if (ics_len == 4) { /* Check the first three characters against ISO 4217 */ char symbol[4]; strncpy (symbol, monetary->int_curr_symbol, 3); symbol[3] = '\0'; + /* A user may disable this waning for testing purposes or + for building a locale with a 3 letter country code that + was not yet supported in our ISO 4217 list. + See the use of --no-warnings=intcurrsym. */ if (bsearch (symbol, valid_int_curr, NR_VALID_INT_CURR, sizeof (const char *), (comparison_fn_t) curr_strcmp) == NULL - && !be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + && warn_int_curr_symbol) + record_warning (_("\ %s: value of field `int_curr_symbol' does \ -not correspond to a valid name in ISO 4217"), - "LC_MONETARY")); +not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), + "LC_MONETARY"); } } @@ -245,25 +254,25 @@ not correspond to a valid name in ISO 4217"), != "". */ if (monetary->mon_decimal_point == NULL) { - if (! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_MONETARY", "mon_decimal_point")); + if (! nothing) + record_error (0, 0, _("%s: field `%s' not defined"), + "LC_MONETARY", "mon_decimal_point"); monetary->mon_decimal_point = "."; } else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing) { - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: value for field `%s' must not be an empty string"), - "LC_MONETARY", "mon_decimal_point")); + "LC_MONETARY", "mon_decimal_point"); } if (monetary->mon_decimal_point_wc == L'\0') monetary->mon_decimal_point_wc = L'.'; if (monetary->mon_grouping_len == 0) { - if (! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_MONETARY", "mon_grouping")); + if (! nothing) + record_error (0, 0, _("%s: field `%s' not defined"), + "LC_MONETARY", "mon_grouping"); monetary->mon_grouping = (char *) "\177"; monetary->mon_grouping_len = 1; @@ -273,17 +282,17 @@ not correspond to a valid name in ISO 4217"), #define TEST_ELEM(cat, min, max, initval) \ if (monetary->cat == -2) \ { \ - if (! be_quiet && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_MONETARY", #cat)); \ + if (! nothing) \ + record_error (0, 0, _("%s: field `%s' not defined"), \ + "LC_MONETARY", #cat); \ monetary->cat = initval; \ } \ else if ((monetary->cat < min || monetary->cat > max) \ && min < max \ && !be_quiet && !nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: value for field `%s' must be in range %d...%d"), \ - "LC_MONETARY", #cat, min, max)) + "LC_MONETARY", #cat, min, max) TEST_ELEM (int_frac_digits, 1, 0, -1); TEST_ELEM (frac_digits, 1, 0, -1); @@ -309,11 +318,10 @@ not correspond to a valid name in ISO 4217"), #define TEST_ELEM(cat, alt, min, max) \ if (monetary->cat == -2) \ monetary->cat = monetary->alt; \ - else if ((monetary->cat < min || monetary->cat > max) && !be_quiet \ - && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("\ + else if ((monetary->cat < min || monetary->cat > max) && ! nothing) \ + record_error (0, 0, _("\ %s: value for field `%s' must be in range %d...%d"), \ - "LC_MONETARY", #cat, min, max)) + "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); diff --git a/locale/programs/ld-name.c b/locale/programs/ld-name.c index b43bcc1c23..21e2d0123d 100644 --- a/locale/programs/ld-name.c +++ b/locale/programs/ld-name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -90,9 +90,8 @@ name_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (name == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_NAME")); + record_warning (_("\ +No definition for %s category found"), "LC_NAME"); name_startup (NULL, locale, 0); name = locale->categories[LC_NAME].name; nothing = 1; @@ -102,8 +101,8 @@ No definition for %s category found"), "LC_NAME")); if (name->name_fmt == NULL) { if (! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_NAME", "name_fmt")); + record_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"; } @@ -114,8 +113,8 @@ No definition for %s category found"), "LC_NAME")); const char *cp = name->name_fmt; if (*cp == '\0') - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"), - "LC_NAME", "name_fmt")); + record_error (0, 0, _("%s: field `%s' must not be empty"), + "LC_NAME", "name_fmt"); else while (*cp != '\0') { @@ -126,8 +125,8 @@ No definition for %s category found"), "LC_NAME")); ++cp; if (strchr ("dfFgGlomMpsSt", *cp) == NULL) { - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: invalid escape sequence in field `%s'"), "LC_NAME", "name_fmt")); + record_error (0, 0, _("\ +%s: invalid escape sequence in field `%s'"), "LC_NAME", "name_fmt"); break; } } @@ -139,8 +138,7 @@ No definition for %s category found"), "LC_NAME")); if (name->cat == NULL) \ { \ if (verbose && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_NAME", #cat)); \ + record_warning (_("%s: field `%s' not defined"), "LC_NAME", #cat); \ name->cat = ""; \ } diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c index 6e1d2b112e..58d5c5a4bc 100644 --- a/locale/programs/ld-numeric.c +++ b/locale/programs/ld-numeric.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -94,9 +94,8 @@ numeric_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (numeric == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_NUMERIC")); + record_warning (_("\ +No definition for %s category found"), "LC_NUMERIC"); numeric_startup (NULL, locale, 0); numeric = locale->categories[LC_NUMERIC].numeric; nothing = 1; @@ -108,23 +107,23 @@ No definition for %s category found"), "LC_NUMERIC")); != "". */ if (numeric->decimal_point == NULL) { - if (! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_NUMERIC", "decimal_point")); + if (! nothing) + record_error (0, 0, _("%s: field `%s' not defined"), + "LC_NUMERIC", "decimal_point"); numeric->decimal_point = "."; } - else if (numeric->decimal_point[0] == '\0' && ! be_quiet && ! nothing) + else if (numeric->decimal_point[0] == '\0' && ! nothing) { - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: value for field `%s' must not be an empty string"), - "LC_NUMERIC", "decimal_point")); + "LC_NUMERIC", "decimal_point"); } if (numeric->decimal_point_wc == L'\0') numeric->decimal_point_wc = L'.'; - if (numeric->grouping_len == 0 && ! be_quiet && ! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_NUMERIC", "grouping")); + if (numeric->grouping_len == 0 && ! nothing) + record_error (0, 0, _("%s: field `%s' not defined"), + "LC_NUMERIC", "grouping"); } diff --git a/locale/programs/ld-paper.c b/locale/programs/ld-paper.c index 24ea684c40..6cbf4e990f 100644 --- a/locale/programs/ld-paper.c +++ b/locale/programs/ld-paper.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -19,7 +19,6 @@ # include <config.h> #endif -#include <error.h> #include <langinfo.h> #include <string.h> #include <stdint.h> @@ -87,9 +86,8 @@ paper_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (paper == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_PAPER")); + record_warning (_("\ +No definition for %s category found"), "LC_PAPER"); paper_startup (NULL, locale, 0); paper = locale->categories[LC_PAPER].paper; nothing = 1; @@ -99,8 +97,8 @@ No definition for %s category found"), "LC_PAPER")); if (paper->height == 0) { if (! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_PAPER", "height")); + record_error (0, 0, _("%s: field `%s' not defined"), + "LC_PAPER", "height"); /* Use as default values the values from the i18n locale. */ paper->height = 297; } @@ -108,8 +106,8 @@ No definition for %s category found"), "LC_PAPER")); if (paper->width == 0) { if (! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_PAPER", "width")); + record_error (0, 0, _("%s: field `%s' not defined"), + "LC_PAPER", "width"); /* Use as default values the values from the i18n locale. */ paper->width = 210; } diff --git a/locale/programs/ld-telephone.c b/locale/programs/ld-telephone.c index 6c38449d2c..f29f88a6e4 100644 --- a/locale/programs/ld-telephone.c +++ b/locale/programs/ld-telephone.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -19,7 +19,6 @@ # include <config.h> #endif -#include <error.h> #include <langinfo.h> #include <string.h> #include <stdint.h> @@ -90,9 +89,8 @@ telephone_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (telephone == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_TELEPHONE")); + record_warning (_("\ +No definition for %s category found"), "LC_TELEPHONE"); telephone_startup (NULL, locale, 0); telephone = locale->categories[LC_TELEPHONE].telephone; nothing = 1; @@ -102,10 +100,10 @@ No definition for %s category found"), "LC_TELEPHONE")); if (telephone->tel_int_fmt == NULL) { if (! nothing) - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), - "LC_TELEPHONE", "tel_int_fmt")); + record_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"; + telephone->tel_int_fmt = "+%c %a%t%l"; } else { @@ -114,17 +112,17 @@ No definition for %s category found"), "LC_TELEPHONE")); const char *cp = telephone->tel_int_fmt; if (*cp == '\0') - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"), - "LC_TELEPHONE", "tel_int_fmt")); + record_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) + if (strchr ("aAcCelt", *++cp) == NULL) { - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_int_fmt")); + record_error (0, 0, _("\ +%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_int_fmt"); break; } } @@ -144,10 +142,10 @@ No definition for %s category found"), "LC_TELEPHONE")); { if (*cp == '%') { - if (strchr ("aAlc", *++cp) == NULL) + if (strchr ("aAcCelt", *++cp) == NULL) { - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_dom_fmt")); + record_error (0, 0, _("\ +%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_dom_fmt"); break; } } @@ -159,8 +157,8 @@ No definition for %s category found"), "LC_TELEPHONE")); if (telephone->cat == NULL) \ { \ if (verbose && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_TELEPHONE", #cat)); \ + record_warning (_("%s: field `%s' not defined"), "LC_TELEPHONE", \ + #cat); \ telephone->cat = ""; \ } diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index ca31c9c81b..a755792363 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -91,6 +91,12 @@ struct locale_time_t const char *date_fmt; const uint32_t *wdate_fmt; int alt_digits_defined; + const char *alt_mon[12]; + const uint32_t *walt_mon[12]; + int alt_mon_defined; + const char *ab_alt_mon[12]; + const uint32_t *wab_alt_mon[12]; + int ab_alt_mon_defined; unsigned char week_ndays; uint32_t week_1stday; unsigned char week_1stweek; @@ -155,9 +161,8 @@ time_finish (struct localedef_t *locale, const struct charmap_t *charmap) empty one. */ if (time == NULL) { - if (! be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -No definition for %s category found"), "LC_TIME")); + record_warning (_("\ +No definition for %s category found"), "LC_TIME"); time_startup (NULL, locale, 0); time = locale->categories[LC_TIME].time; nothing = 1; @@ -171,9 +176,9 @@ No definition for %s category found"), "LC_TIME")); const char *initval[] = { noparen val }; \ unsigned int i; \ \ - if (! be_quiet && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_TIME", #cat)); \ + if (! nothing) \ + record_error (0, 0, _("%s: field `%s' not defined"), \ + "LC_TIME", #cat); \ \ for (i = 0; i < sizeof (initval) / sizeof (initval[0]); ++i) \ time->cat[i] = initval[i]; \ @@ -192,9 +197,9 @@ No definition for %s category found"), "LC_TIME")); #define TEST_ELEM(cat, initval) \ if (time->cat == NULL) \ { \ - if (! be_quiet && ! nothing) \ - WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"), \ - "LC_TIME", #cat)); \ + if (! nothing) \ + record_error (0, 0, _("%s: field `%s' not defined"), \ + "LC_TIME", #cat); \ \ time->cat = initval; \ } @@ -243,10 +248,9 @@ No definition for %s category found"), "LC_TIME")); /* First character must be + or - for the direction. */ if (*str != '+' && *str != '-') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: direction flag in string %Zd in `era' field is not '+' nor '-'"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); /* Default arbitrarily to '+'. */ time->era_entries[idx].direction = '+'; } @@ -254,10 +258,9 @@ No definition for %s category found"), "LC_TIME")); time->era_entries[idx].direction = *str; if (*++str != ':') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: direction flag in string %Zd in `era' field is not a single character"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else @@ -267,18 +270,16 @@ No definition for %s category found"), "LC_TIME")); time->era_entries[idx].offset = strtol (str, &endp, 10); if (endp == str) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: invalid number for offset in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else if (*endp != ':') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: garbage at end of offset value in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else @@ -326,19 +327,17 @@ No definition for %s category found"), "LC_TIME")); if (endp == str) { invalid_start_date: - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: invalid starting date in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else if (*endp != ':') { garbage_start_date: - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: garbage at end of starting date in string %Zd in `era' field "), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else @@ -353,11 +352,10 @@ No definition for %s category found"), "LC_TIME")); > days_per_month[time->era_entries[idx].start_date[1]]) || (time->era_entries[idx].start_date[1] == 2 && time->era_entries[idx].start_date[2] == 29 - && !__isleap (time->era_entries[idx].start_date[0]))) - && !be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + && !__isleap (time->era_entries[idx].start_date[0])))) + record_error (0, 0, _("\ %s: starting date is invalid in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); } } @@ -403,19 +401,17 @@ No definition for %s category found"), "LC_TIME")); if (endp == str) { invalid_stop_date: - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: invalid stopping date in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else if (*endp != ':') { garbage_stop_date: - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: garbage at end of stopping date in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); (void) strsep (&str, ":"); } else @@ -430,19 +426,17 @@ No definition for %s category found"), "LC_TIME")); > days_per_month[time->era_entries[idx].stop_date[1]]) || (time->era_entries[idx].stop_date[1] == 2 && time->era_entries[idx].stop_date[2] == 29 - && !__isleap (time->era_entries[idx].stop_date[0]))) - && !be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + && !__isleap (time->era_entries[idx].stop_date[0])))) + record_error (0, 0, _("\ %s: invalid stopping date in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); } } if (str == NULL || *str == '\0') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ -%s: missing era name in string %Zd in `era' field"), "LC_TIME", idx + 1)); + record_error (0, 0, _("\ +%s: missing era name in string %Zd in `era' field"), "LC_TIME", idx + 1); time->era_entries[idx].name = time->era_entries[idx].format = ""; } @@ -452,10 +446,9 @@ No definition for %s category found"), "LC_TIME")); if (str == NULL || *str == '\0') { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: missing era format in string %Zd in `era' field"), - "LC_TIME", idx + 1)); + "LC_TIME", idx + 1); time->era_entries[idx].name = time->era_entries[idx].format = ""; } @@ -487,40 +480,44 @@ No definition for %s category found"), "LC_TIME")); } } + /* Set up defaults based on ISO 30112 WD10 [2014]. */ if (time->week_ndays == 0) time->week_ndays = 7; if (time->week_1stday == 0) time->week_1stday = 19971130; + if (time->week_1stweek == 0) + time->week_1stweek = 7; + if (time->week_1stweek > time->week_ndays) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: third operand for value of field `%s' must not be larger than %d"), - "LC_TIME", "week", 7)); + "LC_TIME", "week", 7); if (time->first_weekday == '\0') /* The definition does not specify this so the default is used. */ time->first_weekday = 1; else if (time->first_weekday > time->week_ndays) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: values for field `%s' must not be larger than %d"), - "LC_TIME", "first_weekday", 7)); + "LC_TIME", "first_weekday", 7); if (time->first_workday == '\0') /* The definition does not specify this so the default is used. */ time->first_workday = 2; else if (time->first_workday > time->week_ndays) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: values for field `%s' must not be larger than %d"), - "LC_TIME", "first_workday", 7)); + "LC_TIME", "first_workday", 7); if (time->cal_direction == '\0') /* The definition does not specify this so the default is used. */ time->cal_direction = 1; else if (time->cal_direction > 3) - WITH_CUR_LOCALE (error (0, 0, _("\ + record_error (0, 0, _("\ %s: values for field `%s' must not be larger than %d"), - "LC_TIME", "cal_direction", 3)); + "LC_TIME", "cal_direction", 3); /* XXX We don't perform any tests on the timezone value since this is simply useless, stupid $&$!@... */ @@ -648,6 +645,23 @@ time_output (struct localedef_t *locale, const struct charmap_t *charmap, add_locale_string (&file, time->date_fmt); add_locale_wstring (&file, time->wdate_fmt); add_locale_string (&file, charmap->code_set_name); + + /* The alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_string (&file, time->alt_mon[n] ?: ""); + + /* The wide character alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_wstring (&file, time->walt_mon[n] ?: empty_wstr); + + /* The ab'alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_string (&file, time->ab_alt_mon[n] ?: ""); + + /* The wide character ab'alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_wstring (&file, time->wab_alt_mon[n] ?: empty_wstr); + write_locale_data (output_path, LC_TIME, "LC_TIME", &file); } @@ -791,6 +805,8 @@ time_read (struct linereader *ldfile, struct localedef_t *result, STRARR_ELEM (mon, 12, 12); STRARR_ELEM (am_pm, 2, 2); STRARR_ELEM (alt_digits, 0, 100); + STRARR_ELEM (alt_mon, 12, 12); + STRARR_ELEM (ab_alt_mon, 12, 12); case tok_era: /* Ignore the rest of the line if we don't need the input of @@ -943,6 +959,21 @@ time_read (struct linereader *ldfile, struct localedef_t *result, lr_error (ldfile, _("\ %1$s: definition does not end with `END %1$s'"), "LC_TIME"); lr_ignore_rest (ldfile, now->tok == tok_lc_time); + + /* If alt_mon was not specified, make it a copy of mon. */ + if (!ignore_content && !time->alt_mon_defined) + { + memcpy (time->alt_mon, time->mon, sizeof (time->mon)); + memcpy (time->walt_mon, time->wmon, sizeof (time->wmon)); + time->alt_mon_defined = 1; + } + /* The same for abbreviated versions. */ + if (!ignore_content && !time->ab_alt_mon_defined) + { + memcpy (time->ab_alt_mon, time->abmon, sizeof (time->abmon)); + memcpy (time->wab_alt_mon, time->wabmon, sizeof (time->wabmon)); + time->ab_alt_mon_defined = 1; + } return; default: diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c index b885f65d1f..3525c8a43d 100644 --- a/locale/programs/linereader.c +++ b/locale/programs/linereader.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. @@ -634,7 +634,6 @@ get_string (struct linereader *lr, const struct charmap_t *charmap, size_t buf2act = 0; size_t buf2max = 56 * sizeof (uint32_t); int ch; - int warned = 0; /* We have to provide the wide character result as well. */ if (return_widestr) @@ -664,13 +663,6 @@ get_string (struct linereader *lr, const struct charmap_t *charmap, 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); diff --git a/locale/programs/linereader.h b/locale/programs/linereader.h index 5f423af44c..24fedaed92 100644 --- a/locale/programs/linereader.h +++ b/locale/programs/linereader.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.org>. @@ -27,7 +27,7 @@ #include "error.h" #include "locfile-token.h" #include "repertoire.h" - +#include "record-status.h" typedef const struct keyword_t *(*kw_hash_fct_t) (const char *, unsigned int); struct charset_t; @@ -96,9 +96,29 @@ extern struct token *lr_token (struct linereader *lr, extern void lr_ignore_rest (struct linereader *lr, int verbose); -#define lr_error(lr, fmt, args...) \ - WITH_CUR_LOCALE (error_at_line (0, 0, lr->fname, lr->lineno, fmt, ## args)) +static inline void +__attribute__ ((__format__ (__printf__, 2, 3), nonnull (1, 2))) +lr_error (struct linereader *lr, const char *fmt, ...) +{ + char *str; + va_list arg; + struct locale_state ls; + int ret; + + va_start (arg, fmt); + ls = push_locale (); + + ret = vasprintf (&str, fmt, arg); + if (ret == -1) + abort (); + pop_locale (ls); + va_end (arg); + + error_at_line (0, 0, lr->fname, lr->lineno, "%s", str); + + free (str); +} static inline int diff --git a/locale/programs/locale-spec.c b/locale/programs/locale-spec.c index 80c9354dea..01dfe1ed60 100644 --- a/locale/programs/locale-spec.c +++ b/locale/programs/locale-spec.c @@ -1,5 +1,5 @@ /* Handle special requests. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. @@ -53,7 +53,7 @@ locale_special (const char *name, int show_category_name, size_t cnt; for (cnt = 0; cnt < nelem; ++cnt) - if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0))) + if (__collate_element_hash[2 * cnt] != (~((uint32_t) 0))) { size_t idx = __collate_element_hash[2 * cnt]; diff --git a/locale/programs/locale.c b/locale/programs/locale.c index 6cb3d5ec64..86941e4ef6 100644 --- a/locale/programs/locale.c +++ b/locale/programs/locale.c @@ -1,5 +1,5 @@ /* Implementation of the locale program according to POSIX 9945-2. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. @@ -40,6 +40,7 @@ #include <sys/mman.h> #include <sys/stat.h> +#include "record-status.h" #include "localeinfo.h" #include "charmap-dir.h" #include "../locarchive.h" @@ -59,9 +60,6 @@ static int do_all; /* Print names of all available character maps. */ static int do_charmaps = 0; -/* Nonzero if verbose output is wanted. */ -static int verbose; - /* Name and version of program. */ static void print_version (FILE *stream, struct argp_state *state); void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; @@ -295,7 +293,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2016"); +"), "2018"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -318,11 +316,9 @@ select_dirs (const struct dirent *dirent) { mode_t mode = 0; -#ifdef _DIRENT_HAVE_D_TYPE if (dirent->d_type != DT_UNKNOWN && dirent->d_type != DT_LNK) mode = DTTOIF (dirent->d_type); else -#endif { struct stat64 st; char buf[sizeof (COMPLOCALEDIR) diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index 6becd9aa2e..d718d2e9f4 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. @@ -24,7 +24,6 @@ #include <fcntl.h> #include <libintl.h> #include <locale.h> -#include <mcheck.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -33,6 +32,7 @@ #include <error.h> #include <sys/mman.h> #include <sys/stat.h> +#include <ctype.h> #include "localedef.h" #include "charmap.h" @@ -49,16 +49,6 @@ struct copy_def_list_t *copy_list; /* If this is defined be POSIX conform. */ int posix_conformance; -/* If not zero give a lot more messages. */ -int verbose; - -/* If not zero suppress warnings and information messages. */ -int be_quiet; - -/* If not zero, produce old-style hash table instead of 3-level access - tables. */ -int oldstyle_tables; - /* If not zero force output even if warning were issued. */ static int force_output; @@ -105,7 +95,6 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; #define OPT_POSIX 301 #define OPT_QUIET 302 -#define OPT_OLDSTYLE 303 #define OPT_PREFIX 304 #define OPT_NO_ARCHIVE 305 #define OPT_ADD_TO_ARCHIVE 306 @@ -114,6 +103,8 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; #define OPT_LIST_ARCHIVE 309 #define OPT_LITTLE_ENDIAN 400 #define OPT_BIG_ENDIAN 401 +#define OPT_NO_WARN 402 +#define OPT_WARN 403 /* Definitions of arguments for argp functions. */ static const struct argp_option options[] = @@ -129,12 +120,18 @@ static const struct argp_option options[] = { NULL, 0, NULL, 0, N_("Output control:") }, { "force", 'c', NULL, 0, N_("Create output even if warning messages were issued") }, - { "old-style", OPT_OLDSTYLE, NULL, 0, N_("Create old-style tables") }, { "prefix", OPT_PREFIX, N_("PATH"), 0, N_("Optional output file prefix") }, { "posix", OPT_POSIX, NULL, 0, N_("Strictly conform to POSIX") }, { "quiet", OPT_QUIET, NULL, 0, N_("Suppress warnings and information messages") }, { "verbose", 'v', NULL, 0, N_("Print more messages") }, + { "no-warnings", OPT_NO_WARN, N_("<warnings>"), 0, + N_("Comma-separated list of warnings to disable; " + "supported warnings are: ascii, intcurrsym") }, + { "warnings", OPT_WARN, N_("<warnings>"), 0, + N_("Comma-separated list of warnings to enable; " + "supported warnings are: ascii, intcurrsym") }, + { NULL, 0, NULL, 0, N_("Archive control:") }, { "no-archive", OPT_NO_ARCHIVE, NULL, 0, N_("Don't add new data to archive") }, @@ -243,8 +240,8 @@ main (int argc, char *argv[]) defines error code 3 for this situation so I think it must be a fatal error (see P1003.2 4.35.8). */ if (sysconf (_SC_2_LOCALEDEF) < 0) - WITH_CUR_LOCALE (error (3, 0, _("\ -FATAL: system does not define `_POSIX2_LOCALEDEF'"))); + record_error (3, 0, _("\ +FATAL: system does not define `_POSIX2_LOCALEDEF'")); /* Process charmap file. */ charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1); @@ -257,8 +254,8 @@ FATAL: system does not define `_POSIX2_LOCALEDEF'"))); /* Now read the locale file. */ if (locfile_read (&global, charmap) != 0) - WITH_CUR_LOCALE (error (4, errno, _("\ -cannot open locale definition file `%s'"), input_file)); + record_error (4, errno, _("\ +cannot open locale definition file `%s'"), input_file); /* Perhaps we saw some `copy' instructions. */ while (1) @@ -273,31 +270,80 @@ cannot open locale definition file `%s'"), input_file)); break; if (locfile_read (runp, charmap) != 0) - WITH_CUR_LOCALE (error (4, errno, _("\ -cannot open locale definition file `%s'"), runp->name)); + record_error (4, errno, _("\ +cannot open locale definition file `%s'"), runp->name); } /* Check the categories we processed in source form. */ 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). */ - if (error_message_count == 0 || force_output != 0) + /* What we do next depends on the number of errors and warnings we + have generated in processing the input files. + + * No errors: Write the output file. + + * Some warnings: Write the output file and exit with status 1 to + indicate there may be problems using the output file e.g. missing + data that makes it difficult to use + + * Errors: We don't write the output file and we exit with status 4 + to indicate no output files were written. + + The use of -c|--force writes the output file even if errors were + seen. */ + if (recorded_error_count == 0 || force_output != 0) { if (cannot_write_why != 0) - WITH_CUR_LOCALE (error (4, cannot_write_why, _("\ -cannot write output files to `%s'"), output_path ? : argv[remaining])); + record_error (4, cannot_write_why, _("\ +cannot write output files to `%s'"), output_path ? : argv[remaining]); else write_all_categories (locales, charmap, argv[remaining], output_path); } else - WITH_CUR_LOCALE (error (4, 0, _("\ -no output file produced because warnings were issued"))); + record_error (4, 0, _("\ +no output file produced because errors were issued")); /* This exit status is prescribed by POSIX.2 4.35.7. */ - exit (error_message_count != 0); + exit (recorded_warning_count != 0); } +/* Search warnings for matching warnings and if found enable those + warnings if ENABLED is true, otherwise disable the warnings. */ +static void +set_warnings (char *warnings, bool enabled) +{ + char *tok = warnings; + char *copy = (char *) malloc (strlen (warnings) + 1); + char *save = copy; + + /* As we make a copy of the warnings list we remove all spaces from + the warnings list to make the processing a more robust. We don't + support spaces in a warning name. */ + do + { + while (isspace (*tok) != 0) + tok++; + } + while ((*save++ = *tok++) != '\0'); + + warnings = copy; + + /* Tokenize the input list of warnings to set, compare them to + known warnings, and set the warning. We purposely ignore unknown + warnings, and are thus forward compatible, users can attempt to + disable whaterver new warnings they know about, but we will only + disable those *we* known about. */ + while ((tok = strtok_r (warnings, ",", &save)) != NULL) + { + warnings = NULL; + if (strcmp (tok, "ascii") == 0) + warn_ascii = enabled; + else if (strcmp (tok, "intcurrsym") == 0) + warn_int_curr_symbol = enabled; + } + + free (copy); +} /* Handle program arguments. */ static error_t @@ -311,9 +357,6 @@ parse_opt (int key, char *arg, struct argp_state *state) case OPT_POSIX: posix_conformance = 1; break; - case OPT_OLDSTYLE: - oldstyle_tables = 1; - break; case OPT_PREFIX: output_prefix = arg; break; @@ -338,6 +381,14 @@ parse_opt (int key, char *arg, struct argp_state *state) case OPT_BIG_ENDIAN: set_big_endian (true); break; + case OPT_NO_WARN: + /* Disable the warnings. */ + set_warnings (arg, false); + break; + case OPT_WARN: + /* Enable the warnings. */ + set_warnings (arg, true); + break; case 'c': force_output = 1; break; @@ -403,7 +454,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2016"); +"), "2018"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -577,14 +628,14 @@ add_to_readlist (int category, const char *name, const char *repertoire_name, if (generate && (runp->needed & (1 << category)) != 0 && (runp->avail & (1 << category)) == 0) - WITH_CUR_LOCALE (error (5, 0, _("\ -circular dependencies between locale definitions"))); + record_error (5, 0, _("\ +circular dependencies between locale definitions")); if (copy_locale != NULL) { if (runp->categories[category].generic != NULL) - WITH_CUR_LOCALE (error (5, 0, _("\ -cannot add already read locale `%s' a second time"), name)); + record_error (5, 0, _("\ +cannot add already read locale `%s' a second time"), name); else runp->categories[category].generic = copy_locale->categories[category].generic; @@ -609,8 +660,8 @@ find_locale (int category, const char *name, const char *repertoire_name, if ((result->avail & (1 << category)) == 0 && locfile_read (result, charmap) != 0) - WITH_CUR_LOCALE (error (4, errno, _("\ -cannot open locale definition file `%s'"), result->name)); + record_error (4, errno, _("\ +cannot open locale definition file `%s'"), result->name); return result; } @@ -629,19 +680,8 @@ load_locale (int category, const char *name, const char *repertoire_name, if ((result->avail & (1 << category)) == 0 && locfile_read (result, charmap) != 0) - WITH_CUR_LOCALE (error (4, errno, _("\ -cannot open locale definition file `%s'"), result->name)); + record_error (4, errno, _("\ +cannot open locale definition file `%s'"), result->name); return result; } - -static void -turn_on_mcheck (void) -{ - /* Enable `malloc' debugging. */ - mcheck (NULL); - /* Use the following line for a more thorough but much slower testing. */ - /* mcheck_pedantic (NULL); */ -} - -void (*__malloc_initialize_hook) (void) = turn_on_mcheck; diff --git a/locale/programs/localedef.h b/locale/programs/localedef.h index cb9386a798..0083faceab 100644 --- a/locale/programs/localedef.h +++ b/locale/programs/localedef.h @@ -1,5 +1,5 @@ /* General definitions for localedef(1). - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -24,7 +24,11 @@ #include <locale.h> #include <stdbool.h> #include <stddef.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include "record-status.h" #include "repertoire.h" #include "../locarchive.h" @@ -110,9 +114,6 @@ struct localedef_t /* Global variables of the localedef program. */ -extern int verbose; -extern int be_quiet; -extern int oldstyle_tables; extern const char *repertoire_global; extern int max_locarchive_open_retry; extern bool no_archive; @@ -123,19 +124,6 @@ extern const char *alias_file; #include <programs/xmalloc.h> -/* Wrapper to switch LC_CTYPE back to the locale specified in the - environment for output. */ -#define WITH_CUR_LOCALE(stmt) \ - do { \ - int saved_errno = errno; \ - const char *cur_locale_ = setlocale (LC_CTYPE, NULL); \ - setlocale (LC_CTYPE, ""); \ - errno = saved_errno; \ - stmt; \ - setlocale (LC_CTYPE, cur_locale_); \ - } while (0) - - /* Mark given locale as to be read. */ extern struct localedef_t *add_to_readlist (int locale, const char *name, const char *repertoire_name, diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index fadc3bfd43..ca332a345f 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -40,8 +40,8 @@ #include <sys/shm.h> #include <sys/stat.h> -#include <libc-internal.h> #include <libc-mmap.h> +#include <libc-pointer-arith.h> #include "../../crypt/md5.h" #include "../localeinfo.h" #include "../locarchive.h" @@ -320,8 +320,8 @@ compare_from_file (struct locarhandle *ah, void *p1, uint32_t offset2, { void *p2 = xmalloc (size); if (pread (ah->fd, p2, size, offset2) != size) - WITH_CUR_LOCALE (error (4, errno, - _("cannot read data from locale archive"))); + record_error (4, errno, + _("cannot read data from locale archive")); int res = memcmp (p1, p2, size); free (p2); @@ -1385,17 +1385,13 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) a directory we have to look at a file with the prefix "SYS_". Otherwise we have found what we are looking for. */ -#ifdef _DIRENT_HAVE_D_TYPE d_type = d->d_type; if (d_type != DT_REG) -#endif { char fullname[fnamelen + 2 * strlen (d->d_name) + 7]; -#ifdef _DIRENT_HAVE_D_TYPE if (d_type == DT_UNKNOWN) -#endif { strcpy (stpcpy (stpcpy (fullname, fname), "/"), d->d_name); diff --git a/locale/programs/locfile-kw.gperf b/locale/programs/locfile-kw.gperf index 5fea6964ff..6bf2f6018b 100644 --- a/locale/programs/locfile-kw.gperf +++ b/locale/programs/locfile-kw.gperf @@ -1,5 +1,5 @@ %{ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. @@ -148,6 +148,8 @@ first_workday, tok_first_workday, 0 cal_direction, tok_cal_direction, 0 timezone, tok_timezone, 0 date_fmt, tok_date_fmt, 0 +alt_mon, tok_alt_mon, 0 +ab_alt_mon, tok_ab_alt_mon, 0 LC_MESSAGES, tok_lc_messages, 0 yesexpr, tok_yesexpr, 0 noexpr, tok_noexpr, 0 diff --git a/locale/programs/locfile-kw.h b/locale/programs/locfile-kw.h index 16b87d415a..d25cf992f2 100644 --- a/locale/programs/locfile-kw.h +++ b/locale/programs/locfile-kw.h @@ -30,7 +30,7 @@ #line 1 "locfile-kw.gperf" -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. @@ -54,7 +54,7 @@ #line 24 "locfile-kw.gperf" struct keyword_t ; -#define TOTAL_KEYWORDS 176 +#define TOTAL_KEYWORDS 178 #define MIN_WORD_LENGTH 3 #define MAX_WORD_LENGTH 22 #define MIN_HASH_VALUE 3 @@ -147,22 +147,22 @@ locfile_hash (register const char *str, register unsigned int len) #line 30 "locfile-kw.gperf" {"LC_CTYPE", tok_lc_ctype, 0}, {""}, -#line 166 "locfile-kw.gperf" +#line 168 "locfile-kw.gperf" {"LC_ADDRESS", tok_lc_address, 0}, -#line 151 "locfile-kw.gperf" +#line 153 "locfile-kw.gperf" {"LC_MESSAGES", tok_lc_messages, 0}, -#line 159 "locfile-kw.gperf" +#line 161 "locfile-kw.gperf" {"LC_NAME", tok_lc_name, 0}, -#line 156 "locfile-kw.gperf" +#line 158 "locfile-kw.gperf" {"LC_PAPER", tok_lc_paper, 0}, -#line 184 "locfile-kw.gperf" +#line 186 "locfile-kw.gperf" {"LC_MEASUREMENT", tok_lc_measurement, 0}, #line 56 "locfile-kw.gperf" {"LC_COLLATE", tok_lc_collate, 0}, {""}, -#line 186 "locfile-kw.gperf" +#line 188 "locfile-kw.gperf" {"LC_IDENTIFICATION", tok_lc_identification, 0}, -#line 199 "locfile-kw.gperf" +#line 201 "locfile-kw.gperf" {"revision", tok_revision, 0}, #line 69 "locfile-kw.gperf" {"UNDEFINED", tok_undefined, 0}, @@ -170,19 +170,19 @@ locfile_hash (register const char *str, register unsigned int len) {"LC_NUMERIC", tok_lc_numeric, 0}, #line 82 "locfile-kw.gperf" {"LC_MONETARY", tok_lc_monetary, 0}, -#line 179 "locfile-kw.gperf" +#line 181 "locfile-kw.gperf" {"LC_TELEPHONE", tok_lc_telephone, 0}, {""}, {""}, {""}, #line 75 "locfile-kw.gperf" {"define", tok_define, 0}, -#line 152 "locfile-kw.gperf" +#line 154 "locfile-kw.gperf" {"yesexpr", tok_yesexpr, 0}, #line 141 "locfile-kw.gperf" {"era_year", tok_era_year, 0}, {""}, #line 54 "locfile-kw.gperf" {"translit_ignore", tok_translit_ignore, 0}, -#line 154 "locfile-kw.gperf" +#line 156 "locfile-kw.gperf" {"yesstr", tok_yesstr, 0}, {""}, #line 89 "locfile-kw.gperf" @@ -190,7 +190,7 @@ locfile_hash (register const char *str, register unsigned int len) {""}, #line 137 "locfile-kw.gperf" {"t_fmt", tok_t_fmt, 0}, -#line 157 "locfile-kw.gperf" +#line 159 "locfile-kw.gperf" {"height", tok_height, 0}, {""}, {""}, #line 52 "locfile-kw.gperf" @@ -213,7 +213,7 @@ locfile_hash (register const char *str, register unsigned int len) {""}, #line 142 "locfile-kw.gperf" {"era_d_fmt", tok_era_d_fmt, 0}, -#line 187 "locfile-kw.gperf" +#line 189 "locfile-kw.gperf" {"title", tok_title, 0}, {""}, {""}, #line 149 "locfile-kw.gperf" @@ -243,7 +243,7 @@ locfile_hash (register const char *str, register unsigned int len) {"duo_n_cs_precedes", tok_duo_n_cs_precedes, 0}, #line 127 "locfile-kw.gperf" {"thousands_sep", tok_thousands_sep, 0}, -#line 195 "locfile-kw.gperf" +#line 197 "locfile-kw.gperf" {"territory", tok_territory, 0}, #line 36 "locfile-kw.gperf" {"digit", tok_digit, 0}, @@ -258,7 +258,7 @@ locfile_hash (register const char *str, register unsigned int len) {""}, #line 78 "locfile-kw.gperf" {"else", tok_else, 0}, -#line 182 "locfile-kw.gperf" +#line 184 "locfile-kw.gperf" {"int_select", tok_int_select, 0}, {""}, {""}, {""}, #line 132 "locfile-kw.gperf" @@ -266,11 +266,11 @@ locfile_hash (register const char *str, register unsigned int len) #line 33 "locfile-kw.gperf" {"upper", tok_upper, 0}, {""}, {""}, -#line 192 "locfile-kw.gperf" +#line 194 "locfile-kw.gperf" {"tel", tok_tel, 0}, #line 93 "locfile-kw.gperf" {"p_sep_by_space", tok_p_sep_by_space, 0}, -#line 158 "locfile-kw.gperf" +#line 160 "locfile-kw.gperf" {"width", tok_width, 0}, {""}, #line 98 "locfile-kw.gperf" @@ -301,7 +301,7 @@ locfile_hash (register const char *str, register unsigned int len) {""}, {""}, {""}, {""}, {""}, #line 58 "locfile-kw.gperf" {"section-symbol", tok_section_symbol, 0}, -#line 183 "locfile-kw.gperf" +#line 185 "locfile-kw.gperf" {"int_prefix", tok_int_prefix, 0}, {""}, {""}, {""}, {""}, #line 42 "locfile-kw.gperf" @@ -318,7 +318,7 @@ locfile_hash (register const char *str, register unsigned int len) {"duo_p_sep_by_space", tok_duo_p_sep_by_space, 0}, #line 118 "locfile-kw.gperf" {"duo_int_p_sign_posn", tok_duo_int_p_sign_posn, 0}, -#line 155 "locfile-kw.gperf" +#line 157 "locfile-kw.gperf" {"nostr", tok_nostr, 0}, {""}, {""}, #line 140 "locfile-kw.gperf" @@ -327,26 +327,26 @@ locfile_hash (register const char *str, register unsigned int len) #line 84 "locfile-kw.gperf" {"currency_symbol", tok_currency_symbol, 0}, {""}, -#line 165 "locfile-kw.gperf" +#line 167 "locfile-kw.gperf" {"name_ms", tok_name_ms, 0}, -#line 163 "locfile-kw.gperf" +#line 165 "locfile-kw.gperf" {"name_mrs", tok_name_mrs, 0}, -#line 164 "locfile-kw.gperf" +#line 166 "locfile-kw.gperf" {"name_miss", tok_name_miss, 0}, #line 83 "locfile-kw.gperf" {"int_curr_symbol", tok_int_curr_symbol, 0}, -#line 188 "locfile-kw.gperf" +#line 190 "locfile-kw.gperf" {"source", tok_source, 0}, -#line 162 "locfile-kw.gperf" +#line 164 "locfile-kw.gperf" {"name_mr", tok_name_mr, 0}, -#line 161 "locfile-kw.gperf" +#line 163 "locfile-kw.gperf" {"name_gen", tok_name_gen, 0}, -#line 200 "locfile-kw.gperf" +#line 202 "locfile-kw.gperf" {"date", tok_date, 0}, {""}, {""}, -#line 189 "locfile-kw.gperf" +#line 191 "locfile-kw.gperf" {"address", tok_address, 0}, -#line 160 "locfile-kw.gperf" +#line 162 "locfile-kw.gperf" {"name_fmt", tok_name_fmt, 0}, #line 32 "locfile-kw.gperf" {"copy", tok_copy, 0}, @@ -365,16 +365,16 @@ locfile_hash (register const char *str, register unsigned int len) #line 117 "locfile-kw.gperf" {"duo_n_sign_posn", tok_duo_n_sign_posn, 0}, {""}, -#line 168 "locfile-kw.gperf" +#line 170 "locfile-kw.gperf" {"country_name", tok_country_name, 0}, #line 71 "locfile-kw.gperf" {"reorder-after", tok_reorder_after, 0}, {""}, {""}, -#line 153 "locfile-kw.gperf" +#line 155 "locfile-kw.gperf" {"noexpr", tok_noexpr, 0}, #line 50 "locfile-kw.gperf" {"tolower", tok_tolower, 0}, -#line 196 "locfile-kw.gperf" +#line 198 "locfile-kw.gperf" {"audience", tok_audience, 0}, {""}, {""}, {""}, #line 49 "locfile-kw.gperf" @@ -395,7 +395,7 @@ locfile_hash (register const char *str, register unsigned int len) {""}, #line 102 "locfile-kw.gperf" {"int_p_sign_posn", tok_int_p_sign_posn, 0}, -#line 173 "locfile-kw.gperf" +#line 175 "locfile-kw.gperf" {"country_car", tok_country_car, 0}, {""}, {""}, #line 104 "locfile-kw.gperf" @@ -406,9 +406,9 @@ locfile_hash (register const char *str, register unsigned int len) {""}, {""}, #line 116 "locfile-kw.gperf" {"duo_p_sign_posn", tok_duo_p_sign_posn, 0}, -#line 185 "locfile-kw.gperf" +#line 187 "locfile-kw.gperf" {"measurement", tok_measurement, 0}, -#line 174 "locfile-kw.gperf" +#line 176 "locfile-kw.gperf" {"country_isbn", tok_country_isbn, 0}, #line 37 "locfile-kw.gperf" {"outdigit", tok_outdigit, 0}, @@ -418,9 +418,9 @@ locfile_hash (register const char *str, register unsigned int len) {""}, {""}, {""}, #line 34 "locfile-kw.gperf" {"lower", tok_lower, 0}, -#line 181 "locfile-kw.gperf" +#line 183 "locfile-kw.gperf" {"tel_dom_fmt", tok_tel_dom_fmt, 0}, -#line 169 "locfile-kw.gperf" +#line 171 "locfile-kw.gperf" {"country_post", tok_country_post, 0}, #line 148 "locfile-kw.gperf" {"cal_direction", tok_cal_direction, 0}, @@ -430,7 +430,7 @@ locfile_hash (register const char *str, register unsigned int len) #line 91 "locfile-kw.gperf" {"frac_digits", tok_frac_digits, 0}, {""}, {""}, -#line 175 "locfile-kw.gperf" +#line 177 "locfile-kw.gperf" {"lang_name", tok_lang_name, 0}, #line 90 "locfile-kw.gperf" {"int_frac_digits", tok_int_frac_digits, 0}, @@ -445,7 +445,7 @@ locfile_hash (register const char *str, register unsigned int len) {""}, {""}, {""}, {""}, #line 107 "locfile-kw.gperf" {"duo_frac_digits", tok_duo_frac_digits, 0}, -#line 180 "locfile-kw.gperf" +#line 182 "locfile-kw.gperf" {"tel_int_fmt", tok_tel_int_fmt, 0}, #line 123 "locfile-kw.gperf" {"duo_valid_to", tok_duo_valid_to, 0}, @@ -455,7 +455,7 @@ locfile_hash (register const char *str, register unsigned int len) #line 130 "locfile-kw.gperf" {"abday", tok_abday, 0}, {""}, -#line 198 "locfile-kw.gperf" +#line 200 "locfile-kw.gperf" {"abbreviation", tok_abbreviation, 0}, #line 147 "locfile-kw.gperf" {"first_workday", tok_first_workday, 0}, @@ -472,12 +472,12 @@ locfile_hash (register const char *str, register unsigned int len) #line 45 "locfile-kw.gperf" {"blank", tok_blank, 0}, {""}, {""}, -#line 194 "locfile-kw.gperf" +#line 196 "locfile-kw.gperf" {"language", tok_language, 0}, #line 120 "locfile-kw.gperf" {"uno_valid_from", tok_uno_valid_from, 0}, {""}, -#line 197 "locfile-kw.gperf" +#line 199 "locfile-kw.gperf" {"application", tok_application, 0}, {""}, #line 80 "locfile-kw.gperf" @@ -498,7 +498,7 @@ locfile_hash (register const char *str, register unsigned int len) #line 96 "locfile-kw.gperf" {"p_sign_posn", tok_p_sign_posn, 0}, {""}, -#line 201 "locfile-kw.gperf" +#line 203 "locfile-kw.gperf" {"category", tok_category, 0}, {""}, {""}, {""}, {""}, #line 134 "locfile-kw.gperf" @@ -510,29 +510,29 @@ locfile_hash (register const char *str, register unsigned int len) #line 63 "locfile-kw.gperf" {"order_start", tok_order_start, 0}, {""}, {""}, {""}, {""}, {""}, -#line 176 "locfile-kw.gperf" - {"lang_ab", tok_lang_ab, 0}, #line 178 "locfile-kw.gperf" + {"lang_ab", tok_lang_ab, 0}, +#line 180 "locfile-kw.gperf" {"lang_lib", tok_lang_lib, 0}, {""}, {""}, {""}, -#line 190 "locfile-kw.gperf" +#line 192 "locfile-kw.gperf" {"contact", tok_contact, 0}, {""}, {""}, {""}, -#line 171 "locfile-kw.gperf" +#line 173 "locfile-kw.gperf" {"country_ab3", tok_country_ab3, 0}, {""}, {""}, {""}, -#line 191 "locfile-kw.gperf" +#line 193 "locfile-kw.gperf" {"email", tok_email, 0}, -#line 170 "locfile-kw.gperf" +#line 172 "locfile-kw.gperf" {"country_ab2", tok_country_ab2, 0}, {""}, {""}, {""}, #line 55 "locfile-kw.gperf" {"default_missing", tok_default_missing, 0}, {""}, {""}, -#line 193 "locfile-kw.gperf" +#line 195 "locfile-kw.gperf" {"fax", tok_fax, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 172 "locfile-kw.gperf" +#line 174 "locfile-kw.gperf" {"country_num", tok_country_num, 0}, {""}, {""}, {""}, {""}, {""}, {""}, #line 51 "locfile-kw.gperf" @@ -548,7 +548,9 @@ locfile_hash (register const char *str, register unsigned int len) {"endif", tok_endif, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 151 "locfile-kw.gperf" + {"alt_mon", tok_alt_mon, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, #line 76 "locfile-kw.gperf" {"undef", tok_undef, 0}, @@ -558,7 +560,9 @@ locfile_hash (register const char *str, register unsigned int len) #line 59 "locfile-kw.gperf" {"collating-element", tok_collating_element, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 152 "locfile-kw.gperf" + {"ab_alt_mon", tok_ab_alt_mon, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, @@ -569,7 +573,7 @@ locfile_hash (register const char *str, register unsigned int len) #line 85 "locfile-kw.gperf" {"mon_decimal_point", tok_mon_decimal_point, 0}, {""}, {""}, -#line 167 "locfile-kw.gperf" +#line 169 "locfile-kw.gperf" {"postal_fmt", tok_postal_fmt, 0}, {""}, {""}, {""}, {""}, {""}, #line 60 "locfile-kw.gperf" @@ -588,7 +592,7 @@ locfile_hash (register const char *str, register unsigned int len) #line 87 "locfile-kw.gperf" {"mon_grouping", tok_mon_grouping, 0}, {""}, -#line 177 "locfile-kw.gperf" +#line 179 "locfile-kw.gperf" {"lang_term", tok_lang_term, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, diff --git a/locale/programs/locfile-token.h b/locale/programs/locfile-token.h index d6e7a8b4ac..e3cd18e5f0 100644 --- a/locale/programs/locfile-token.h +++ b/locale/programs/locfile-token.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. @@ -186,6 +186,8 @@ enum token_t tok_cal_direction, tok_timezone, tok_date_fmt, + tok_alt_mon, + tok_ab_alt_mon, tok_lc_messages, tok_yesexpr, tok_noexpr, diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c index 32f5cd2a79..32e5f761f2 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. @@ -796,9 +796,8 @@ write_locale_data (const char *output_path, int catidx, const char *category, if (fd == -1) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, save_err, _("\ -cannot open output file `%s' for category `%s'"), fname, category)); + record_error (0, save_err, _("\ +cannot open output file `%s' for category `%s'"), fname, category); free (fname); return; } @@ -820,9 +819,8 @@ cannot open output file `%s' for category `%s'"), fname, category)); if (writev (fd, &vec[cnt], step) < 0) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, errno, _("\ -failure while writing data for category `%s'"), category)); + record_error (0, errno, _("\ +failure while writing data for category `%s'"), category); break; } } @@ -916,9 +914,8 @@ failure while writing data for category `%s'"), category)); unlink (fname); if (rename (tmp_fname, fname) < 0) { - if (!be_quiet) - WITH_CUR_LOCALE (error (0, errno, _("\ -cannot create output file `%s' for category `%s'"), fname, category)); + record_error (0, errno, _("\ +cannot create output file `%s' for category `%s'"), fname, category); } free (tmp_fname); free (other_fname); diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h index a3dd90412a..89b347c72d 100644 --- a/locale/programs/locfile.h +++ b/locale/programs/locfile.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. diff --git a/locale/programs/record-status.c b/locale/programs/record-status.c new file mode 100644 index 0000000000..730679a795 --- /dev/null +++ b/locale/programs/record-status.c @@ -0,0 +1,229 @@ +/* Functions for recorded errors, warnings, and verbose messages. + Copyright (C) 1998-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stdbool.h> +#include <string.h> +#include <error.h> +#include <errno.h> +#include <locale.h> + +#include "record-status.h" + +/* Warnings recorded by record_warnings. */ +int recorded_warning_count; + +/* Errors recorded by record_errors. */ +int recorded_error_count; + +/* If not zero suppress warnings and information messages. */ +int be_quiet; + +/* If not zero give a lot more messages. */ +int verbose; + +/* Warnings which can be disabled: */ +/* By default we check the character map for ASCII compatibility. */ +bool warn_ascii = true; +/* By default we check that the international currency symbol matches a + known country code. */ +bool warn_int_curr_symbol = true; + +/* Alter the current locale to match the locale configured by the + user, and return the previous saved state. */ +struct locale_state +push_locale (void) +{ + int saved_errno; + const char *orig; + char *copy = NULL; + + saved_errno = errno; + + orig = setlocale (LC_CTYPE, NULL); + if (orig == NULL) + error (0, 0, "failed to read locale!"); + + if (setlocale (LC_CTYPE, "") == NULL) + error (0, 0, "failed to set locale!"); + + errno = saved_errno; + + if (orig != NULL) + copy = strdup (orig); + + /* We will return either a valid locale or NULL if we failed + to save the locale. */ + return (struct locale_state) { .cur_locale = copy }; +} + +/* Use the saved state to restore the locale. */ +void +pop_locale (struct locale_state ls) +{ + const char *set = NULL; + /* We might have failed to save the locale, so only attempt to + restore a validly saved non-NULL locale. */ + if (ls.cur_locale != NULL) + { + set = setlocale (LC_CTYPE, ls.cur_locale); + if (set == NULL) + error (0, 0, "failed to restore %s locale!", ls.cur_locale); + + free (ls.cur_locale); + } +} + +/* Wrapper to print verbose informative messages. + Verbose messages are only printed if --verbose + is in effect and --quiet is not. */ +void +__attribute__ ((__format__ (__printf__, 2, 3), nonnull (1, 2), unused)) +record_verbose (FILE *stream, const char *format, ...) +{ + char *str; + va_list arg; + + if (!verbose) + return; + + if (!be_quiet) + { + struct locale_state ls; + int ret; + + va_start (arg, format); + ls = push_locale (); + + ret = vasprintf (&str, format, arg); + if (ret == -1) + abort (); + + pop_locale (ls); + va_end (arg); + + fprintf (stream, "[verbose] %s\n", str); + + free (str); + } +} + +/* Wrapper to print warning messages. We keep track of how + many were called because this effects our exit code. + Nothing is printed if --quiet is in effect, but warnings + are always counted. */ +void +__attribute__ ((__format__ (__printf__, 1, 2), nonnull (1), unused)) +record_warning (const char *format, ...) +{ + char *str; + va_list arg; + + recorded_warning_count++; + + if (!be_quiet) + { + struct locale_state ls; + int ret; + + va_start (arg, format); + ls = push_locale (); + + ret = vasprintf (&str, format, arg); + if (ret == -1) + abort (); + + pop_locale (ls); + va_end (arg); + + fprintf (stderr, "[warning] %s\n", str); + + free (str); + } +} + +/* Wrapper to print error messages. We keep track of how + many were called because this effects our exit code. + Nothing is printed if --quiet is in effect, but errors + are always counted, and fatal errors always exit the + program. */ +void +__attribute__ ((__format__ (__printf__, 3, 4), nonnull (3), unused)) +record_error (int status, int errnum, const char *format, ...) +{ + char *str; + va_list arg; + + recorded_error_count++; + + /* The existing behaviour is that even if you use --quiet, a fatal + error is always printed and terminates the process. */ + if (!be_quiet || status != 0) + { + struct locale_state ls; + int ret; + + va_start (arg, format); + ls = push_locale (); + + ret = vasprintf (&str, format, arg); + if (ret == -1) + abort (); + + pop_locale (ls); + va_end (arg); + + error (status, errnum, "[error] %s", str); + + free (str); + } +} +/* ... likewise for error_at_line. */ +void +__attribute__ ((__format__ (__printf__, 5, 6), nonnull (3, 5), unused)) +record_error_at_line (int status, int errnum, const char *filename, + unsigned int linenum, const char *format, ...) +{ + char *str; + va_list arg; + + recorded_error_count++; + + /* The existing behaviour is that even if you use --quiet, a fatal + error is always printed and terminates the process. */ + if (!be_quiet || status != 0) + { + struct locale_state ls; + int ret; + + va_start (arg, format); + ls = push_locale (); + + ret = vasprintf (&str, format, arg); + if (ret == -1) + abort (); + + pop_locale (ls); + va_end (arg); + + error_at_line (status, errnum, filename, linenum, "[error] %s", str); + + free (str); + } +} diff --git a/locale/programs/record-status.h b/locale/programs/record-status.h new file mode 100644 index 0000000000..7ea0b5be8f --- /dev/null +++ b/locale/programs/record-status.h @@ -0,0 +1,51 @@ +/* General definitions for recording error and warning status. + Copyright (C) 1998-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _RECORD_STATUS_H +#define _RECORD_STATUS_H 1 + +#include <stdio.h> +#include <stdbool.h> + +/* Error, warning and verbose count and control. */ +extern int recorded_warning_count; +extern int recorded_error_count; +extern int be_quiet; +extern int verbose; +extern bool warn_ascii; +extern bool warn_int_curr_symbol; + +/* Record verbose, warnings, or errors... */ +void record_verbose (FILE *stream, const char *format, ...); +void record_warning (const char *format, ...); +void record_error (int status, int errnum, const char *format, ...); +void record_error_at_line (int status, int errnum, + const char *filename, unsigned int linenum, + const char *format, ...); + +/* Locale related functionality for custom error functions. */ +struct locale_state +{ + /* The current in-use locale. */ + char *cur_locale; +}; + +struct locale_state push_locale (void); +void pop_locale (struct locale_state ls); + + +#endif diff --git a/locale/programs/repertoire.c b/locale/programs/repertoire.c index c39870759c..ac83988ebf 100644 --- a/locale/programs/repertoire.c +++ b/locale/programs/repertoire.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -20,7 +20,6 @@ #endif #include <errno.h> -#include <error.h> #include <limits.h> #include <obstack.h> #include <search.h> @@ -321,14 +320,14 @@ argument to <%s> must be a single character"), } if (state != 2 && state != 90 && !be_quiet) - WITH_CUR_LOCALE (error (0, 0, _("%s: premature end of file"), - repfile->fname)); + record_error (0, 0, _("%s: premature end of file"), + repfile->fname); lr_close (repfile); if (tsearch (result, &known, &repertoire_compare) == NULL) /* Something went wrong. */ - WITH_CUR_LOCALE (error (0, errno, _("cannot save new repertoire map"))); + record_error (0, errno, _("cannot save new repertoire map")); return result; } @@ -339,8 +338,8 @@ repertoire_complain (const char *name) { if (tfind (name, &unavailable, (__compar_fn_t) strcmp) == NULL) { - WITH_CUR_LOCALE (error (0, errno, _("\ -repertoire map file `%s' not found"), name)); + record_error (0, errno, _("\ +repertoire map file `%s' not found"), name); /* Remember that we reported this map. */ tsearch (name, &unavailable, (__compar_fn_t) strcmp); diff --git a/locale/programs/repertoire.h b/locale/programs/repertoire.h index a426a3cba6..6a9c7b4257 100644 --- a/locale/programs/repertoire.h +++ b/locale/programs/repertoire.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. diff --git a/locale/programs/simple-hash.c b/locale/programs/simple-hash.c index a79539a1c9..66bb474deb 100644 --- a/locale/programs/simple-hash.c +++ b/locale/programs/simple-hash.c @@ -1,5 +1,5 @@ /* Implement simple hashing table with string based keys. - Copyright (C) 1994-2016 Free Software Foundation, Inc. + Copyright (C) 1994-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, October 1994. diff --git a/locale/programs/simple-hash.h b/locale/programs/simple-hash.h index cc3f85655c..ce55a70879 100644 --- a/locale/programs/simple-hash.h +++ b/locale/programs/simple-hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. diff --git a/locale/programs/xmalloc.c b/locale/programs/xmalloc.c index 7524fa5083..be1e43d920 100644 --- a/locale/programs/xmalloc.c +++ b/locale/programs/xmalloc.c @@ -1,5 +1,5 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-2016 Free Software Foundation, Inc. + Copyright (C) 1990-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify diff --git a/locale/programs/xstrdup.c b/locale/programs/xstrdup.c index 534ac56e36..7331d6410f 100644 --- a/locale/programs/xstrdup.c +++ b/locale/programs/xstrdup.c @@ -1,5 +1,5 @@ /* xstrdup.c -- copy a string with out of memory checking - Copyright (C) 1990-2016 Free Software Foundation, Inc. + Copyright (C) 1990-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify diff --git a/locale/setlocale.c b/locale/setlocale.c index 69b314134b..e4de907e1f 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 @@ -283,7 +283,7 @@ setlocale (int category, const char *locale) if (__glibc_unlikely (strchr (locale, ';') != NULL)) { /* This is a composite name. Make a copy and split it up. */ - locale_copy = strdup (locale); + locale_copy = __strdup (locale); if (__glibc_unlikely (locale_copy == NULL)) { __libc_rwlock_unlock (__libc_setlocale_lock); diff --git a/locale/strlen-hash.h b/locale/strlen-hash.h index a4c3527e3a..8973f188a0 100644 --- a/locale/strlen-hash.h +++ b/locale/strlen-hash.h @@ -1,5 +1,5 @@ /* Implements hashing function for string with known length. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/locale/tst-C-locale.c b/locale/tst-C-locale.c index e8a9a32043..cee08822b1 100644 --- a/locale/tst-C-locale.c +++ b/locale/tst-C-locale.c @@ -1,5 +1,5 @@ /* Tests of C and POSIX locale contents. - Copyright (C) 2000-2016 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2000. diff --git a/locale/uselocale.c b/locale/uselocale.c index 53021f435c..5ba77c5639 100644 --- a/locale/uselocale.c +++ b/locale/uselocale.c @@ -1,5 +1,5 @@ /* uselocale -- fetch and set the current per-thread locale - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 @@ -34,7 +34,7 @@ __uselocale (locale_t newloc) { const locale_t locobj = newloc == LC_GLOBAL_LOCALE ? &_nl_global_locale : newloc; - __libc_tsd_set (__locale_t, LOCALE, locobj); + __libc_tsd_set (locale_t, LOCALE, locobj); #ifdef NL_CURRENT_INDIRECT /* Now we must update all the per-category thread-local variables to diff --git a/locale/weight.h b/locale/weight.h index c99730c4fb..6028d3595e 100644 --- a/locale/weight.h +++ b/locale/weight.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper, <drepper@cygnus.com>. @@ -19,6 +19,8 @@ #ifndef _WEIGHT_H_ #define _WEIGHT_H_ 1 +#include <libc-diag.h> + /* Find index of weight. */ static inline int32_t __attribute__ ((always_inline)) findidx (const int32_t *table, @@ -61,9 +63,17 @@ findidx (const int32_t *table, already. */ size_t cnt; + /* With GCC 5.3 when compiling with -Os the compiler warns + that seq2.back_us, which becomes usrc, might be used + uninitialized. This can't be true because we pass a length + of -1 for len at the same time which means that this loop + never executes. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); for (cnt = 0; cnt < nhere && cnt < len; ++cnt) if (cp[cnt] != usrc[cnt]) break; + DIAG_POP_NEEDS_COMMENT; if (cnt == nhere) { @@ -122,7 +132,15 @@ findidx (const int32_t *table, do { offset <<= 8; + /* With GCC 7 when compiling with -Os the compiler + warns that seq1.back_us and seq2.back_us, which + become usrc, might be used uninitialized. This + is impossible for the same reason as described + above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); offset += usrc[cnt] - cp[cnt]; + DIAG_POP_NEEDS_COMMENT; } while (++cnt < nhere); } diff --git a/locale/weightwc.h b/locale/weightwc.h index ab26482996..7ee335dc9a 100644 --- a/locale/weightwc.h +++ b/locale/weightwc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper, <drepper@cygnus.com>. @@ -19,6 +19,8 @@ #ifndef _WEIGHTWC_H_ #define _WEIGHTWC_H_ 1 +#include <libc-diag.h> + /* Find index of weight. */ static inline int32_t __attribute__ ((always_inline)) findidx (const int32_t *table, @@ -26,7 +28,15 @@ findidx (const int32_t *table, const wint_t *extra, const wint_t **cpp, size_t len) { + /* With GCC 7 when compiling with -Os the compiler warns that + seq1.back_us and seq2.back_us, which become *cpp, might be used + uninitialized. This is impossible as this function cannot be + called except in cases where those fields have been + initialized. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); wint_t ch = *(*cpp)++; + DIAG_POP_NEEDS_COMMENT; int32_t i = __collidx_table_lookup ((const char *) table, ch); if (i >= 0) @@ -59,9 +69,17 @@ findidx (const int32_t *table, already. */ size_t cnt; + /* With GCC 5.3 when compiling with -Os the compiler warns + that seq2.back_us, which becomes usrc, might be used + uninitialized. This can't be true because we pass a length + of -1 for len at the same time which means that this loop + never executes. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); for (cnt = 0; cnt < nhere && cnt < len; ++cnt) if (cp[cnt] != usrc[cnt]) break; + DIAG_POP_NEEDS_COMMENT; if (cnt == nhere) { @@ -80,23 +98,37 @@ findidx (const int32_t *table, size_t cnt; size_t offset; + /* With GCC 7 when compiling with -Os the compiler warns + that seq1.back_us and seq2.back_us, which become usrc, + might be used uninitialized. This is impossible for the + same reason as described above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); for (cnt = 0; cnt < nhere - 1 && cnt < len; ++cnt) if (cp[cnt] != usrc[cnt]) break; + DIAG_POP_NEEDS_COMMENT; - if (cnt < nhere - 1) + if (cnt < nhere - 1 || cnt == len) { cp += 2 * nhere; continue; } - if (cp[nhere - 1] > usrc[nhere -1]) + /* With GCC 7 when compiling with -Os the compiler warns + that seq1.back_us and seq2.back_us, which become usrc, + might be used uninitialized. This is impossible for the + same reason as described above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); + if (cp[nhere - 1] > usrc[nhere - 1]) { cp += 2 * nhere; continue; } + DIAG_POP_NEEDS_COMMENT; - if (cp[2 * nhere - 1] < usrc[nhere -1]) + if (cp[2 * nhere - 1] < usrc[nhere - 1]) { cp += 2 * nhere; continue; diff --git a/locale/xlocale.c b/locale/xlocale.c index 18faaf1a8f..8a52c48e58 100644 --- a/locale/xlocale.c +++ b/locale/xlocale.c @@ -1,5 +1,5 @@ /* C locale object. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001. |