From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6076 invoked by alias); 29 Oct 2014 15:57:36 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 6041 invoked by uid 48); 29 Oct 2014 15:57:32 -0000 From: "arjun.is at lostca dot se" To: glibc-bugs@sourceware.org Subject: [Bug stdio/17522] New: `fputws' errors out when writing wide characters to unbuffered stream Date: Wed, 29 Oct 2014 15:57:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: stdio X-Bugzilla-Version: 2.21 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arjun.is at lostca dot se X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg00118.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D17522 Bug ID: 17522 Summary: `fputws' errors out when writing wide characters to unbuffered stream Product: glibc Version: 2.21 Status: NEW Severity: normal Priority: P2 Component: stdio Assignee: unassigned at sourceware dot org Reporter: arjun.is at lostca dot se I observed this bug when trying to modify libio/tst-fopenloc.c (which uses fputws) to use test-skeleton.c (which un-buffers stdout). When writing to an unbuffered stream, `fputws' seems to error out as soon a= s it encounters a UTF-8 character that takes up more than one byte. Reproducer: The below test case should print "Platform 9=C2=BE" to stdout a= nd finish successfully. It does not. fputws prints "Platform 9" then returns -1: #include #include #include #include #include int main (void) { wchar_t buf[100] =3D L"Platform 9"; FILE *fp; int r; setlocale (LC_ALL, "en_US.UTF-8"); buf[10] =3D L'\xbe'; /* unicode code point for "3/4" */ buf[11] =3D L'\n'; buf[12] =3D L'\0'; setvbuf (stdout, NULL, _IONBF, 0); if (fputws (buf, stdout) < 0) return 1; return 0; } --=20 You are receiving this mail because: You are on the CC list for the bug. >>From glibc-bugs-return-26483-listarch-glibc-bugs=sources.redhat.com@sourceware.org Wed Oct 29 16:50:51 2014 Return-Path: Delivered-To: listarch-glibc-bugs@sources.redhat.com Received: (qmail 27600 invoked by alias); 29 Oct 2014 16:50:50 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Delivered-To: mailing list glibc-bugs@sourceware.org Received: (qmail 27571 invoked by uid 48); 29 Oct 2014 16:50:47 -0000 From: "schwab@linux-m68k.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 16:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: stdio X-Bugzilla-Version: 2.21 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: schwab@linux-m68k.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg00119.txt.bz2 Content-length: 298 https://sourceware.org/bugzilla/show_bug.cgi?id=17522 --- Comment #1 from Andreas Schwab --- The problem is that an unbuffered stream has only room for a single byte buffer for code conversion. -- You are receiving this mail because: You are on the CC list for the bug.