Date: Friday, May 13, 2022 @ 15:27:12 Author: freswa Revision: 445407
remove unused patchfiles Deleted: glibc/trunk/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch glibc/trunk/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch glibc/trunk/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch -----------------------------------------------------------------+ 0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch | 380 ---------- 0001-localedata-Do-not-generate-output-if-warnings-were-p.patch | 69 - 0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch | 302 ------- 3 files changed, 751 deletions(-) Deleted: 0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch =================================================================== --- 0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch 2022-05-13 15:25:34 UTC (rev 445406) +++ 0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch 2022-05-13 15:27:12 UTC (rev 445407) @@ -1,380 +0,0 @@ -From 10fe3cd309b32c003a6b98e08928e7d6007caecf Mon Sep 17 00:00:00 2001 -From: Adhemerval Zanella <[email protected]> -Date: Tue, 8 Feb 2022 15:22:49 -0300 -Subject: [PATCH] elf: Fix DFS sorting algorithm for LD_TRACE_LOADED_OBJECTS - with missing libraries (BZ #28868) - -On _dl_map_object the underlying file is not opened in trace mode -(in other cases where the underlying file can't be opened, -_dl_map_object quits with an error). If there any missing libraries -being processed, they will not be considered on final nlist size -passed on _dl_sort_maps later in the function. And it is then used by -_dl_sort_maps_dfs on the stack allocated working maps: - -222 /* Array to hold RPO sorting results, before we copy back to maps[]. */ -223 struct link_map *rpo[nmaps]; -224 -225 /* The 'head' position during each DFS iteration. Note that we start at -226 one past the last element due to first-decrement-then-store (see the -227 bottom of above dfs_traversal() routine). */ -228 struct link_map **rpo_head = &rpo[nmaps]; - -However while transversing the 'l_initfini' on dfs_traversal it will -still consider the l_faked maps and thus update rpo more times than the -allocated working 'rpo', overflowing the stack object. - -As suggested in bugzilla, one option would be to avoid sorting the maps -for trace mode. However I think ignoring l_faked object does make -sense (there is one less constraint to call the sorting function), it -allows a slight less stack usage for trace, and it is slight simpler -solution. - -The tests does trigger the stack overflow, however I tried to make -it more generic to check different scenarios or missing objects. - -Checked on x86_64-linux-gnu. - -Reviewed-by: Siddhesh Poyarekar <[email protected]> -(cherry picked from commit 3a0588ae48fb35384a6bd33f9b66403badfa1262) ---- - elf/Makefile | 54 ++++++++++++++++++++ - elf/dl-deps.c | 2 + - elf/dl-sort-maps.c | 4 +- - elf/libtracemod1-1.c | 1 + - elf/libtracemod2-1.c | 1 + - elf/libtracemod3-1.c | 1 + - elf/libtracemod4-1.c | 1 + - elf/libtracemod5-1.c | 1 + - elf/tst-trace1.exp | 4 ++ - elf/tst-trace2.exp | 6 +++ - elf/tst-trace3.exp | 6 +++ - elf/tst-trace4.exp | 6 +++ - elf/tst-trace5.exp | 6 +++ - scripts/tst-ld-trace.py | 108 ++++++++++++++++++++++++++++++++++++++++ - 15 files changed, 202 insertions(+), 1 deletion(-) - create mode 100644 elf/libtracemod1-1.c - create mode 100644 elf/libtracemod2-1.c - create mode 100644 elf/libtracemod3-1.c - create mode 100644 elf/libtracemod4-1.c - create mode 100644 elf/libtracemod5-1.c - create mode 100644 elf/tst-trace1.exp - create mode 100644 elf/tst-trace2.exp - create mode 100644 elf/tst-trace3.exp - create mode 100644 elf/tst-trace4.exp - create mode 100644 elf/tst-trace5.exp - create mode 100755 scripts/tst-ld-trace.py - -diff --git a/elf/Makefile b/elf/Makefile -index 4bca0424a3..fa1ea28b25 100644 ---- a/elf/Makefile -+++ b/elf/Makefile -@@ -652,6 +652,11 @@ modules-names = \ - libmarkermod4-2 \ - libmarkermod4-3 \ - libmarkermod4-4 \ -+ libtracemod1-1 \ -+ libtracemod2-1 \ -+ libtracemod3-1 \ -+ libtracemod4-1 \ -+ libtracemod5-1 \ - ltglobmod1 \ - ltglobmod2 \ - neededobj1 \ -@@ -1112,6 +1117,11 @@ tests-special += \ - $(objpfx)tst-initorder2-cmp.out \ - $(objpfx)tst-unused-dep-cmp.out \ - $(objpfx)tst-unused-dep.out \ -+ $(objpfx)tst-trace1.out \ -+ $(objpfx)tst-trace2.out \ -+ $(objpfx)tst-trace3.out \ -+ $(objpfx)tst-trace4.out \ -+ $(objpfx)tst-trace5.out \ - # tests-special - endif - -@@ -2787,3 +2797,47 @@ $(objpfx)tst-p_align3: $(objpfx)tst-p_alignmod3.so - $(objpfx)tst-p_align3.out: tst-p_align3.sh $(objpfx)tst-p_align3 - $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \ - $(evaluate-test) -+ -+LDFLAGS-libtracemod1-1.so += -Wl,-soname,libtracemod1.so -+LDFLAGS-libtracemod2-1.so += -Wl,-soname,libtracemod2.so -+LDFLAGS-libtracemod3-1.so += -Wl,-soname,libtracemod3.so -+LDFLAGS-libtracemod4-1.so += -Wl,-soname,libtracemod4.so -+LDFLAGS-libtracemod5-1.so += -Wl,-soname,libtracemod5.so -+ -+$(objpfx)libtracemod1-1.so: $(objpfx)libtracemod2-1.so \ -+ $(objpfx)libtracemod3-1.so -+$(objpfx)libtracemod2-1.so: $(objpfx)libtracemod4-1.so \ -+ $(objpfx)libtracemod5-1.so -+ -+define libtracemod-x -+$(objpfx)libtracemod$(1)/libtracemod$(1).so: $(objpfx)libtracemod$(1)-1.so -+ $$(make-target-directory) -+ cp $$< $$@ -+endef -+libtracemod-suffixes = 1 2 3 4 5 -+$(foreach i,$(libtracemod-suffixes), $(eval $(call libtracemod-x,$(i)))) -+ -+define tst-trace-skeleton -+$(objpfx)tst-trace$(1).out: $(objpfx)libtracemod1/libtracemod1.so \ -+ $(objpfx)libtracemod2/libtracemod2.so \ -+ $(objpfx)libtracemod3/libtracemod3.so \ -+ $(objpfx)libtracemod4/libtracemod4.so \ -+ $(objpfx)libtracemod5/libtracemod5.so \ -+ $(..)scripts/tst-ld-trace.py \ -+ tst-trace$(1).exp -+ ${ $(PYTHON) $(..)scripts/tst-ld-trace.py \ -+ "$(test-wrapper-env) $(elf-objpfx)$(rtld-installed-name) \ -+ --library-path $(common-objpfx):$(strip $(2)) \ -+ $(objpfx)libtracemod1/libtracemod1.so" tst-trace$(1).exp \ -+ } > $$@; $$(evaluate-test) -+endef -+ -+$(eval $(call tst-trace-skeleton,1,)) -+$(eval $(call tst-trace-skeleton,2,\ -+ $(objpfx)libtracemod2)) -+$(eval $(call tst-trace-skeleton,3,\ -+ $(objpfx)libtracemod2:$(objpfx)libtracemod3)) -+$(eval $(call tst-trace-skeleton,4,\ -+ $(objpfx)libtracemod2:$(objpfx)libtracemod3:$(objpfx)libtracemod4)) -+$(eval $(call tst-trace-skeleton,5,\ -+ $(objpfx)libtracemod2:$(objpfx)libtracemod3:$(objpfx)libtracemod4:$(objpfx)libtracemod5)) -diff --git a/elf/dl-deps.c b/elf/dl-deps.c -index c8bab5cad5..cfe7f0743a 100644 ---- a/elf/dl-deps.c -+++ b/elf/dl-deps.c -@@ -489,6 +489,8 @@ _dl_map_object_deps (struct link_map *map, - - for (nlist = 0, runp = known; runp; runp = runp->next) - { -+ /* _dl_sort_maps ignores l_faked object, so it is safe to not consider -+ them for nlist. */ - if (__builtin_expect (trace_mode, 0) && runp->map->l_faked) - /* This can happen when we trace the loading. */ - --map->l_searchlist.r_nlist; -diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c -index 9e9d53ec47..96638d7ed1 100644 ---- a/elf/dl-sort-maps.c -+++ b/elf/dl-sort-maps.c -@@ -140,7 +140,9 @@ static void - dfs_traversal (struct link_map ***rpo, struct link_map *map, - bool *do_reldeps) - { -- if (map->l_visited) -+ /* _dl_map_object_deps ignores l_faked objects when calculating the -+ number of maps before calling _dl_sort_maps, ignore them as well. */ -+ if (map->l_visited || map->l_faked) - return; - - map->l_visited = 1; -diff --git a/elf/libtracemod1-1.c b/elf/libtracemod1-1.c -new file mode 100644 -index 0000000000..7c89c9a5a4 ---- /dev/null -+++ b/elf/libtracemod1-1.c -@@ -0,0 +1 @@ -+/* Empty */ -diff --git a/elf/libtracemod2-1.c b/elf/libtracemod2-1.c -new file mode 100644 -index 0000000000..7c89c9a5a4 ---- /dev/null -+++ b/elf/libtracemod2-1.c -@@ -0,0 +1 @@ -+/* Empty */ -diff --git a/elf/libtracemod3-1.c b/elf/libtracemod3-1.c -new file mode 100644 -index 0000000000..7c89c9a5a4 ---- /dev/null -+++ b/elf/libtracemod3-1.c -@@ -0,0 +1 @@ -+/* Empty */ -diff --git a/elf/libtracemod4-1.c b/elf/libtracemod4-1.c -new file mode 100644 -index 0000000000..7c89c9a5a4 ---- /dev/null -+++ b/elf/libtracemod4-1.c -@@ -0,0 +1 @@ -+/* Empty */ -diff --git a/elf/libtracemod5-1.c b/elf/libtracemod5-1.c -new file mode 100644 -index 0000000000..7c89c9a5a4 ---- /dev/null -+++ b/elf/libtracemod5-1.c -@@ -0,0 +1 @@ -+/* Empty */ -diff --git a/elf/tst-trace1.exp b/elf/tst-trace1.exp -new file mode 100644 -index 0000000000..4a6f5211a6 ---- /dev/null -+++ b/elf/tst-trace1.exp -@@ -0,0 +1,4 @@ -+ld 1 -+libc 1 -+libtracemod2.so 0 -+libtracemod3.so 0 -diff --git a/elf/tst-trace2.exp b/elf/tst-trace2.exp -new file mode 100644 -index 0000000000..e13506e2eb ---- /dev/null -+++ b/elf/tst-trace2.exp -@@ -0,0 +1,6 @@ -+ld 1 -+libc 1 -+libtracemod2.so 1 -+libtracemod3.so 0 -+libtracemod4.so 0 -+libtracemod5.so 0 -diff --git a/elf/tst-trace3.exp b/elf/tst-trace3.exp -new file mode 100644 -index 0000000000..e574549d12 ---- /dev/null -+++ b/elf/tst-trace3.exp -@@ -0,0 +1,6 @@ -+ld 1 -+libc 1 -+libtracemod2.so 1 -+libtracemod3.so 1 -+libtracemod4.so 0 -+libtracemod5.so 0 -diff --git a/elf/tst-trace4.exp b/elf/tst-trace4.exp -new file mode 100644 -index 0000000000..31ca97b35b ---- /dev/null -+++ b/elf/tst-trace4.exp -@@ -0,0 +1,6 @@ -+ld 1 -+libc 1 -+libtracemod2.so 1 -+libtracemod3.so 1 -+libtracemod4.so 1 -+libtracemod5.so 0 -diff --git a/elf/tst-trace5.exp b/elf/tst-trace5.exp -new file mode 100644 -index 0000000000..5d7d953726 ---- /dev/null -+++ b/elf/tst-trace5.exp -@@ -0,0 +1,6 @@ -+ld 1 -+libc 1 -+libtracemod2.so 1 -+libtracemod3.so 1 -+libtracemod4.so 1 -+libtracemod5.so 1 -diff --git a/scripts/tst-ld-trace.py b/scripts/tst-ld-trace.py -new file mode 100755 -index 0000000000..f5a4028003 ---- /dev/null -+++ b/scripts/tst-ld-trace.py -@@ -0,0 +1,108 @@ -+#!/usr/bin/python3 -+# Dump the output of LD_TRACE_LOADED_OBJECTS in architecture neutral format. -+# Copyright (C) 2022 Free Software Foundation, Inc. -+# Copyright The GNU Toolchain Authors. -+# 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 -+# <https://www.gnu.org/licenses/>. -+ -+import argparse -+import os -+import subprocess -+import sys -+ -+try: -+ subprocess.run -+except: -+ class _CompletedProcess: -+ def __init__(self, args, returncode, stdout=None, stderr=None): -+ self.args = args -+ self.returncode = returncode -+ self.stdout = stdout -+ self.stderr = stderr -+ -+ def _run(*popenargs, input=None, timeout=None, check=False, **kwargs): -+ assert(timeout is None) -+ with subprocess.Popen(*popenargs, **kwargs) as process: -+ try: -+ stdout, stderr = process.communicate(input) -+ except: -+ process.kill() -+ process.wait() -+ raise -+ returncode = process.poll() -+ if check and returncode: -+ raise subprocess.CalledProcessError(returncode, popenargs) -+ return _CompletedProcess(popenargs, returncode, stdout, stderr) -+ -+ subprocess.run = _run -+ -+def is_vdso(lib): -+ return lib.startswith('linux-gate') or lib.startswith('linux-vdso') -+ -+ -+def parse_trace(cmd, fref): -+ new_env = os.environ.copy() -+ new_env['LD_TRACE_LOADED_OBJECTS'] = '1' -+ trace_out = subprocess.run(cmd, stdout=subprocess.PIPE, check=True, -+ universal_newlines=True, env=new_env).stdout -+ trace = [] -+ for line in trace_out.splitlines(): -+ line = line.strip() -+ if is_vdso(line): -+ continue -+ fields = line.split('=>' if '=>' in line else ' ') -+ lib = os.path.basename(fields[0].strip()) -+ if lib.startswith('ld'): -+ lib = 'ld' -+ elif lib.startswith('libc'): -+ lib = 'libc' -+ found = 1 if fields[1].strip() != 'not found' else 0 -+ trace += ['{} {}'.format(lib, found)] -+ trace = sorted(trace) -+ -+ reference = sorted(line.replace('\n','') for line in fref.readlines()) -+ -+ ret = 0 if trace == reference else 1 -+ if ret != 0: -+ for i in reference: -+ if i not in trace: -+ print("Only in {}: {}".format(fref.name, i)) -+ for i in trace: -+ if i not in reference: -+ print("Only in trace: {}".format(i)) -+ -+ sys.exit(ret) -+ -+ -+def get_parser(): -+ parser = argparse.ArgumentParser(description=__doc__) -+ parser.add_argument('command', -+ help='comand to run') -+ parser.add_argument('reference', -+ help='reference file to compare') -+ return parser -+ -+ -+def main(argv): -+ parser = get_parser() -+ opts = parser.parse_args(argv) -+ with open(opts.reference, 'r') as fref: -+ # Remove the initial 'env' command. -+ parse_trace(opts.command.split()[1:], fref) -+ -+ -+if __name__ == '__main__': -+ main(sys.argv[1:]) --- -2.36.0 - Deleted: 0001-localedata-Do-not-generate-output-if-warnings-were-p.patch =================================================================== --- 0001-localedata-Do-not-generate-output-if-warnings-were-p.patch 2022-05-13 15:25:34 UTC (rev 445406) +++ 0001-localedata-Do-not-generate-output-if-warnings-were-p.patch 2022-05-13 15:27:12 UTC (rev 445407) @@ -1,69 +0,0 @@ -From 732dd3a63d39c7ca77e817b462285c14551c8b49 Mon Sep 17 00:00:00 2001 -From: Carlos O'Donell <[email protected]> -Date: Thu, 3 Feb 2022 16:01:52 -0500 -Subject: [PATCH] localedata: Do not generate output if warnings were present. - -With LC_MONETARY parsing fixed we can now generate locales -without forcing output with '-c'. - -Removing '-c' from localedef invocation is the equivalent of -using -Werror for localedef. The glibc locale sources should -always be clean and free from warnings. - -We remove '-c' from both test locale generation and the targets -used for installing locales e.g. install-locale-archive, and -install-locale-files. - -Tested on x86_64 and i686 without regressions. -Tested with install-locale-archive target. -Tested with install-locale-files target. - -Reviewed-by: DJ Delorie <[email protected]> -(cherry picked from commit 1c7a34567d21fbd3b706c77cd794956b43daefe7) ---- - localedata/Makefile | 4 ++-- - localedata/gen-locale.sh | 10 ++++++++-- - 2 files changed, 10 insertions(+), 4 deletions(-) - -diff --git a/localedata/Makefile b/localedata/Makefile -index 9ae2e5c161..7741ac3b5e 100644 ---- a/localedata/Makefile -+++ b/localedata/Makefile -@@ -468,11 +468,11 @@ define build-one-locale - endef - - $(INSTALL-SUPPORTED-LOCALE-ARCHIVE): install-locales-dir -- @flags="-c"; \ -+ @flags=""; \ - $(build-one-locale) - - $(INSTALL-SUPPORTED-LOCALE-FILES): install-locales-dir -- @flags="-c --no-archive --no-hard-links"; \ -+ @flags="--no-archive --no-hard-links"; \ - $(build-one-locale) - - tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP -diff --git a/localedata/gen-locale.sh b/localedata/gen-locale.sh -index 7fce35f212..8053c816a6 100644 ---- a/localedata/gen-locale.sh -+++ b/localedata/gen-locale.sh -@@ -54,8 +54,14 @@ modifier=`echo $locfile|sed 's|[^.]*[.]\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\2|'` - - echo "Generating locale $locale.$charmap: this might take a while..." - --# Run quietly and force output. --flags="--quiet -c" -+# Do not force output with '-c', all locales should compile without -+# warning or errors. There is likewise no need to run quietly with -+# '--quiet' since all locales should compile without additional -+# diagnostics. If there are messages printed then we want to see -+# them, fix them, and the associated error or warning. During -+# development it may be beneficialy to put '--quiet -c' here to allow -+# you to develop in-progress locales. -+flags="" - - # For SJIS the charmap is SHIFT_JIS. We just want the locale to have - # a slightly nicer name instead of using "*.SHIFT_SJIS", but that --- -2.35.1 - Deleted: 0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch =================================================================== --- 0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch 2022-05-13 15:25:34 UTC (rev 445406) +++ 0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch 2022-05-13 15:27:12 UTC (rev 445407) @@ -1,302 +0,0 @@ -From 3feecd80013c822a12d4b01c5c25e155dfbc6e2f Mon Sep 17 00:00:00 2001 -From: Carlos O'Donell <[email protected]> -Date: Thu, 3 Feb 2022 16:51:59 -0500 -Subject: [PATCH] localedef: Update LC_MONETARY handling (Bug 28845) - -ISO C17, POSIX Issue 7, and ISO 30112 all allow the char* -types to be empty strings i.e. "", integer or char values to -be -1 or CHAR_MAX respectively, with the exception of -decimal_point which must be non-empty in ISO C. Note that -the defaults for mon_grouping vary, but are functionaly -equivalent e.g. "\177" (no further grouping reuqired) vs. -"" (no grouping defined for all groups). - -We include a broad comment talking about harmonizing ISO C, -POSIX, ISO 30112, and the default C/POSIX locale for glibc. - -We reorder all setting based on locale/categories.def order. - -We soften all missing definitions from errors to warnings when -defaults exist. - -Given that ISO C, POSIX and ISO 30112 allow the empty string -we change LC_MONETARY handling of mon_decimal_point to allow -the empty string. If mon_decimal_point is not defined at all -then we pick the existing legacy glibc default value of -<U002E> i.e. ".". - -We also set the default for mon_thousands_sep_wc at the -same time as mon_thousands_sep, but this is not a change in -behaviour, it is always either a matching value or L'\0', -but if in the future we change the default to a non-empty -string we would need to update both at the same time. - -Tested on x86_64 and i686 without regressions. -Tested with install-locale-archive target. -Tested with install-locale-files target. - -Reviewed-by: DJ Delorie <[email protected]> -(cherry picked from commit 2ab8b74567dc0a9a3c98696e6444881997dd6c49) ---- - locale/programs/ld-monetary.c | 182 +++++++++++++++++++++++++++------- - 1 file changed, 146 insertions(+), 36 deletions(-) - -diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c -index 3b0412b405..18698bbe94 100644 ---- a/locale/programs/ld-monetary.c -+++ b/locale/programs/ld-monetary.c -@@ -196,21 +196,105 @@ No definition for %s category found"), "LC_MONETARY"); - } - } - -+ /* Generally speaking there are 3 standards the define the default, -+ warning, and error behaviour of LC_MONETARY. They are ISO/IEC TR 30112, -+ ISO/IEC 9899:2018 (ISO C17), and POSIX.1-2017. Within 30112 we have the -+ definition of a standard i18n FDCC-set, which for LC_MONETARY has the -+ following default values: -+ int_curr_symbol "" -+ currency_symbol "" -+ mon_decimal_point "<U002C>" i.e. "," -+ mon_thousand_sep "" -+ mon_grouping "\177" i.e. CHAR_MAX -+ positive_sign "" -+ negative_sign "<U002E>" i.e. "." -+ int_frac_digits -1 -+ frac_digits -1 -+ p_cs_precedes -1 -+ p_sep_by_space -1 -+ n_cs_precedes -1 -+ n_sep_by_space -1 -+ p_sign_posn -1 -+ n_sign_posn -1 -+ Under 30112 a keyword that is not provided implies an empty string "" -+ for string values or a -1 for integer values, and indicates the value -+ is unspecified with no default implied. No errors are considered. -+ The exception is mon_grouping which is a string with a terminating -+ CHAR_MAX. -+ For POSIX Issue 7 we have: -+ https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html -+ and again values not provided default to "" or -1, and indicate the value -+ is not available to the locale. The exception is mon_grouping which is -+ a string with a terminating CHAR_MAX. For the POSIX locale the values of -+ LC_MONETARY should be: -+ int_curr_symbol "" -+ currency_symbol "" -+ mon_decimal_point "" -+ mon_thousands_sep "" -+ mon_grouping "\177" i.e. CHAR_MAX -+ positive_sign "" -+ negative_sign "" -+ int_frac_digits -1 -+ frac_digits -1 -+ p_cs_precedes -1 -+ p_sep_by_space -1 -+ n_cs_precedes -1 -+ n_sep_by_space -1 -+ p_sign_posn -1 -+ n_sign_posn -1 -+ int_p_cs_precedes -1 -+ int_p_sep_by_space -1 -+ int_n_cs_precedes -1 -+ int_n_sep_by_space -1 -+ int_p_sign_posn -1 -+ int_n_sign_posn -1 -+ Like with 30112, POSIX also considers no error if the keywords are -+ missing, only that if the cateory as a whole is missing the referencing -+ of the category results in unspecified behaviour. -+ For ISO C17 there is no default value provided, but the localeconv -+ specification in 7.11.2.1 admits that members of char * type may point -+ to "" to indicate a value is not available or is of length zero. -+ The exception is decimal_point (not mon_decimal_point) which must be a -+ defined non-empty string. The values of char, which are generally -+ mapped to integer values in 30112 and POSIX, must be non-negative -+ numbers that map to CHAR_MAX when a value is not available in the -+ locale. -+ In ISO C17 for the "C" locale all values are empty strings "", or -+ CHAR_MAX, with the exception of decimal_point which is "." (defined -+ in LC_NUMERIC). ISO C17 makes no exception for mon_grouping like -+ 30112 and POSIX, but a value of "" is functionally equivalent to -+ "\177" since neither defines a grouping (though the latter terminates -+ the grouping). -+ -+ Lastly, we must consider the legacy C/POSIX locale that implemented -+ as a builtin in glibc and wether a default value mapping to the -+ C/POSIX locale may benefit the user from a compatibility perspective. -+ -+ Thus given 30112, POSIX, ISO C, and the builtin C/POSIX locale we -+ need to pick appropriate defaults below. */ -+ -+ /* The members of LC_MONETARY are handled in the order of their definition -+ in locale/categories.def. Please keep them in that order. */ -+ -+ /* The purpose of TEST_ELEM is to define a default value for the fields -+ in the category if the field was not defined in the cateory. If the -+ category was present but we didn't see a definition for the field then -+ we also issue a warning, otherwise the only warning you get is the one -+ earlier when a default category is created (completely missing category). -+ This missing field warning is glibc-specific since no standard requires -+ this warning, but we consider it valuable to print a warning for all -+ missing fields in the category. */ - #define TEST_ELEM(cat, initval) \ - if (monetary->cat == NULL) \ - { \ - if (! nothing) \ -- record_error (0, 0, _("%s: field `%s' not defined"), \ -- "LC_MONETARY", #cat); \ -+ record_warning (_("%s: field `%s' not defined"), \ -+ "LC_MONETARY", #cat); \ - monetary->cat = initval; \ - } - -+ /* Keyword: int_curr_symbol. */ - TEST_ELEM (int_curr_symbol, ""); -- TEST_ELEM (currency_symbol, ""); -- TEST_ELEM (mon_thousands_sep, ""); -- TEST_ELEM (positive_sign, ""); -- TEST_ELEM (negative_sign, ""); -- - /* The international currency symbol must come from ISO 4217. */ - if (monetary->int_curr_symbol != NULL) - { -@@ -247,41 +331,63 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), - } - } - -- /* The decimal point must not be empty. This is not said explicitly -- in POSIX but ANSI C (ISO/IEC 9899) says in 4.4.2.1 it has to be -- != "". */ -+ /* Keyword: currency_symbol */ -+ TEST_ELEM (currency_symbol, ""); -+ -+ /* Keyword: mon_decimal_point */ -+ /* ISO C17 7.11.2.1.3 explicitly allows mon_decimal_point to be the -+ empty string e.g. "". This indicates the value is not available in the -+ current locale or is of zero length. However, if the value was never -+ defined then we issue a warning and use a glibc-specific default. ISO -+ 30112 in the i18n FDCC-Set uses <U002C> ",", and POSIX Issue 7 in the -+ POSIX locale uses "". It is specific to glibc that the default is <U002E> -+ "."; we retain this existing behaviour for backwards compatibility. */ - if (monetary->mon_decimal_point == NULL) - { - if (! nothing) -- record_error (0, 0, _("%s: field `%s' not defined"), -- "LC_MONETARY", "mon_decimal_point"); -+ record_warning (_("%s: field `%s' not defined, using defaults"), -+ "LC_MONETARY", "mon_decimal_point"); - monetary->mon_decimal_point = "."; - monetary->mon_decimal_point_wc = L'.'; - } -- else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing) -+ -+ /* Keyword: mon_thousands_sep */ -+ if (monetary->mon_thousands_sep == NULL) - { -- record_error (0, 0, _("\ --%s: value for field `%s' must not be an empty string"), -- "LC_MONETARY", "mon_decimal_point"); -+ if (! nothing) -+ record_warning (_("%s: field `%s' not defined, using defaults"), -+ "LC_MONETARY", "mon_thousands_sep"); -+ monetary->mon_thousands_sep = ""; -+ monetary->mon_thousands_sep_wc = L'\0'; - } - -+ /* Keyword: mon_grouping */ - if (monetary->mon_grouping_len == 0) - { - if (! nothing) -- record_error (0, 0, _("%s: field `%s' not defined"), -- "LC_MONETARY", "mon_grouping"); -- -+ record_warning (_("%s: field `%s' not defined"), -+ "LC_MONETARY", "mon_grouping"); -+ /* Missing entries are given 1 element in their bytearray with -+ a value of CHAR_MAX which indicates that "No further grouping -+ is to be performed" (functionally equivalent to ISO C's "C" -+ locale default of ""). */ - monetary->mon_grouping = (char *) "\177"; - monetary->mon_grouping_len = 1; - } - -+ /* Keyword: positive_sign */ -+ TEST_ELEM (positive_sign, ""); -+ -+ /* Keyword: negative_sign */ -+ TEST_ELEM (negative_sign, ""); -+ - #undef TEST_ELEM - #define TEST_ELEM(cat, min, max, initval) \ - if (monetary->cat == -2) \ - { \ - if (! nothing) \ -- record_error (0, 0, _("%s: field `%s' not defined"), \ -- "LC_MONETARY", #cat); \ -+ record_warning (_("%s: field `%s' not defined"), \ -+ "LC_MONETARY", #cat); \ - monetary->cat = initval; \ - } \ - else if ((monetary->cat < min || monetary->cat > max) \ -@@ -300,16 +406,11 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), - TEST_ELEM (p_sign_posn, -1, 4, -1); - TEST_ELEM (n_sign_posn, -1, 4, -1); - -- /* The non-POSIX.2 extensions are optional. */ -- if (monetary->duo_int_curr_symbol == NULL) -- monetary->duo_int_curr_symbol = monetary->int_curr_symbol; -- if (monetary->duo_currency_symbol == NULL) -- monetary->duo_currency_symbol = monetary->currency_symbol; -- -- if (monetary->duo_int_frac_digits == -2) -- monetary->duo_int_frac_digits = monetary->int_frac_digits; -- if (monetary->duo_frac_digits == -2) -- monetary->duo_frac_digits = monetary->frac_digits; -+ /* Keyword: crncystr */ -+ monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol) -+ + 2); -+ monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+'; -+ strcpy (&monetary->crncystr[1], monetary->currency_symbol); - - #undef TEST_ELEM - #define TEST_ELEM(cat, alt, min, max) \ -@@ -327,6 +428,17 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), - TEST_ELEM (int_p_sign_posn, p_sign_posn, -1, 4); - TEST_ELEM (int_n_sign_posn, n_sign_posn, -1, 4); - -+ /* The non-POSIX.2 extensions are optional. */ -+ if (monetary->duo_int_curr_symbol == NULL) -+ monetary->duo_int_curr_symbol = monetary->int_curr_symbol; -+ if (monetary->duo_currency_symbol == NULL) -+ monetary->duo_currency_symbol = monetary->currency_symbol; -+ -+ if (monetary->duo_int_frac_digits == -2) -+ monetary->duo_int_frac_digits = monetary->int_frac_digits; -+ if (monetary->duo_frac_digits == -2) -+ monetary->duo_frac_digits = monetary->frac_digits; -+ - TEST_ELEM (duo_p_cs_precedes, p_cs_precedes, -1, 1); - TEST_ELEM (duo_p_sep_by_space, p_sep_by_space, -1, 2); - TEST_ELEM (duo_n_cs_precedes, n_cs_precedes, -1, 1); -@@ -349,17 +461,15 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), - if (monetary->duo_valid_to == 0) - monetary->duo_valid_to = 99991231; - -+ /* Keyword: conversion_rate */ - if (monetary->conversion_rate[0] == 0) - { - monetary->conversion_rate[0] = 1; - monetary->conversion_rate[1] = 1; - } - -- /* Create the crncystr entry. */ -- monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol) -- + 2); -- monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+'; -- strcpy (&monetary->crncystr[1], monetary->currency_symbol); -+ /* A value for monetary-decimal-point-wc was set when -+ monetary_decimal_point was set, likewise for monetary-thousands-sep-wc. */ - } - - --- -2.35.1 -
