This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/6530] *printf() and incomplete multibyte sequences returns -1 bogusly


http://sourceware.org/bugzilla/show_bug.cgi?id=6530

--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2012-03-11 17:03:57 UTC ---
My pleasure. Per N1256 (C99+TC1/2/3):

s
If no l length modifier is present, the argument shall be a pointer to the
initial element of an array of character type.246) Characters from the array
are written up to (but not including) the terminating null character. If the
precision is specified, no more than that many bytes are written. If the
precision is not specified or is greater than the size of the array, the array
shall contain a null character. If an l length modifier is present, the
argument shall be a pointer to the initial element of an array of wchar_t type.
Wide characters from the array are converted to multibyte characters (each as
if by a call to the wcrtomb function, with the conversion state described by an
mbstate_t object initialized to zero before the first wide character is
converted) up to and including a terminating null wide character. The resulting
multibyte characters are written up to (but not including) the terminating null
character (byte). If no precision is specified, the array shall contain a null
wide character. If a precision is specified, no more than that many bytes are
written (including shift sequences, if any), and the array shall contain a null
wide character if, to equal the multibyte character sequence length given by
the precision, the function would need to access a wide character one past the
end of the array. In no case is a partial multibyte character written.247)

And the referenced footnotes:

246) No special provisions are made for multibyte characters.

247) Redundant shift sequences may result if multibyte characters have a
state-dependent encoding.

I don't think it could be clearer than what footnote 246 says about %s without
the l modifier.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]