Page MenuHomeFreeBSD

uptime: Avoid overriding more locale categories than necessary
Needs RevisionPublic

Authored by markj on Nov 2 2025, 5:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jan 10, 12:35 AM
Unknown Object (File)
Thu, Jan 1, 4:05 PM
Unknown Object (File)
Wed, Dec 31, 3:39 AM
Unknown Object (File)
Dec 12 2025, 3:44 PM
Unknown Object (File)
Dec 10 2025, 11:42 PM
Unknown Object (File)
Dec 8 2025, 3:31 AM
Unknown Object (File)
Dec 5 2025, 5:24 AM
Unknown Object (File)
Dec 1 2025, 7:05 AM
Subscribers

Details

Reviewers
bapt
des
Summary

uptime(1) prints floating point numbers to represent the current load
averages. When emitting JSON, these numbers cannot use a comma as the
decimal separator. Commit bd490be57438 fixed a bug along these lines,
but in so doing it overrides all locale categories. As a result, we
emit 12h time in non-text mode, but for that field we should probably
just respect the user's configured locale.

PR: 290328
Fixes: bd490be57438 ("w(1): fix libxo output being locale dependant")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68358
Build 65241: arc lint + arc unit

Event Timeline

markj requested review of this revision.Nov 2 2025, 5:07 PM

I don't think this is the correct solution either. For one, it is a local fix for a problem that affects all libxo consumers. For another, it will use the wrong decimal separators when emitting HTML (which should be localized, but won't if this patch is committed). I think libxo should be modified to always use the C locale when formatting numbers in json output, and bd490be57438 should be reverted.

In D53539#1222315, @des wrote:

I don't think this is the correct solution either. For one, it is a local fix for a problem that affects all libxo consumers. For another, it will use the wrong decimal separators when emitting HTML (which should be localized, but won't if this patch is committed). I think libxo should be modified to always use the C locale when formatting numbers in json output, and bd490be57438 should be reverted.

This all makes sense. @phil do you have any comments on the libxo side of things? Does libxo have a particular stance on this kind of problem?

In D53539#1222315, @des wrote:

I don't think this is the correct solution either. For one, it is a local fix for a problem that affects all libxo consumers. For another, it will use the wrong decimal separators when emitting HTML (which should be localized, but won't if this patch is committed). I think libxo should be modified to always use the C locale when formatting numbers in json output, and bd490be57438 should be reverted.

I agree, we should fix this in libxo itself, libxo is broken in many places regading locales and encodings

This comment was removed by bapt.
This revision is now accepted and ready to land.Nov 27 2025, 9:02 PM
bapt requested changes to this revision.Nov 27 2025, 9:38 PM
This revision now requires changes to proceed.Nov 27 2025, 9:38 PM