diff options
author | Carlos O'Donell <carlos@redhat.com> | 2024-04-22 08:16:09 -0400 |
---|---|---|
committer | Carlos O'Donell <carlos@redhat.com> | 2024-04-22 16:03:00 -0400 |
commit | 684fbab755e727a8c15f8b621648d66694cd1f53 (patch) | |
tree | 02588a7a5bdd12ce4976c5c785f55be0bc8fff83 /localedata/gen-locale.sh | |
parent | 25b191f6d33cda5770a18fd18be86cce0ebb3228 (diff) | |
download | glibc-684fbab755e727a8c15f8b621648d66694cd1f53.tar.gz glibc-684fbab755e727a8c15f8b621648d66694cd1f53.tar.xz glibc-684fbab755e727a8c15f8b621648d66694cd1f53.zip |
locale: Handle loading a missing locale twice (Bug 14247)
Delay setting file->decided until the data has been successfully loaded by _nl_load_locale(). If the function fails to load the data then we must return and error and leave decided untouched to allow the caller to attempt to load the data again at a later time. We should not set decided to 1 early in the function since doing so may prevent attempting to load it again. We want to try loading it again because that allows an open to fail and set errno correctly. On the other side of this problem is that if we are called again with the same inputs we will fetch the cached version of the object and carry out no open syscalls and that fails to set errno so we must set errno to ENOENT in that case. There is a second code path that has to be handled where the name of the locale matches but the codeset doesn't match. These changes ensure that errno is correctly set on failure in all the return paths in _nl_find_locale(). Adds tst-locale-loadlocale to cover the bug. No regressions on x86_64. Co-authored-by: Jeff Law <law@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'localedata/gen-locale.sh')
-rw-r--r-- | localedata/gen-locale.sh | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/localedata/gen-locale.sh b/localedata/gen-locale.sh index b8c422ad13..e400d02b82 100644 --- a/localedata/gen-locale.sh +++ b/localedata/gen-locale.sh @@ -48,9 +48,9 @@ generate_locale () } locfile=`echo $locfile|sed 's|.*/\([^/]*/LC_CTYPE\)|\1|'` -locale=`echo $locfile|sed 's|\([^.]*\)[.].*/LC_CTYPE|\1|'` -charmap=`echo $locfile|sed 's|[^.]*[.]\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\1|'` -modifier=`echo $locfile|sed 's|[^.]*[.]\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\2|'` +locale=`echo $locfile|sed 's|\([^.]*\).*/LC_CTYPE|\1|'` +charmap=`echo $locfile|sed -e 's|[^.]*\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\1|' -e 's|^\.||g'` +modifier=`echo $locfile|sed 's|[^.]*\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\2|'` echo "Generating locale $locale.$charmap: this might take a while..." @@ -63,10 +63,16 @@ echo "Generating locale $locale.$charmap: this might take a while..." # you to develop in-progress locales. flags="" +charmap_real="$charmap" + +# If no character map is specified then we fall back to UTF-8. +if [ -z "$charmap" ]; then + charmap_real="UTF-8" +fi + # 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 # means we need a mapping here. -charmap_real="$charmap" if [ "$charmap" = "SJIS" ]; then charmap_real="SHIFT_JIS" fi @@ -80,4 +86,12 @@ if [ "$charmap_real" = 'SHIFT_JIS' ] \ flags="$flags --no-warnings=ascii" fi -generate_locale $charmap_real $locale$modifier $locale.$charmap$modifier "$flags" +# If the character map is not specified then we output a locale +# with the just the name of the locale e.g. eo, en_US. This is +# used for test locales that act as fallbacks. +output_file="$locale.$charmap$modifier" +if [ -z "$charmap" ]; then + output_file="$locale" +fi + +generate_locale $charmap_real $locale$modifier $output_file "$flags" |