[PATCH] fix fgetwc() from unbuffered file (RH bug 457506)

Denys Vlasenko dvlasenk@redhat.com
Wed Aug 27 11:44:00 GMT 2008


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




More information about the Libc-alpha mailing list