From 0ca58ca1513c1c73dbd2b40898f559eba5478651 Mon Sep 17 00:00:00 2001 From: Eugene Grosbein Date: Sat, 24 Aug 2019 15:50:13 +0000 Subject: [PATCH] last(1): correction after r351413 Make that change no-op for C/POSIX locale just like for UTF-8 that it superset of US-ASCII. MFC after: 2 weeks X-MFC-With: r351413 --- usr.bin/last/last.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c index 357954e58054..16acc6e15693 100644 --- a/usr.bin/last/last.c +++ b/usr.bin/last/last.c @@ -92,8 +92,8 @@ static const char *crmsg; /* cause of last reboot */ static time_t currentout; /* current logout value */ static long maxrec; /* records to display */ static const char *file = NULL; /* utx.log file */ +static int noctfix = 0; /* locale is C or UTF-8 */ static int sflag = 0; /* show delta in seconds */ -static int utf8flag; /* current locale is UTF-8 */ static int width = 5; /* show seconds in delta */ static int yflag; /* show year */ static int d_first; @@ -120,7 +120,7 @@ ctf(const char *fmt) { const char *src, *end; char *dst; - if (utf8flag) + if (noctfix) return (fmt); end = buf + sizeof(buf); @@ -158,7 +158,9 @@ main(int argc, char *argv[]) d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); (void) setlocale(LC_CTYPE, ""); - utf8flag = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0); + p = nl_langinfo(CODESET); + if (strcmp (p, "UTF-8") == 0 || strcmp (p, "US-ASCII") == 0) + noctfix = 1; argc = xo_parse_args(argc, argv); if (argc < 0)