public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Thomas Wolff <towo@towo.net>
To: cygwin@cygwin.com
Subject: Re: newlocale: Linux incompatibility
Date: Thu, 23 Mar 2023 21:09:57 +0100	[thread overview]
Message-ID: <a016d60a-b661-7aca-681d-8f501d54308a@towo.net> (raw)
In-Reply-To: <bd7ebebc-cf90-d509-ef15-11d702a6126c@cornell.edu>


Am 23.03.2023 um 20:48 schrieb Ken Brown via Cygwin:
> I'm reporting this here rather than the newlib list because the 
> behavior is compatible with Posix but not Linux, so I think it's a 
> Cygwin issue.
>
> Consider the following test case:
>
> $ cat locale_test.c
> #include <stdio.h>
> #include <locale.h>
>
> int main ()
> {
>   const char *locale = "en_DE.UTF-8";
>   locale_t loc = newlocale (LC_COLLATE_MASK | LC_CTYPE_MASK, locale, 0);
>   if (!loc)
>     perror ("newlocale");
>   else
>     printf ("newlocale succeeded on invalid locale %s\n", locale);
> }
>
> $ gcc -o locale_test locale_test.c
>
> $ ./locale_test.exe
> newlocale succeeded on invalid locale en_DE.UTF-8
>
> On Linux, the newlocale call fails with ENOENT, as is documented on 
> the man page.  Posix doesn't say what should happen on an invalid 
> locale, so this is not, strictly speaking, a bug.
So the question is what is an invalid locale. In Linux, locales are only 
valid if explicitly listed somewhere.
This strict behaviour may be a problem. A much better approach is to 
allow any combination of known language_REGIOIN tags with encoding 
indications, to be much more flexible and dynamic.
So if such combinations are considered legal, as in cygwin, this is not 
a bug.

>
> Ken
>
> P.S. I noticed this because of a failing Emacs test.  No one else has 
> reported this test failure, so it seems that newlocale fails on an 
> invalid locale on all platforms supported by Emacs other than Cygwin.

  reply	other threads:[~2023-03-23 20:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 19:48 Ken Brown
2023-03-23 20:09 ` Thomas Wolff [this message]
2023-03-23 21:14 ` Corinna Vinschen
2023-03-24 12:18   ` Corinna Vinschen
2023-03-24 13:57     ` Ken Brown
2023-03-24 14:44       ` Corinna Vinschen
2023-03-24 22:49     ` Brian Inglis
2023-03-25 11:49       ` Corinna Vinschen
2023-03-25 19:03         ` Brian Inglis
2023-03-25 21:19           ` Corinna Vinschen
2023-03-25 21:26           ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a016d60a-b661-7aca-681d-8f501d54308a@towo.net \
    --to=towo@towo.net \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).