NetBSD Problem Report #56967

From  Wed Aug 17 02:56:45 2022
Return-Path: <>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 4AC9D1A921F
	for <>; Wed, 17 Aug 2022 02:56:45 +0000 (UTC)
Message-Id: <>
Date: Wed, 17 Aug 2022 02:56:44 +0000 (UTC)
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
The ZAP Group Australia
NetBSD 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022 amd64
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.
Run the following on a NetBSD installation:

  $ wget -N
  $ cc -o strfmon strfmon.c

  $ ./strfmon 1234.56 en_US.UTF-8

The output on NetBSD is garbled:


The output on FreeBSD is correct:

  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.
If possible, copy the latest version of <monetary.h>, strfmon() and strfmon_l() from FreeBSD.

From: "Christos Zoulas" <>
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:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.