NetBSD Problem Report #57633
From www@netbsd.org Wed Sep 27 21:15:08 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 4DF401A9239
for <gnats-bugs@gnats.NetBSD.org>; Wed, 27 Sep 2023 21:15:08 +0000 (UTC)
Message-Id: <20230927211437.319481A9239@mollari.NetBSD.org>
Date: Wed, 27 Sep 2023 21:14:37 +0000 (UTC)
From: jlduran@gmail.com
Reply-To: jlduran@gmail.com
To: gnats-bugs@NetBSD.org
Subject: strfmon: Invalid output format
X-Send-Pr-Version: www-1.0
>Number: 57633
>Category: lib
>Synopsis: strfmon: Invalid output format
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 27 21:20:00 +0000 2023
>Closed-Date: Thu Sep 28 10:06:49 +0000 2023
>Last-Modified: Sat Oct 14 20:20:01 +0000 2023
>Originator: Jose Luis Duran
>Release: trunk
>Organization:
>Environment:
>Description:
While porting back some strfmon(3) fixes from NetBSD to FreeBSD, I accidentally stumbled upon this issue (see MWE).
Every other time, the format may be wrong:
Format: [%8n] [%8n]
Expected: [ $123.45] [ $123.45]
Actual: [ $123.45] [ $123.45]
>How-To-Repeat:
Take the following MWE:
#include <stdio.h>
#include <locale.h>
#include <monetary.h>
int
main(void)
{
char string[100];
if (setlocale(LC_MONETARY, "en_US.UTF-8") == NULL) {
fprintf(stderr, "Unable to setlocale().\n");
return (1);
}
strfmon(string, sizeof(string) - 1, "[%8n] [%8n]", 123.45, 123.45);
printf(" Format: [%%8n] [%%8n]\n");
printf("Expected: %s\n", "[ $123.45] [ $123.45]");
printf(" Actual: %s\n\n", string);
return (0);
}
>Fix:
The fix was to change where pad_size is zeroed. It should be zeroed on every iteration, not every other time:
https://github.com/freebsd/freebsd-src/commit/34f88528edba44b2703ba8c772bef077eca33dab
>Release-Note:
>Audit-Trail:
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57633 CVS commit: src/lib/libc/stdlib
Date: Thu, 28 Sep 2023 10:03:42 +0000
Module Name: src
Committed By: martin
Date: Thu Sep 28 10:03:41 UTC 2023
Modified Files:
src/lib/libc/stdlib: strfmon.c
Log Message:
Fix padding for formats with mutliple padded values.
PR lib/57633, fix from FreeBSD.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/stdlib/strfmon.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Thu, 28 Sep 2023 10:06:49 +0000
State-Changed-Why:
Fixed, thanks for the report!
XXX we should also import the test improvements
From: Jose Luis Duran <jlduran@gmail.com>
To: gnats-bugs@netbsd.org
Cc: lib-bug-people@netbsd.org, netbsd-bugs@netbsd.org, gnats-admin@netbsd.org,
martin@netbsd.org
Subject: Re: lib/57633 (strfmon: Invalid output format)
Date: Fri, 29 Sep 2023 03:27:20 -0300
--000000000000f5dd1706067984be
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Thu, Sep 28, 2023 at 7:06=E2=80=AFAM <martin@netbsd.org> wrote:
> Synopsis: strfmon: Invalid output format
>
> State-Changed-From-To: open->closed
> State-Changed-By: martin@NetBSD.org
> State-Changed-When: Thu, 28 Sep 2023 10:06:49 +0000
> State-Changed-Why:
> Fixed, thanks for the report!
> XXX we should also import the test improvements
>
Please, feel free to import all the other tests!:
https://github.com/freebsd/freebsd-src/blob/main/lib/libc/tests/stdlib/strf=
mon_test.c
There is one thing I did not implement, the sep_by_space default,
re-implemented in
https://github.com/NetBSD/src/commit/d4169749f0cf106c005ce9ca59a3628db02ec6=
8e
(explained
in https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_111.html)=
.
The localization was also implemented differently, mostly to follow the
original Darwin-initiated version (which uses NetBSD as its reference,
https://github.com/apple-oss-distributions/Libc/tree/main/stdlib/NetBSD).
Thank you!
--000000000000f5dd1706067984be
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr">On Thu, Sep 28, 2023 at 7:06=E2=80=AFAM &=
lt;<a href=3D"mailto:martin@netbsd.org">martin@netbsd.org</a>> wrote:<br=
></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;=
border-left-color:rgb(204,204,204);padding-left:1ex">Synopsis: strfmon: Inv=
alid output format<br>
<br>
State-Changed-From-To: open->closed<br>
State-Changed-By: martin@NetBSD.org<br>
State-Changed-When: Thu, 28 Sep 2023 10:06:49 +0000<br>
State-Changed-Why:<br>
Fixed, thanks for the report!<br>
XXX we should also import the test improvements<br></blockquote><div><br></=
div><div>Please, feel free to import all the other tests!:</div><div><div><=
br></div><div><a href=3D"https://github.com/freebsd/freebsd-src/blob/main/l=
ib/libc/tests/stdlib/strfmon_test.c">https://github.com/freebsd/freebsd-src=
/blob/main/lib/libc/tests/stdlib/strfmon_test.c</a></div><br class=3D"gmail=
-Apple-interchange-newline"></div><div>There is one thing I did not impleme=
nt, the sep_by_space default, re-implemented in <a href=3D"https://github.c=
om/NetBSD/src/commit/d4169749f0cf106c005ce9ca59a3628db02ec68e">https://gith=
ub.com/NetBSD/src/commit/d4169749f0cf106c005ce9ca59a3628db02ec68e</a>=C2=A0=
(explained in <a href=3D"https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/ht=
ml_node/libc_111.html">https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html=
_node/libc_111.html</a>).</div><div><br></div><div>The localization was als=
o implemented differently, mostly to follow the original Darwin-initiated v=
ersion (which uses NetBSD as its reference, <a href=3D"https://github.com/a=
pple-oss-distributions/Libc/tree/main/stdlib/NetBSD">https://github.com/app=
le-oss-distributions/Libc/tree/main/stdlib/NetBSD</a>).</div><div><br></div=
><div>Thank you!</div></div></div>
--000000000000f5dd1706067984be--
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57633 CVS commit: src/tests/lib/libc/locale
Date: Sat, 14 Oct 2023 16:19:31 -0400
Module Name: src
Committed By: christos
Date: Sat Oct 14 20:19:31 UTC 2023
Modified Files:
src/tests/lib/libc/locale: t_strfmon.c
Log Message:
PR/57633: Jose Luis Duran: Add strfmon tests from FreeBSD
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/locale/t_strfmon.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.