Red Hat Bugzilla – Bug 77057
Bad interaction between locale settings and the '%.*s' format specifier in the printf family
Last modified: 2016-11-24 10:17:54 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003
Description of problem:
If a program has used setlocale (LC_ALL, "") (as is typical for applications
using gettext), and $LANG is set to en_US (the default), using xxprintf ("blah
%.*s some more", <n>, <some string containing accented characters>) stops output
at the format spec.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. compile & run the attached C source
2. run the resulting program
Actual Results: The accented string is printed only on the first time.
Expected Results: The accented string is printed on both lines (this happens on
redhat 6.2 with glibc-2.2.4-5).
Any other setting than en_US seems to result in the correct behaviour, as does
omitting the setlocale() call (but the latter seems to be required for gettext()
Created attachment 82884 [details]
Cannot reproduce, works just fine with LANG=en_US and glibc 2.2.93-5
nor 2.3.1-2. Though LANG=en_US is certainly not the default in 8.0, it is
en_US.UTF-8, for which obviously the second printf stops at the format spec
because the string is not a valid UTF-8 string and thus printf cannot compute