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/17522] `fputws' errors out when writing wide characters to unbuffered stream


https://sourceware.org/bugzilla/show_bug.cgi?id=17522

--- Comment #4 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Arjun Shankar from comment #3)
> (In reply to Carlos O'Donell from comment #2)
> > This is a bug in tst-skeleton.c IMO, it should allocate a buffer large
> > enough for the test to succeed, but small enough that you still get output
> > as quickly as possible in the even of a crash.
> > 
> > Thus tst-skeleton.c needs to be enhanced to allow the test to define the
> > size of the stdout buffer it needs and then that can be allocated and passed
> > to setvbuf?
> 
> Reading the definitions of setvbuf [1] and fputws [2] didn't make it clear
> to me that fputws is going to error out when writing a multi-byte character
> to an unbuffered stream.

It's a QoI issue.

> Andreas notes that there is a single byte buffer associated with unbuffered
> streams. Is this single byte buffer present in accordance with some contract
> offered by unbuffered streams? If not, then can I call the one byte buffer
> an implementation detail? If it is an implementation detail, would it make
> sense to associate each unbuffered stream with a buffer just wide enough to
> represent one wide character in the chosen encoding scheme, instead of just
> one byte? i.e. in the case of UTF-8, I guess this would mean a 4 byte buffer.
> 
> [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/setvbuf.html
> [2] http://pubs.opengroup.org/onlinepubs/009695399/functions/fputws.html

That's right, it is an implementation detail.

Because UTF-8 is a variable length encoding, you would need to immediately
print a character whenever you complete it regardless of the buffer size, but
rather based on the fact that you are unbuffered.

I don't know how much more work it would be to enhance the file stream support
to do this when unbuffered.

For example, printing ASCII, should just print right away, it's unbuffered, and
that's valid UTF-8. It should not be a naive implementation where you might
have 4 ASCII characters waiting in a buffer before being printed.

Does that answer your question?

-- 
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]