> Date: Wed, 17 Aug 2022 11:30:04 +0200 > From: Ingo Schwarze <schwa...@usta.de> > > QUESTION TO PORTERS: > Would providing <monetary.h>, strfmon(3), and strfmon_l(3) > in our libc make porters' lives easier, or are these interfaces > used so rarely in real-world programs that it does not matter?
Note that these interfaces have been made part of POSIX proper some time ago: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/monetary.h.html Given that we aim to be POSIX-compatible, we probably should add a (minimal) implementation of these functions. > Hi John, > > John Zaitseff wrote on Wed, Aug 17, 2022 at 12:29:20PM +1000: > > > Apologies in advance if I am sending this to the wrong list... > > Since strfmon(3) is a useless API and this discussion is exclusively > about compatibility, asking on ports@ would have been better, > more accurately targetting the intended audience, but bugs@ is not > outright wrong either because OpenBSD aims to support POSIX unless > there are specific reasons to not support something, and <monetary.h>, > strfmon(3), and strfmon_l(3) are specified by POSIX. > > However, strfmon(3) is even more ill-designed than other POSIX > locale-related functions: > > - strfmon(3) is designed to interpret the same floating-point > number differently depending on the user's locale(1). > But whether a user owns 42.00 Turkish Lira or 42.00 Pound Sterling > is *not* a matter of personally preferred output conventions. > Consequently, i can hardly imagine any situation where using > strfmon*(3) might make any sense. Using this functions will > usually misrepresent the currency owned by the user, causing > wrong output. > > - Arguably, you can use the "!" flag to suppress the misfeature > of having the currency symbol depend on the user's locale, > but then, strfmon(3) mostly duplicates functionality already > provided by printf(3) with a very small number of gratuitious > variations, so i see no conceivable motivation for using the > interface with "!" either. > > For those reasons, i think using <monetary.h> is a terrible idea in the > first place and we should not add it to our libc if we can avoid it. > > That said, even if an API is abominable (like this one), > support can sometimes be considered *if* it is used by enough > ports(7) that its absense causes pain for OpenBSD porters. > The only condition in such cases is that a dummy version can be > provided that poses no security risks. I do not doubt that > would be possible for strfmon(3) and strfmon_l(3). > > > A few years ago, Frederic Cambus packaged Star Traders, my simple > > game of interstellar trading, for OpenBSD ("trader"). In doing so, > > he bundled FreeBSD's version of strfmon() as that function is > > required by my program. > > My personal recommendation would be to stop using the bad function > in your program. > > > Longer term, however, could OpenBSD include <monetary.h>, strfmon() > > and strfmon_l(), possibly by copying these from the latest version > > of FreeBSD. > > Well, as usual, the FreeBSD version of locale functions is seriously > bloated, so if porters tell me that lack of the function causes > pain for them, i would radically strip it down before commit. > > Yours, > Ingo > >