Public bug reported:

I just discovered a printf bug for at least the nb_NO and nn_NO locales
when printing numbers with thousands separator. To reproduce:

#!/bin/bash
for l in de_DE en_US nb_NO ; do
   echo "LC_NUMERIC=$l.UTF-8"
   for n in 1 100 1000 10000 100000 1000000 10000000 ; do
      LC_NUMERIC=$l.UTF-8 /usr/bin/printf "<%'10d>\n" $n
   done
done

The expected output of "%'10d" is a right-formatted number string with
10 characters.

The output of the test script is fine for e.g. LC_NUMERIC=de_DE.UTF-8
and LC_NUMERIC=en_US.UTF-8:

LC_NUMERIC=de_DE.UTF-8
<         1>
<       100>
<     1.000>
<    10.000>
<   100.000>
< 1.000.000>
<10.000.000>
LC_NUMERIC=en_US.UTF-8
<         1>
<       100>
<     1,000>
<    10,000>
<   100,000>
< 1,000,000>
<10,000,000>

However, for LC_NUMERIC=nb_NO.UTF-8 and LC_NUMERIC=nn_NO.UTF-8, the
formatting is wrong:

LC_NUMERIC=nb_NO.UTF-8
<         1>
<       100>
<   1 000>
<  10 000>
< 100 000>
<1 000 000>
<10 000 000>
LC_NUMERIC=nn_NO.UTF-8
<         1>
<       100>
<   1 000>
<  10 000>
< 100 000>
<1 000 000>
<10 000 000>

I reproduced the issue with coreutils-8.32-4.1ubuntu1.1 (Ubuntu 22.04)
as well as coreutils-9.3-5.fc39.x86_64 (Fedora 39).

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: coreutils 8.32-4.1ubuntu1.1
ProcVersionSignature: Ubuntu 6.5.0-26.26~22.04.1-generic 6.5.13
Uname: Linux 6.5.0-26-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: KDE
Date: Fri Mar 22 21:33:13 2024
InstallationDate: Installed on 2022-11-29 (479 days ago)
InstallationMedia: Kubuntu 22.04.1 LTS "Jammy Jellyfish" - Release amd64 
(20220809.1)
SourcePackage: coreutils
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: coreutils (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug jammy

** Description changed:

  I just discovered a printf bug for at least the nb_NO and nn_NO locales
  when printing numbers with thousands separator. To reproduce:
  
  #!/bin/bash
  for l in de_DE en_US nb_NO ; do
-    echo "LC_NUMERIC=$l.UTF-8"
-    for n in 1 100 1000 10000 100000 1000000 10000000 ; do     
-       LC_NUMERIC=$l.UTF-8 /usr/bin/printf "<%'10d>\n" $n
-    done
+    echo "LC_NUMERIC=$l.UTF-8"
+    for n in 1 100 1000 10000 100000 1000000 10000000 ; do
+       LC_NUMERIC=$l.UTF-8 /usr/bin/printf "<%'10d>\n" $n
+    done
  done
  
  The expected output of "%'10d" is a right-formatted number string with
  10 characters.
  
  The output of the test script is fine for e.g. LC_NUMERIC=de_DE.UTF-8
  and LC_NUMERIC=en_US.UTF-8:
  
  LC_NUMERIC=de_DE.UTF-8
  <         1>
  <       100>
  <     1.000>
  <    10.000>
  <   100.000>
  < 1.000.000>
  <10.000.000>
  LC_NUMERIC=en_US.UTF-8
  <         1>
  <       100>
  <     1,000>
  <    10,000>
  <   100,000>
  < 1,000,000>
  <10,000,000>
  
  However, for LC_NUMERIC=nb_NO.UTF-8 and LC_NUMERIC=nn_NO.UTF-8, the
  formatting is wrong:
  
  LC_NUMERIC=nb_NO.UTF-8
  <         1>
  <       100>
  <   1 000>
  <  10 000>
  < 100 000>
  <1 000 000>
  <10 000 000>
  LC_NUMERIC=nn_NO.UTF-8
  <         1>
  <       100>
  <   1 000>
  <  10 000>
  < 100 000>
  <1 000 000>
  <10 000 000>
  
  I reproduced the issue with coreutils-8.32-4.1ubuntu1.1 (Ubuntu 22.04)
  as well as coreutils-9.3-5.fc39.x86_64 (Fedora 39).
  
  ProblemType: Bug
  DistroRelease: Ubuntu 22.04
  Package: coreutils 8.32-4.1ubuntu1.1
  ProcVersionSignature: Ubuntu 6.5.0-26.26~22.04.1-generic 6.5.13
  Uname: Linux 6.5.0-26-generic x86_64
  ApportVersion: 2.20.11-0ubuntu82.5
  Architecture: amd64
  CasperMD5CheckResult: pass
  CurrentDesktop: KDE
  Date: Fri Mar 22 21:33:13 2024
  InstallationDate: Installed on 2022-11-29 (479 days ago)
  InstallationMedia: Kubuntu 22.04.1 LTS "Jammy Jellyfish" - Release amd64 
(20220809.1)
  SourcePackage: coreutils
  UpgradeStatus: No upgrade log present (probably fresh install)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2058775

Title:
  coreutils: printf formatting bug for nb_NO and nn_NO locales

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/2058775/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to