Re: fdopen on MSVC

2011-09-26 Thread Eric Blake
On 09/26/2011 04:40 PM, Bruno Haible wrote: On glibc systems (and probably many others as well), the invalid file descriptor is already caught by fdopen(). But there is no guarantee that all systems do this. But this is gnulib. _We_ can make that guarantee for all systems, via the fdopen mod

Re: fdopen on MSVC

2011-09-26 Thread Bruno Haible
Hi Eric, > If fdopen(-1,"r") returns anything besides NULL in the first place, then > that is a bug in fdopen(). Nope. POSIX:2008 says in : "The fdopen() function MAY fail if: [EBADF] The fildes argument is

Re: fdopen on MSVC

2011-09-26 Thread Eric Blake
On 09/26/2011 04:30 PM, Eric Blake wrote: If fdopen(-1,"r") returns anything besides NULL in the first place, then that is a bug in fdopen(). All right, POSIX states that EBADF is a may fail, rather than a shall fail, in that situation. But do we know of any implementations that actually ret

Re: fdopen on MSVC

2011-09-26 Thread Eric Blake
On 09/26/2011 04:17 PM, Bruno Haible wrote: Paolo Bonzini asked: * modules/fclose-tests (Depends-on): Add fdopen. * modules/fflush-tests (Depends-on): Likewise. * modules/fgetc-tests (Depends-on): Likewise. * modules/fputc-tests (Depends-on): Likewise. * m

Re: fdopen on MSVC

2011-09-26 Thread Bruno Haible
Paolo Bonzini asked: > > * modules/fclose-tests (Depends-on): Add fdopen. > > * modules/fflush-tests (Depends-on): Likewise. > > * modules/fgetc-tests (Depends-on): Likewise. > > * modules/fputc-tests (Depends-on): Likewise. > > * modules/fread-tests (Depends-on): Likewise. > >

Re: fdopen on MSVC

2011-09-26 Thread Paolo Bonzini
On 09/24/2011 06:11 PM, Bruno Haible wrote: * modules/fclose-tests (Depends-on): Add fdopen. * modules/fflush-tests (Depends-on): Likewise. * modules/fgetc-tests (Depends-on): Likewise. * modules/fputc-tests (Depends-on): Likewise. * modules/fread-tests (De

fdopen on MSVC

2011-09-24 Thread Bruno Haible
The fdopen() function also crashes on MSVC if the fd argument is invalid. Here's the workaround. 2011-09-24 Bruno Haible fdopen: Support for MSVC 9. * m4/fdopen.m4 (gl_FUNC_FDOPEN): Set REPLACE_FDOPEN also if HAVE_MSVC_INVALID_PARAMETER_HANDLER is 1. * lib/fdop