bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#69951: coreutils: printf formatting bug for nb_NO and nn_NO locales


From: Thomas Dreibholz
Subject: bug#69951: coreutils: printf formatting bug for nb_NO and nn_NO locales
Date: Sat, 23 Mar 2024 19:17:02 +0100
User-agent: Mozilla Thunderbird

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@simula.no
 Homepage:http://simula.no/people/dreibh
=======================================================================

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]