Re: fprintf() crashes on wide-oriented stream.

Brian Inglis <[email protected]>
Newsgroups gmane.comp.lib.newlib
Organization Inglis
Message-ID <[email protected]>
On 2023-09-28 02:42, Takashi Yano wrote:
> On Thu, 28 Sep 2023 12:58:27 +0900
> Takashi Yano wrote:
>> On Tue, 26 Sep 2023 12:41:47 +0900
>> Takashi Yano wrote:
>>> With this patch, __sfputs_r/__sprint_r is split into two versions, one
>>> is for vfprintf which does not handle wide string, and the other (newly
>>> introduced __sfputws_r/__swprin_r) is for vfwprintf which handles wide
>>> string. Please note that fprintf gets working for wide orient stream
>>> just like BSD libc, which behaves differently from GNU libc.

Note that glibc handles %c/%s in wchar_t functions and %C/%lc/%S/%ls in char 
functions: see `man -m linux 3 fwide` NOTES.

>> I confirmed musl libc also behaves as BSD libc.
>>
>> In the GNU libc (glibc), fprintf() returns -1 with no errno set if the
>> stream is wide-oriented.

That is not documented in released man-pages-linux.
What is documented is that the width setting persists once set, and can not be 
changed until the stream is closed.

> I also confirmed that Solaris libc behaves as same as BSD libc.
> 
> I wonder what are the advantages of the glibc implementation?
> Any historical reason?

What are the behavioural differences you perceive?

There is a public inbox you can search at

	https://inbox.sourceware.org/libc-help/

and you can ask mailto:[email protected] about anything.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.