NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/56967: Buggy implementation of strfmon()
>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
>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@localhost:/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�234,5�234,56 руб.
1�234,5�234,56 RUB
whereas FreeBSD gives the correct output:
1 234,56 ₽
1 234,56 RUB
Note also that the correct local currency symbol for ru_RU.UTF-8 is "₽", not "руб." -- a separate bug in the locale data.
>Fix:
If possible, copy the latest version of <monetary.h>, strfmon() and strfmon_l() from FreeBSD.
Home |
Main Index |
Thread Index |
Old Index