Page MenuHomeFreeBSD

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

Authored by yuripv on Sep 2 2019, 3:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 12, 11:07 PM
Unknown Object (File)
Wed, Dec 11, 5:54 AM
Unknown Object (File)
Nov 4 2024, 12:28 PM
Unknown Object (File)
Oct 23 2024, 12:00 AM
Unknown Object (File)
Oct 23 2024, 12:00 AM
Unknown Object (File)
Oct 23 2024, 12:00 AM
Unknown Object (File)
Oct 22 2024, 11:59 PM
Unknown Object (File)
Oct 22 2024, 11:41 PM
Subscribers

Details

Summary

As reported in PR237752, our locale utility doesn't handle the day, abday, mon, abmon keywords, and that seems to violate POSIX.

Also handle am_pm, which is missing as well.

Test Plan

Simply running locale -k, locale -k day abday mon abmon for the moment. If this implementation looks sane enough, I'll add the test cases for locale(1).

$ LC_ALL=en_US.UTF-8 locale -k day abday mon abmon
day="Sunday";"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday"
abday="Sun";"Mon";"Tue";"Wed";"Thu";"Fri";"Sat"
mon="January";"February";"March";"April";"May";"June";"July";"August";"September";"October";"November";"December"
abmon="Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"
$ LC_ALL=ru_RU.UTF-8 locale -k day abday mon abmon
day="воскресенье";"понедельник";"вторник";"среда";"четверг";"пятница";"суббота"
abday="вс";"пн";"вт";"ср";"чт";"пт";"сб"
mon="января";"февраля";"марта";"апреля";"мая";"июня";"июля";"августа";"сентября";"октября";"ноября";"декабря"
abmon="янв.";"февр.";"марта";"апр.";"мая";"июня";"июля";"авг.";"сент.";"окт.";"нояб.";"дек."

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This looks sane to me!

usr.bin/locale/locale.c
860

that if is useless, free deals properly with NULL

This revision is now accepted and ready to land.Sep 3 2019, 8:41 AM
yuripv added inline comments.
usr.bin/locale/locale.c
860

Yes, but I'm NOT checking kwval for NULL, rather if we did allocate the memory for kwval -- otherwise we'll try to free something we didn't allocate.

yuripv retitled this revision from locale: handle day, abday, mon, abmon keywords to locale: handle day, abday, mon, abmon, am_pm keywords.
yuripv edited the summary of this revision. (Show Details)
  • use sbuf functions
  • also handle am_pm
  • mark all keywords not specified by POSIX (e.g. abmon_1 through abmon_12, am_str, pm_str, ...) as local additions as other systems (at least Linux and Solaris) do not handle them
  • add tests
This revision now requires review to proceed.Sep 10 2019, 10:45 AM
This revision is now accepted and ready to land.Sep 10 2019, 1:13 PM