Bug 77057 - Bad interaction between locale settings and the '%.*s' format specifier in the printf family
Summary: Bad interaction between locale settings and the '%.*s' format specifier in th...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 8.0
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-31 15:34 UTC by Need Real Name
Modified: 2016-11-24 15:17 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-10-31 15:35:52 UTC


Attachments (Terms of Use)
Simplistic testcase (299 bytes, patch)
2002-10-31 15:35 UTC, Need Real Name
no flags Details | Diff

Description Need Real Name 2002-10-31 15:34:48 UTC
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):


How reproducible:
Always

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).

Additional info:

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()
to work).

Comment 1 Need Real Name 2002-10-31 15:35:46 UTC
Created attachment 82884 [details]
Simplistic testcase

Comment 2 Jakub Jelinek 2002-11-01 20:35:48 UTC
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
its length.


Note You need to log in before you can comment on or make changes to this bug.