From nobody Wed Oct 23 07:25:57 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XYLF16lSJz5ZxCP; Wed, 23 Oct 2024 07:25:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XYLF14FQyz49CG; Wed, 23 Oct 2024 07:25:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729668357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wYueOi4dTv7UF1B1HKy+xsSmInnuUaZn5swKPb0xW44=; b=KaTZ/fNqrXiBQVpRQ5+En9M3EX1D6Ewu2B7FqhKT9MjlMR1z5t5z9ZE58sJEybk1C6pZ9f 70459d+6xlAg1cwgLV6ie6KGNVA46oD0MCbdwmbUFR3jRbFr42N+FAZWHyTIl4e/wE08E3 KQHJeZxDfrMm4vmlJbRUahRhfZPstYN5f5FI1NmMBhpjKvRzX0xyV/39Yt3PFmxUKphAP1 hpX2aZIDo1ZRDBf3AjFypwyyhbUUilll/7M3i3O2gLYZQr8bMoRIiQ4FGYmUnlKqGoY54S IVVKlBUEvPe8p+EJze3xo3roYVBlRW5dmeeLeS3RGK6MD1wBJ1gwFR0gMhf22g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729668357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wYueOi4dTv7UF1B1HKy+xsSmInnuUaZn5swKPb0xW44=; b=h7LKM9MqYwpSLNZzjVs8GhjGQ984zTmHZkxhP/FRy9RSSOQYFhmHI5ofmT7TMMl8NoP66A 8qpjgZMg3kPlLCd7VJARsOheSeoi0wHFLD8KhWgKCFa7MrjjnI2eY/3Q5L2BRUZqJ4J2UF 5fEh8FUoiexKRbblTw2/DC+x0Nm32bTN97WZ9O1HMyBrIaBCVthc77g4NVU+sTKpT6pbmz KjzhoRdo+Hue0VIlad+R/KXs0Twz5baiCctgKHhQme1PdYgM8LfkNLtwS2icDhSz5aafmb CyA3SmN//r2Ktv3wwHV+5AKifI1XeMcw1GMwRL9Fz4nSUCO8l8Tv/6h/ZWwG/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729668357; a=rsa-sha256; cv=none; b=jvdvzc3SC0PVrG62KC22z5TE8HYlzWZuP4ZOsoBWMCj+pMxIV5XWM9aaEV+hbe4LuuMlux xPydELV9z9N0ucCBSZEO9lo35Tm7nYEwXkF+QNPT7V7nFPXI9uqEXUJfPn7/rPYHDF66hJ HGi8PoHusZDaN6iYaIw1MHh8VWt2ClU/CmMcg9SpACbbBge2QsZNOCkEPMXRubzPAtKBWF WVr5u9KWxTKLA+xIQrIG/DN71Me6/uPLSs2o0VAM3KZPCxTpbtMfeNn++yCa+KgHPxCXwm Rj2p11HWCaRLsbHCGPSb9gjgjLLAYzz1A9M0Gr23ITTSLzl8Ebd5Df5uplmkTA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XYLF13sTCzpHQ; Wed, 23 Oct 2024 07:25:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49N7PvtJ037183; Wed, 23 Oct 2024 07:25:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49N7PvwJ037180; Wed, 23 Oct 2024 07:25:57 GMT (envelope-from git) Date: Wed, 23 Oct 2024 07:25:57 GMT Message-Id: <202410230725.49N7PvwJ037180@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 6c1a174e4c0a - stable/14 - w(1): fix libxo output being locale dependant List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 6c1a174e4c0a01a40aa1c06dfc07a37a31cabe33 Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=6c1a174e4c0a01a40aa1c06dfc07a37a31cabe33 commit 6c1a174e4c0a01a40aa1c06dfc07a37a31cabe33 Author: Baptiste Daroussin AuthorDate: 2024-10-14 07:37:46 +0000 Commit: Baptiste Daroussin CommitDate: 2024-10-23 07:25:50 +0000 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 (cherry picked from commit bd490be57438a82c22d1274bc58d51142b63f4a0) --- usr.bin/w/w.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 93f17b0f4ae3..69ff8c33cbbf 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -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;