GNU bug report logs -
#69951
coreutils: printf formatting bug for nb_NO and nn_NO locales
Previous Next
Reported by: Thomas Dreibholz <dreibh <at> simula.no>
Date: Fri, 22 Mar 2024 22:11:01 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #18 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
indeed, the issue seems to be in libc. I can reproduce the problem with
a simple C program:
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(int argc, char** argv)
{
setlocale (LC_ALL, "");
struct lconv* loc = localeconv();
printf("Thousands Separator: <%s>\n", loc->thousands_sep);
for(int i = 1; i <argc; i++) {
int n = atoi(argv[i]);
double f = atof(argv[i]);
printf("double <%'10.0f>\tint <%'10d>\n", f, n);
}
return 0;
}
Output with LC_NUMERIC=nb_NO.UTF-8:
Thousands Separator: < >
double < 1> int < 1>
double < 10> int < 10>
double < 100> int < 100>
double < 1 000> int < 1 000>
double < 10 000> int < 10 000>
double < 100 000> int < 100 000>
double < 1 000 000> int <1 000 000>
double <10 000 000> int <10 000 000>
So, for a float (%f), the output is as expected, while it is wrong for
an integer (%d).
--
Best regards / Mit freundlichen Grüßen / Med vennlig hilsen
=======================================================================
Thomas Dreibholz
Simula Metropolitan Centre for Digital Engineering
Centre for Resilient Networks and Applications
Pilestredet 52
0167 Oslo, Norway
-----------------------------------------------------------------------
E-Mail:dreibh <at> simula.no
Homepage:http://simula.no/people/dreibh
=======================================================================
[Message part 2 (text/html, inline)]
[OpenPGP_signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 1 year and 115 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.