public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug stdio/17522] `fputws' errors out when writing wide characters to unbuffered stream Date: Wed, 29 Oct 2014 18:49:00 -0000 [thread overview] Message-ID: <bug-17522-131-KENwt8UuCf@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-17522-131@http.sourceware.org/bugzilla/> 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.
next prev parent reply other threads:[~2014-10-29 18:49 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-10-29 15:57 [Bug stdio/17522] New: " arjun.is at lostca dot se 2014-10-29 18:03 ` [Bug stdio/17522] " carlos at redhat dot com 2014-10-29 18:43 ` arjun.is at lostca dot se 2014-10-29 18:49 ` carlos at redhat dot com [this message] 2014-10-29 19:12 ` arjun.is at lostca dot se 2014-10-29 19:16 ` carlos at redhat dot com 2014-11-03 9:00 ` cvs-commit at gcc dot gnu.org 2014-11-03 9:03 ` schwab@linux-m68k.org 2014-12-16 11:26 ` cvs-commit at gcc dot gnu.org 2023-12-20 15:43 ` fweimer at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-17522-131-KENwt8UuCf@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).