Bug 237752 - LC_TIME keywords violate POSIX
Summary: LC_TIME keywords violate POSIX
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Yuri Pankov
URL:
Keywords: needs-patch, needs-qa, standards
Depends on:
Blocks:
 
Reported: 2019-05-05 00:30 UTC by AJ Jordan
Modified: 2020-03-09 19:19 UTC (History)
2 users (show)

See Also:
yuripv: mfc-stable12+
yuripv: mfc-stable11-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description AJ Jordan 2019-05-05 00:30:34 UTC
IEEE Std 1003.1-2004 ("POSIX.1")[1] section 7.3.5.1 states:

> In a locale definition, the following mandatory keywords shall be recognized:
>
> [...]
>
> [abmon] Define the abbreviated month names, corresponding to the %b conversion specification. The operand shall consist of twelve semicolon-separated strings, each  surrounded by double-quotes. The first string shall be the abbreviated name of the first month of the year (January), the  second the abbreviated name of the second month, and so on.

However, it turns out that FreeBSD does not conform to this behavior. `locale -k abmon` returns "Unknown keyword: `abmon'". On the other hand, `locale -k abmon_1` _does_ return "Jan", and so on and so forth.

It seems to me that this is a bug and that the locale keywords need to be changed if FreeBSD wants to conform to POSIX. Note that locale(1) claims to be conformant to POSIX.1.

I have confirmed this bug both on FreeBSD 11.2 and on FreeBSD 12.

(For some context, I'm the maintainer of filter-other-days[2] and in the course of trying to figure out how to do localization support, I started using `locale -k` to extract this information from the system.)

 [1]: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1309815
 [2]: https://github.com/strugee/filter-other-days
Comment 1 commit-hook freebsd_committer freebsd_triage 2019-09-10 15:10:27 UTC
A commit references this bug:

Author: yuripv
Date: Tue Sep 10 15:09:48 UTC 2019
New revision: 352138
URL: https://svnweb.freebsd.org/changeset/base/352138

Log:
  locale: handle day, abday, mon, abmon, am_pm keywords

  All of these are defined as mandatory by POSIX.

  While here, mark all non-standard ones as FreeBSD-only as
  other systems (at least, GNU/Linux and illumos) do not handle
  them, so we should not encourage their use.

  PR:		237752
  Reviewed by:	bapt
  Differential Revision:	https://reviews.freebsd.org/D21490

Changes:
  head/etc/mtree/BSD.tests.dist
  head/usr.bin/locale/Makefile
  head/usr.bin/locale/locale.c
  head/usr.bin/locale/tests/
  head/usr.bin/locale/tests/Makefile
  head/usr.bin/locale/tests/k_flag_posix_messages.out
  head/usr.bin/locale/tests/k_flag_posix_monetary.out
  head/usr.bin/locale/tests/k_flag_posix_numeric.out
  head/usr.bin/locale/tests/k_flag_posix_time.out
  head/usr.bin/locale/tests/locale_test.sh
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-09-11 15:40:22 UTC
A commit references this bug:

Author: yuripv
Date: Wed Sep 11 15:39:30 UTC 2019
New revision: 352214
URL: https://svnweb.freebsd.org/changeset/base/352214

Log:
  locale: more output fixes

  - make abday, day, abmon, mon, am_pm output quoting match linux
  - workaround localeconv() issue for mon_grouping and grouping (PR172215)
  - for other values not available in default locale, output -1 instead of
    127 (CHAR_MAX) as returned by localeconv()

  With these changes, output of `locale` and `locale -k` for all keywords
  specified by POSIX exactly matches the linux one.

  PR:		237752
  Reviewed by:	bapt
  Differential Revision:	https://reviews.freebsd.org/D21599

Changes:
  head/usr.bin/locale/locale.c
  head/usr.bin/locale/tests/Makefile
  head/usr.bin/locale/tests/k_flag_posix_monetary.out
  head/usr.bin/locale/tests/k_flag_posix_numeric.out
  head/usr.bin/locale/tests/k_flag_posix_time.out
  head/usr.bin/locale/tests/locale_test.sh
  head/usr.bin/locale/tests/no_flags_posix_messages.out
  head/usr.bin/locale/tests/no_flags_posix_monetary.out
  head/usr.bin/locale/tests/no_flags_posix_numeric.out
  head/usr.bin/locale/tests/no_flags_posix_time.out
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-09-16 16:18:20 UTC
A commit references this bug:

Author: yuripv
Date: Mon Sep 16 16:17:32 UTC 2019
New revision: 352416
URL: https://svnweb.freebsd.org/changeset/base/352416

Log:
  MFC r352138, r352214, r352216:

  locale: handle day, abday, mon, abmon, am_pm keywords

  All of these are defined as mandatory by POSIX.

  While here, mark all non-standard ones as FreeBSD-only as
  other systems (at least, GNU/Linux and illumos) do not handle
  them, so we should not encourage their use.

  - make abday, day, abmon, mon, am_pm output quoting match linux
  - workaround localeconv() issue for mon_grouping and grouping (PR172215)
  - for other values not available in default locale, output -1 instead of
    127 (CHAR_MAX) as returned by localeconv()

  PR:		237752

Changes:
_U  stable/12/
  stable/12/etc/mtree/BSD.tests.dist
  stable/12/usr.bin/locale/Makefile
  stable/12/usr.bin/locale/locale.c
  stable/12/usr.bin/locale/tests/
  stable/12/usr.bin/locale/tests/Makefile
  stable/12/usr.bin/locale/tests/k_flag_posix_monetary.out
  stable/12/usr.bin/locale/tests/k_flag_posix_numeric.out
  stable/12/usr.bin/locale/tests/k_flag_posix_time.out
  stable/12/usr.bin/locale/tests/locale_test.sh
  stable/12/usr.bin/locale/tests/no_flags_posix_messages.out
  stable/12/usr.bin/locale/tests/no_flags_posix_monetary.out
  stable/12/usr.bin/locale/tests/no_flags_posix_numeric.out
  stable/12/usr.bin/locale/tests/no_flags_posix_time.out