Public bug reported:
$ 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(LC_CTYPE, "")) {
perror("setlocale");
exit(EXIT_FAILURE);
}
while ((errno = 0, c = fgetwc(stdin)) != WEOF) {
printf("U+%04x has width %d\n", (unsigned)c, wcwidth(c));
}
if (errno != 0) {
fprintf(stderr, "errno = %d\n", errno);
perror("fgetwc");
exit(EXIT_FAILURE);
}
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
** Affects: glibc (Ubuntu)
Importance: Undecided
Status: New
--
fgetwc returns various errors when it shouldn't
https://bugs.launchpad.net/bugs/307987
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs