public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/17522] New: `fputws' errors out when writing wide characters to unbuffered stream
@ 2014-10-29 15:57 arjun.is at lostca dot se
  2014-10-29 18:03 ` [Bug stdio/17522] " carlos at redhat dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: arjun.is at lostca dot se @ 2014-10-29 15:57 UTC (permalink / raw)
  To: glibc-bugs

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

            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 as it
encounters a UTF-8 character that takes up more than one byte.

Reproducer: The below test case should print "Platform 9¾" to stdout and finish
successfully. It does not. fputws prints "Platform 9" then returns -1:

#include <locale.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <errno.h>

int
main (void)
{
  wchar_t buf[100] = L"Platform 9";
  FILE *fp;
  int r;

  setlocale (LC_ALL, "en_US.UTF-8");

  buf[10] = L'\xbe'; /* unicode code point for "3/4" */
  buf[11] = L'\n';
  buf[12] = L'\0';

  setvbuf (stdout, NULL, _IONBF, 0);

  if (fputws (buf, stdout) < 0)
    return 1;

  return 0;
}

-- 
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: <glibc-bugs-return-26483-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
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: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
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" <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 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: <bug-17522-131-zXNZ7G6oOO@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17522-131@http.sourceware.org/bugzilla/>
References: <bug-17522-131@http.sourceware.org/bugzilla/>
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\x17522

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-20 15:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29 15:57 [Bug stdio/17522] New: `fputws' errors out when writing wide characters to unbuffered stream 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
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

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).