fgetwc returns various errors when it shouldn't
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
$ cat wcw.c
#define _GNU_SOURCE
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
int
main(void)
{
wint_t c;
if (!setlocale(
}
while ((errno = 0, c = fgetwc(stdin)) != WEOF) {
}
if (errno != 0) {
}
return 0;
}
$ cc -Wall -W wcw.c -o wcw
$ ./wcw < empty
$ ./wcw < /dev/null
errno = 25
fgetwc: Inappropriate ioctl for device
$ cat /dev/null | ./wcw
errno = 29
fgetwc: Illegal seek
On the other hand, on Solaris 10, I get the following behavior, which lets me distinguish EOF from errors:
$ ./wcw < empty
$ ./wcw < /de
$ ./wcw < /dev/null
$ cat empty | ./wcw