[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: locale-related printf bug when using formats with thousands grouping
From: |
Jim Meyering |
Subject: |
Re: locale-related printf bug when using formats with thousands grouping character |
Date: |
Thu, 13 Jan 2011 10:04:05 +0100 |
Bruno Haible wrote:
> The bug affects not only %f but also %g, and it can lead to a SIGSEGV.
>
> Reproduce with the bash 3.2.1 built-in:
>
> $ LC_ALL=en_US.UTF-8 bash -c "printf \"%'.5g\\\\n\" 999.996"
> 1000
> $ LC_ALL=en_US.UTF-8 bash -c "printf \"%'.4g\\\\n\" 9999.996"
> Segmentation fault
> $ LC_ALL=en_US.UTF-8 bash -c "printf \"%'.5g\\\\n\" 99999.996"
> Segmentation fault
> $ LC_ALL=en_US.UTF-8 bash -c "printf \"%'.6g\\\\n\" 999999.996"
> Segmentation fault
> $ LC_ALL=en_US.UTF-8 bash -c "printf \"%'.7g\\\\n\" 9999999.996"
> Segmentation fault
>
> or with the printf program from coreutils 8.4:
>
> $ env LC_ALL=en_US.UTF-8 printf "%'.5g\\n" 999.996
> 1000
> $ env LC_ALL=en_US.UTF-8 printf "%'.4g\\n" 9999.996
> Segmentation fault
Argh.
Yet another reason to add a full-blown snprintf replacement to gnulib.
At least this bug affects only floating point formats.