From nobody Mon Oct 14 08:44:43 2024 X-Original-To: dev-commits-src-all@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 4XRrQ32d60z5ZRQq; Mon, 14 Oct 2024 08:44:43 +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 4XRrQ327lzz4gF9; Mon, 14 Oct 2024 08:44:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728895483; 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=4uorrpNnGa0JgfjT2T58OR9j00ibmLShDA1sFeluapE=; b=dWLTG+pTmR9zQb6LLYlBlJfNPtl6NHPHKT9u5d3bv7FVdPXdEgQAVGGAIB5SFbnbazsGaO wOvQXeFuYF6p6IKYaQTzmG+4DJ3BDj+XgSM8bIaSHb9wFUkxvkNuqonhLWfzYXVjSiwrma gwPdTL5qkAy3/fHv9Q42XIxJrYAsQgZecoue+ThIMhy59s70cb+uZ5OCrjCdgavmLmQbsk mIi1g2Nx93Jz5NY1PizZucwb4o3Hq9/37xVxb+qcjk8EkMAHjiJYw7RHkeRnlC3AZOa8JQ IdF8XlQz8Lqzp825wHCAOaF1sRzUW12JWO9PeL1dZWmWzYV1I2xWv+Xc6Fyv1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728895483; 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=4uorrpNnGa0JgfjT2T58OR9j00ibmLShDA1sFeluapE=; b=XH6XyemccoM0glFl8AEnZlgecoOhL5hblR6po8EOAAufQlxuhKVQso6ZZhha5/vNHN8nMI z03vcJh65nSkx2hISbFByA5PH/RmoSuE/0YG8a03eRysZeWsB/XknJNrKQtc7DnP6Hz7fk zNoZG4RXC7SON3NY6VHV6yEtEtkcNw56dvKibkuZI9I4C41EzakyJMF3wTZF/xkWmddVPY mKodowMeeud57uPuUJi1HmnW3Y1coi/y0J1g5LQfoIkCUd6vbXjk68ooBm9/90Zl1tdg6P 7KVSUKvNtfJfCJDr9H1qfurtEIaPzZJYVwDQL4MQyfSDZrEypDTNwOJ9AfO5qQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728895483; a=rsa-sha256; cv=none; b=E16w0qXQKmuM5udVFCATlin/H74O5D17RPZA5m0QTi5/xeGcJKBEa4PpNEEY0Skf6CZQFh 6SD0NLkJ9RTOB0EML2nYVxhCZHwRGFJMFe3OqegZF4V7wiD2nF8wNV5QeDYtDuUaoc/g9Z V9o3w+s4RoLqjQBGRLYPowI9hsb5z7BBB5BO8dGni4tuLpibRy6cZ5u09MyFJDPKgJz0fz d1yd3f6H1Q98SOrP+467QyoCGeu3Y7j24hjn6muFnKqoxnCK0YK0zClHl+dVLqPLJehYO6 Uzdt5zllKo9jHrESpMqlG+3McXY7wFSkbfmyCnqiUCvmsp9HDtkp/XqK1aqOhg== 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 4XRrQ31kypzX5m; Mon, 14 Oct 2024 08:44:43 +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 49E8ihqe098749; Mon, 14 Oct 2024 08:44:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49E8ihGq098746; Mon, 14 Oct 2024 08:44:43 GMT (envelope-from git) Date: Mon, 14 Oct 2024 08:44:43 GMT Message-Id: <202410140844.49E8ihGq098746@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: bd490be57438 - main - w(1): fix libxo output being locale dependant List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: bd490be57438a82c22d1274bc58d51142b63f4a0 Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=bd490be57438a82c22d1274bc58d51142b63f4a0 commit bd490be57438a82c22d1274bc58d51142b63f4a0 Author: Baptiste Daroussin AuthorDate: 2024-10-14 07:37:46 +0000 Commit: Baptiste Daroussin CommitDate: 2024-10-14 08:43:38 +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 --- 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 47899d0b38e0..ac1df96077d3 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -135,14 +135,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;