mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-02 10:42:45 +00:00
w(1): fix libxo output being locale dependant
by being locale dependant the json export is invalid in locales where
the separator for float is a comma.
The Json and the XML are invalid for login-time when days contains
contains characters which are not unicode.
Forcing locale to be C, makes this json and xml output valid and also
identical accross locales, so reliable for parsers
PR: 276304
Reported by: Vedran Miletic <vedran@miletic.net>
(cherry picked from commit bd490be574
)
This commit is contained in:
parent
acd0487a7f
commit
6c1a174e4c
@ -144,14 +144,16 @@ main(int argc, char *argv[])
|
||||
char buf[MAXHOSTNAMELEN], fn[MAXHOSTNAMELEN];
|
||||
char *dot;
|
||||
|
||||
(void)setlocale(LC_ALL, "");
|
||||
use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
|
||||
use_comma = (*nl_langinfo(RADIXCHAR) != ',');
|
||||
|
||||
argc = xo_parse_args(argc, argv);
|
||||
if (argc < 0)
|
||||
exit(1);
|
||||
|
||||
if (xo_get_style(NULL) == XO_STYLE_TEXT) {
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
|
||||
use_comma = (*nl_langinfo(RADIXCHAR) != ',');
|
||||
/* Are we w(1) or uptime(1)? */
|
||||
if (strcmp(basename(argv[0]), "uptime") == 0) {
|
||||
wcmd = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user