NetBSD Problem Report #56967

From www@netbsd.org  Wed Aug 17 02:56:45 2022
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 4AC9D1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 17 Aug 2022 02:56:45 +0000 (UTC)
Message-Id: <20220817025644.2CD671A923A@mollari.NetBSD.org>
Date: Wed, 17 Aug 2022 02:56:44 +0000 (UTC)
From: J.Zaitseff@zap.org.au
Reply-To: J.Zaitseff@zap.org.au
To: gnats-bugs@NetBSD.org
Subject: Buggy implementation of strfmon()
X-Send-Pr-Version: www-1.0

>Number:         56967
>Category:       lib
>Synopsis:       Buggy implementation of strfmon()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 17 03:00:00 +0000 2022
>Last-Modified:  Wed Aug 17 09:35:01 +0000 2022
>Originator:     John Zaitseff
>Release:        9.3
>Organization:
The ZAP Group Australia
>Environment:
NetBSD vega-netbsd.home.zap.org.au 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
The implementation of strfmon() on NetBSD is unfortunately very buggy when grouping characters are involved.  The implementation used in FreeBSD seems to be free of these problems.
>How-To-Repeat:
Run the following on a NetBSD installation:

  $ wget -N https://www.zap.org.au/software/utils/scripts/strfmon.c
  $ cc -o strfmon strfmon.c

  $ ./strfmon 1234.56 en_US.UTF-8

The output on NetBSD is garbled:

  $1,234.5,234.56
  USD1,234.5,234.56

The output on FreeBSD is correct:

  $1,234.56
  USD 1,234.56

Furthermore, non-ASCII characters for the grouping character cause additional problems (truncated UTF-8 strings):

  $ ./strfmon 1234,56 ru_RU.UTF-8

gives, on NetBSD:

  1&#65533;234,5&#65533;234,56 &#1088;&#1091;&#1073;.
  1&#65533;234,5&#65533;234,56 RUB

whereas FreeBSD gives the correct output:

  1 234,56 &#8381;
  1 234,56 RUB 

Note also that the correct local currency symbol for ru_RU.UTF-8 is "&#8381;", not "&#1088;&#1091;&#1073;." -- a separate bug in the locale data.
>Fix:
If possible, copy the latest version of <monetary.h>, strfmon() and strfmon_l() from FreeBSD.

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56967 CVS commit: src/lib/libc/stdlib
Date: Wed, 17 Aug 2022 05:32:56 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Aug 17 09:32:56 UTC 2022

 Modified Files:
 	src/lib/libc/stdlib: strfmon.c

 Log Message:
 PR/56967: John Zaitseff: Reduce diff with FreeBSD, fixes various bugs.


 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.17 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.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.