[Bug 280543] df -, isn't columnated if the thousands separator is multi-byte

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 07 Aug 2024 14:06:04 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280543

Duncan Paterson <dunkyp@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dunkyp@gmail.com

--- Comment #1 from Duncan Paterson <dunkyp@gmail.com> ---
Created attachment 252588
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=252588&action=edit
Don't multiply size of thousands separator by string length of sep

The bug is in printf handling of thousands separators. In the case of multibyte
chars as in polish (C2 A0 NO-BREAK SPACE) the offset for thousands separator is
being given in bytes however this isn't correct as there is only a single char.
I've attached a patch to printf which corrects the output.

Given the program 
#include <stdio.h>
#include <locale.h>
int main(void)
{
    setlocale(LC_NUMERIC, "");
    printf("%'*d\n", 20, 1123456789);
    return 0;
}

the output of the program is now correctly 
env LC_ALL=pl_PL.UTF-8 ./a.out
       1 123 456 789
rather than
env LC_ALL=pl_PL.UTF-8 ./a.out
     1 123 456 789

-- 
You are receiving this mail because:
You are the assignee for the bug.