Bug#324075: libc6: putwchar() returns WEOF without setting errno to EILSEQ
Package: libc6
Version: 2.3.5-4
Severity: normal
The following program shows that putwchar() can return WEOF with
errno = 0, though it should have set it to EILSEQ (see the ISO C
standard, and it is explicitly say in the putwchar(3) man page).
It should be run with "LC_CTYPE=tr_TR.UTF-8"; in this case, it
outputs:
putwchar-test: errno = 29
putwchar-test: errno = 0 (EILSEQ = 84)
Note: the fact that fwide() is called before setlocale() is
intentional, to make the error appear.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
#include <errno.h>
void my_putwchar (wchar_t wc)
{
wint_t ret;
ret = putwchar (wc);
if (ret == wc)
return;
putc ('\n', stderr);
if (ret != WEOF)
fprintf (stderr, "putwchar-test: internal error in putwchar\n");
fprintf (stderr, "putwchar-test: errno = %d (EILSEQ = %d)\n",
errno, EILSEQ);
exit (EXIT_FAILURE);
}
int main (void)
{
wint_t wc;
errno = 0;
if (fwide (stdout, 1) <= 0)
{
fprintf (stderr, "putwchar-test: can't set stdout's orientation\n");
exit (EXIT_FAILURE);
}
if (errno)
{
fprintf (stderr, "putwchar-test: errno = %d\n", errno);
errno = 0;
}
if (setlocale (LC_ALL, "") == NULL)
{
fprintf (stderr, "putwchar-test: can't set locales\n");
exit (EXIT_FAILURE);
}
wc = towlower (L'I');
if (wc == WEOF)
{
fprintf (stderr, "putwchar-test: btowc returned WEOF\n");
exit (EXIT_FAILURE);
}
my_putwchar (wc);
my_putwchar (L'\n');
return 0;
}
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11.10-20050517
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)
-- no debconf information
Reply to: