unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621)
@ 2022-11-15  0:56 Bruno Haible
  2023-09-04 13:34 ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Haible @ 2022-11-15  0:56 UTC (permalink / raw)
  To: libc-alpha; +Cc: Bruno Haible

The wiki page https://sourceware.org/glibc/wiki/Proposals/C.UTF-8
says that "Setting LC_ALL=C.UTF-8 will ignore LANGUAGE just like it
does with LC_ALL=C." This patch implements it.

* intl/dcigettext.c (guess_category_value): Treat C.<encoding> locale
like the C locale.
---
 intl/dcigettext.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index 1fc074a414..6a3c248e68 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1564,8 +1564,12 @@ guess_category_value (int category, const char *categoryname)
      2. The precise output of some programs in the "C" locale is specified
 	by POSIX and should not depend on environment variables like
 	"LANGUAGE" or system-dependent information.  We allow such programs
-        to use gettext().  */
-  if (strcmp (locale, "C") == 0)
+        to use gettext().
+     Ignore LANGUAGE and its system-dependent analogon also if the locale is
+     set to "C.UTF-8" or, more generally, to "C.<encoding>", because that's
+     the by-design behaviour for glibc, see
+     <https://sourceware.org/glibc/wiki/Proposals/C.UTF-8>.  */
+  if (locale[0] == 'C' && (locale[1] == '\0' || locale[1] == '.'))
     return locale;
 
   /* The highest priority value is the value of the 'LANGUAGE' environment
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621)
  2022-11-15  0:56 [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621) Bruno Haible
@ 2023-09-04 13:34 ` Florian Weimer via Libc-alpha
  2023-09-10 19:10   ` Bruno Haible
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer via Libc-alpha @ 2023-09-04 13:34 UTC (permalink / raw)
  To: Bruno Haible; +Cc: libc-alpha

* Bruno Haible:

> The wiki page https://sourceware.org/glibc/wiki/Proposals/C.UTF-8
> says that "Setting LC_ALL=C.UTF-8 will ignore LANGUAGE just like it
> does with LC_ALL=C." This patch implements it.
>
> * intl/dcigettext.c (guess_category_value): Treat C.<encoding> locale
> like the C locale.
> ---
>  intl/dcigettext.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/intl/dcigettext.c b/intl/dcigettext.c
> index 1fc074a414..6a3c248e68 100644
> --- a/intl/dcigettext.c
> +++ b/intl/dcigettext.c
> @@ -1564,8 +1564,12 @@ guess_category_value (int category, const char *categoryname)
>       2. The precise output of some programs in the "C" locale is specified
>  	by POSIX and should not depend on environment variables like
>  	"LANGUAGE" or system-dependent information.  We allow such programs
> -        to use gettext().  */
> -  if (strcmp (locale, "C") == 0)
> +        to use gettext().
> +     Ignore LANGUAGE and its system-dependent analogon also if the locale is
> +     set to "C.UTF-8" or, more generally, to "C.<encoding>", because that's
> +     the by-design behaviour for glibc, see
> +     <https://sourceware.org/glibc/wiki/Proposals/C.UTF-8>.  */
> +  if (locale[0] == 'C' && (locale[1] == '\0' || locale[1] == '.'))
>      return locale;
>  
>    /* The highest priority value is the value of the 'LANGUAGE' environment

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Fix pushed.  I've posted my test case as well:

  [PATCH] intl: Add test case for bug 16621
  <https://inbox.sourceware.org/libc-alpha/87o7iiukpt.fsf@oldenburg3.str.redhat.com/T/#u>

Thanks,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621)
  2023-09-04 13:34 ` Florian Weimer via Libc-alpha
@ 2023-09-10 19:10   ` Bruno Haible
  0 siblings, 0 replies; 4+ messages in thread
From: Bruno Haible @ 2023-09-10 19:10 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

Florian Weimer wrote:
> > * intl/dcigettext.c (guess_category_value): Treat C.<encoding> locale
> > like the C locale.
> 
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
> 
> Fix pushed.

Thanks!

> I've posted my test case as well:
> 
>   [PATCH] intl: Add test case for bug 16621
>   <https://inbox.sourceware.org/libc-alpha/87o7iiukpt.fsf@oldenburg3.str.redhat.com/T/#u>

Now that the main patch is in glibc, I added it also to GNU gettext, together with a unit
test. My unit test [1][2] happens to be stricter than what I had manually tested in Dec. 2022:
It adds a .mo file at <LOCALEDIR>/C/LC_MESSAGES/<domain>.mo . And the test fails. A
second patch is needed, basically the same change at a different place in dcigettext.c.
I'm posting it separately.

Bruno

[1] https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/tests/intl-0;h=9977cfe2e5d645c3a20fbfe891974720aacb488d;hb=HEAD
[2] https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/tests/intl-1-prg.c;h=cda076140b4d60d2a9535d4fa1d769f26c580c20;hb=HEAD




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621)
@ 2023-11-20 18:12 Bruno Haible
  0 siblings, 0 replies; 4+ messages in thread
From: Bruno Haible @ 2023-11-20 18:12 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

Hi Florian,

Thanks for your test case [1]. Looks good to me too.

Please consider to commit also the second part of my patch. [2][3][4][5]

This change will not have an effect on your test case.

Bruno

[1] https://sourceware.org/pipermail/libc-alpha/2023-September/151330.html
[2] https://sourceware.org/pipermail/libc-alpha/2023-September/151462.html
[3] https://sourceware.org/pipermail/libc-alpha/2023-September/151463.html
[4] https://sourceware.org/pipermail/libc-alpha/2023-September/151467.html
[5] https://sourceware.org/pipermail/libc-alpha/2023-September/151521.html




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-20 18:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15  0:56 [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621) Bruno Haible
2023-09-04 13:34 ` Florian Weimer via Libc-alpha
2023-09-10 19:10   ` Bruno Haible
  -- strict thread matches above, loose matches on Subject: below --
2023-11-20 18:12 Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).