bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: localename: Fix gettext test failures on mingw


From: Eli Zaretskii
Subject: Re: localename: Fix gettext test failures on mingw
Date: Sat, 24 Nov 2018 13:44:03 +0200

> From: Bruno Haible <address@hidden>
> Cc: address@hidden
> Date: Sat, 24 Nov 2018 12:20:21 +0100
> 
> > LC_MESSAGES means nothing on MS-Windows, so why does Gnulib need to
> > "fix" something that is not supported by the runtime library?
> 
> On native Windows, LC_MESSAGES is indeed not defined by the runtime
> library, but by Gnulib: it's defined in gnulib's <locale.h> replacement [1]
> and supported by gnulib's 'setlocale' module.
> 
> Why do we do this?
> 1. Because LC_MESSAGES is defined by POSIX, and one of Gnulib's goals is
>    to emulate POSIX APIs, as far as it makes sense.
> 2. Because LC_MESSAGES is essential for GNU gettext.

But LC_MESSAGES has additional impacts on systems that support it,
beyond message catalogs and gettext, doesn't it?  And GNU gettext
doesn't provide all those, does it?  If so, the make-believe support
for LC_MESSAGES in Gnulib might be dangerous, for exampl, if an
application bases some functionality on a test of its being defined.

> > Applications that want to be portable to MinGW and use LC_MESSAGES
> > should make sure the related code is either ifdef'ed out on MS-Windows
> > or does something reasonable "by other means".
> 
> ... where "other means" include using Gnulib's 'locale' and 'setlocale'
> modules.

Besides message catalogs, what does Gnulib support for LC_MESSAGES
entail?

> > Proliferating the illusion that LC_MESSAGES are supported on
> > MS-Windows is IMO not a good idea.
> 
> Why not? It's a good "illusion". It's an "illusion" that allows GNU gettext
> to work on native Windows.

We could have gettext work without LC_MESSAGES, by using native
Windows calls instead, couldn't we?

> > > 2018-11-23  Bruno Haible  <address@hidden>
> > > 
> > >   localename: Fix gettext test failures on mingw.
> > >   * lib/localename.c (gl_locale_name_posix): Convert the result of
> > >   gl_locale_name_environ to XPG syntax.
> > 
> > I no longer remember the details, but wouldn't such conversion get in
> > the way of calling 'setlocale'?  The MS-Windows runtime library
> > implementation doesn't understand the XPG syntax, AFAIR, so it will
> > generally fail.
> 
> Correct. Programs should not call 'setlocale' with the result of
> 'gl_locale_name_posix'. This follows from the documentation of
> 'gl_locale_name_posix' in localename.h.

If such calls are possible (e.g., for those who are not ardent enough
in reading the documentation), perhaps they should be caught by Gnulib
and flagged as errors, if they aren't already?

> Programs that call 'setlocale' and want to consider locale names given
> by environment variables usually do so by calling
>    setlocale (LC_something, "");

Which doesn't work as expected with Windows' 'setlocale', of course.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]