> +#ifdef __KLIBC__ > + FILE *result = freopen (filename, mode, stream); > + > + /* On OS/2 kLIBC, freopen() returns NULL even if it is successful > + if filename is NULL. */ > + if (!result && !errno) > + result = stream;
1) In the comment you say 'if filename is NULL' but in the code you use the (hacky) workaround code also if filename != NULL. Why? 2) When freopen returns NULL for success, does it set errno = 0, or does it leave errno untouched? Can you find out, please, by using a test program like errno = 42; FILE *result = freopen (NULL, mode, stream); printf ("errno = %d\n", errno); If it's the latter case (it leaves errno untouched), you need to add an 'errno = 0;' statement before the freopen call. Bruno