POSIX states: The perror() function shall not change the orientation of the standard error stream.
However, cygwin perror() function changes the orientation of stderr to byte-oriented mode if stderr is not oriented yet. Simple test case (chkperror.c) attached checks this behavior. Expected result: 0 äöü: Invalid argument 0 äöü 1 äöü: Invalid argument However, cygwin result: 0 äöü: Invalid argument -1 ▒▒▒ -1 äöü: Invalid argument I have made a patch to solve this problem, attached. However, I am not sure that calling _write_r() here is correct manner. I will appreciate if anyone familiar with libc code comment or make suggestions. -- Takashi Yano <takashi.y...@nifty.ne.jp>
0001-Fix-a-bug-of-perror-which-changes-the-orientation-of.patch
Description: Binary data
#include <stdio.h> #include <wchar.h> #include <locale.h> #include <errno.h> int main() { setlocale(LC_CTYPE, "de_DE.UTF-8"); errno = EINVAL; printf("%d\n", fwide(stderr, 0)); perror("äöü"); printf("%d\n", fwide(stderr, 0)); fwprintf(stderr, L"äöü\n"); printf("%d\n", fwide(stderr, 0)); perror("äöü"); return 0; }
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple