This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] fix fgetwc() from unbuffered file (RH bug 457506)
- From: Denys Vlasenko <dvlasenk at redhat dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Wed, 27 Aug 2008 12:13:07 +0200
- Subject: [PATCH] fix fgetwc() from unbuffered file (RH bug 457506)
Hi,
This is a fix for this RH bug:
https://bugzilla.redhat.com/show_bug.cgi?id=457506
Testcase:
This what is working for me with this patch:
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
int main(void)
{
wint_t c;
setlocale(LC_ALL, "en_US.utf8");
setvbuf(stdin, NULL, _IONBF, 0);
while ((c = fgetwc(stdin)) != WEOF) {
fputwc(c, stdout);
fflush(stdout);
}
if (ferror(stdin))
perror(NULL);
}
# cat zz.txt
qwerty
ÐÑÑÐÐÐ
# LD_LIBRARY_PATH=. ./a.out <zz.txt
qwerty
ÐÑÑÐÐÐ <--- without patch, this is not printed!
for Changelog:
2008-08-27 Denys Vlasenko <dvlasenk@redhat.com>
* libio/wfileops.c (_IO_wfile_underflow): Use local small
buffer if input file is unbuffered.
--
vda