Hi Bruno,

Patch looks good, thanks!

Bruno Haible via Gnulib discussion list <[email protected]> writes:

> Collin: With this patch, the three coreutils tests now fail on OpenBSD the 
> same
> way as they fail on macOS 
> <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79118>.
> This means, you can use gdb on OpenBSD to debug it.

I'll just respond here since it is mostly a Gnulib issue (just the
behavior affects Coreutils).

Anyways, I'm going through gdb now on OpenBSD and think I found the
issue.

gl_locale_name_posix_unsafe returns NULL on OpenBSD and MacOS (among
others).  Here the comment explains why:

    /* XPG3 defines the result of 'setlocale (category, NULL)' as:
       "Directs 'setlocale()' to query 'category' and return the current
        setting of 'local'."
       [...]
       We cannot use it on
      - macOS, Cygwin (because these systems have a facility for customizing the
        default locale, and setlocale (category, NULL) ignores it and merely
        returns "C" or "C.UTF-8"),
      - OpenBSD (because on OpenBSD ≤ 6.1, LC_ALL does not set the LC_NUMERIC,
        LC_TIME, LC_COLLATE, LC_MONETARY categories).
       [...]

Once we receive NULL from there, we call gl_locale_name_environ from
gl_locale_name_unsafe. This part of the function body of
gl_locale_name_environ should make it clear:

    /* Setting of LC_ALL overrides all other.  */
    retval = getenv ("LC_ALL");
    if (retval != NULL && retval[0] != '\0')
      return retval;
    /* Next comes the name of the desired category.  */
    retval = getenv (categoryname);
    if (retval != NULL && retval[0] != '\0')
      return retval;

So, despite setting 'setlocale (LC_TIME, "C")' when doing
'LC_ALL=am_ET.UTF-8 date --iso-8601=hours' we will receive the value
from LC_ALL in the environment.

Haven't thought of a just yet...

Collin

Reply via email to