On 9/8/2011 5:44 PM, Bruno Haible wrote:
> Find below a patch which ought to fix this. But it has upsides and downsides.
> The upside: It treats LC_ALL, LC_$category, LANG consistently, like POSIX
> wants it.

Consistently, yes.  Correctly...no.  You said earlier:

"Users who want to have a German Windows but a non-internationalized
Cygwin can set LANG=C or LC_ALL=C - exactly like POSIX specifies."

With your patch, this is /technically/ true: if I set LANG=C exactly,
without the UTF-8 charset specifier, then yes -- I'll get english cygwin
with german windows.  But, your patch explicitly ignores "C.UTF-8" -- so
if I deliberately select the "C" locale with the "UTF-8" charset, I will
get...the german locale.

That can't be right.

Now, the reason you're ignoring "C.UTF-8" is because you want to
override cygwin's default locale setting -- which is implemented in two
ways: #1, cygwin's internal code for 'setlocale(LC_blah, "")' returns
that value, and #2, some older versions of the base-files startup
scripts (/etc/profile, /etc/skel/.*, and the like) used to set LANG or
LC_* IIRC.  However, they no longer do so.

Now, long term, I think what we will see is that some part of your
suggestions here:
http://cygwin.com/ml/cygwin/2011-09/msg00084.html
will eventually be implemented in cygwin.  When that happens, libintl
will have to change again.

Until then, what?

My suggestion for the "interim" libintl behavior is this:

If /no/ relevant env vars are set
then
        if setlocale(LC_*, "") returns C.UTF-8
        # which we know is the /current/ cygwin default locale
        then
                query Win32 API for "real" default locale
        else
                use what setlocale returns
else
        use the env var value; don't ignore 'C.UTF-8'
        # if I have explicitly set LANG=C.UTF-8 then I must really
        # really want the "C" locale, not en_US or de.

> The downside: It makes libintl_setlocale's behaviour diverge a little more 
> from
> Cygwin's setlocale behaviour.
> Should I commit the patch or not?

I don't think so.  What do you think about the algorithm above, at least
for now, until cygwin's internal behavior is improved -- I tend to agree
with Eric:
http://cygwin.com/ml/cygwin/2011-09/msg00061.html
"I'd argue that if none of LC_* or LANG are set, then
setlocale(LC_BLA,"") should indeed return the system default, rather
than being hard-coded to C. "
and
"I also agree with this sentiment - if setlocale(LC_BLA, "") is not
returning sane results (that is, if there is a system default, but
cygwin is not honoring those defaults), then the bug should be fixed in
cygwin, not libintl."

--
Chuck

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to