bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: Ingo Schwarze <schwarze@usta.de>
Cc: bug-gnulib@gnu.org
Subject: Re: OpenBSD locale system
Date: Sun, 16 Dec 2018 20:01:04 +0100	[thread overview]
Message-ID: <45443746.orUszaOq50@omega> (raw)
In-Reply-To: <20181216180407.GF90457@athene.usta.de>

Hi Ingo,

> The OpenBSD C library intentionally doesn't implement any other
> locale(1) categories except LC_CTYPE because many here regard the
> other categories as overengineering and as detrimental to system
> security

I partially agree with this, regarding specific categories, such as

  - LC_MONETARY: The main API function for this category, strfmon(),
    is defined in such a way that, if implemented correctly, it
    produces misleading results.
    <http://austingroupbugs.net/view.php?id=1199>

  - LC_PAPER: Any software which wants to print something should
    better ask the attached printer, rather than make assumptions
    about the printer device based on the locale.

However, locale categories such as LC_NUMERIC and LC_MESSAGES
are useful when you assume that your software does have end-users
that are not sysadmins.

For Android, the choice to use dumbed-down locales in libc was made
because 99% of the software visible to the end user is written in
another programming language (Java) that comes with its own, elaborate,
locale system. The remaining 1% of visible only to developers via 'adb',
and thus needs no locales.

Regarding OpenBSD, the uselocale support is useful for adding a checkmark
to the checkbox "We support POSIX locale_t API", but is not useful, for
example, to have a multithreaded web server honor the Accept-Language
settings given by a browser user, other than by reimplementing all
needed locale-dependent behaviour.

> POSIX does not require that "de_DE.UTF-8" and
> "fr_FR.UTF-8" must be different locales, or that they behave
> differently from each other in any way.

Here you need to distinguish
  - locale-dependent behaviour defined by POSIX functions and
  - locale-dependent behaviour defined by the application.

In setlocale.c you made this distinction, as witnessed by the comment in
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/locale/setlocale.c?annotate=1.29
lines 72..75.

Why not also for the per-thread locales? By implementing the FreeBSD
querylocale API (the equivalent of setlocale(category,NULL) for locale_t
objects), you would make it possible for applications to pull out
German versus French messages, depending whether the per-thread locale
is "de_DE.UTF-8" or "fr_FR.UTF-8".

> Not sure what the conclusion should be for gnulib - it probably
> depends on what gnulib suggests the application build system should
> do when newlocale(3) is not available

Exactly. Gnulib now treats such a platform like one which does not
have locale_t, uselocale(), newlocale().

Bruno



  reply	other threads:[~2018-12-16 19:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16  6:12 localename: Fix test failure on OpenBSD >= 6.2 Bruno Haible
2018-12-16 18:04 ` Ingo Schwarze
2018-12-16 19:01   ` Bruno Haible [this message]
2018-12-16 23:16     ` OpenBSD locale system Ingo Schwarze
2018-12-20 20:55       ` Bruno Haible
2018-12-21  0:37         ` Ingo Schwarze

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=45443746.orUszaOq50@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=schwarze@usta.de \
    /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).