> + * The default way, which is reasonable for programs (not libraries): > + AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING]) > + > + * The way for libraries that make "hairy" calls (like close(-1), or > + fclose(fp) where fileno(fp) is closed, or simply getdtablesize()): > + AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING]) > + > + * The way for libraries that make no "hairy" calls: > + AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING])
Now, 5 unit tests pass in the DEFAULT_HANDLING mode but fail in the two other modes: FAIL: test-fflush.exe FAIL: test-fgetc.exe FAIL: test-fputc.exe FAIL: test-fread.exe FAIL: test-fwrite.exe All these fail on a stream whose file descriptor has been closed. Most libraries won't do such a thing. Therefore I don't find it worth to fix this. Just document it. Also, in hindsight, the modifications to the 'raise' and 'sigprocmask' modules could have been low priority. Libraries hardly use 'raise' and 'sigprocmask' since these functions are not multithread-safe, and for programs the DEFAULT_HANDLING mode already provides a POSIX like behaviour to raise() and sigprocmask(). On the other hand, libraries can use pthread_sigmask(), and our current gnulib replacement for it uses sigprocmask(). 2011-09-25 Bruno Haible <br...@clisp.org> fflush et al.: Document limitation on MSVC. * doc/posix-functions/fflush.texi: Document possible crash in handling mode other than DEFAULT_HANDLING. * doc/posix-functions/fgetc.texi: Likewise. * doc/posix-functions/fputc.texi: Likewise. * doc/posix-functions/fread.texi: Likewise. * doc/posix-functions/fwrite.texi: Likewise. --- doc/posix-functions/fflush.texi.orig Sun Sep 25 23:20:15 2011 +++ doc/posix-functions/fflush.texi Sun Sep 25 23:19:34 2011 @@ -31,6 +31,12 @@ On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. @item +This function crashes if the stream's file descriptor has already been +closed, if @code{MSVC_INVALID_PARAMETER_HANDLING} is +@code{HAIRY_LIBRARY_HANDLING} or @code{SANE_LIBRARY_HANDLING}, +on some platforms: +MSVC 9. +@item @code{fflush} on an input stream right after @code{ungetc} does not discard the @code{ungetc} buffer, on some platforms: AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11 2010-11, mingw, MSVC 9. --- doc/posix-functions/fgetc.texi.orig Sun Sep 25 23:20:15 2011 +++ doc/posix-functions/fgetc.texi Sun Sep 25 23:19:10 2011 @@ -20,4 +20,10 @@ @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +This function crashes if the stream's file descriptor has already been +closed, if @code{MSVC_INVALID_PARAMETER_HANDLING} is +@code{HAIRY_LIBRARY_HANDLING} or @code{SANE_LIBRARY_HANDLING}, +on some platforms: +MSVC 9. @end itemize --- doc/posix-functions/fputc.texi.orig Sun Sep 25 23:20:15 2011 +++ doc/posix-functions/fputc.texi Sun Sep 25 23:19:10 2011 @@ -32,4 +32,10 @@ On some platforms, this function does not set @code{errno} or the stream error indicator on attempts to write to a read-only stream: Cygwin 1.7.9. +@item +This function crashes if the stream's file descriptor has already been +closed, if @code{MSVC_INVALID_PARAMETER_HANDLING} is +@code{HAIRY_LIBRARY_HANDLING} or @code{SANE_LIBRARY_HANDLING}, +on some platforms: +MSVC 9. @end itemize --- doc/posix-functions/fread.texi.orig Sun Sep 25 23:20:15 2011 +++ doc/posix-functions/fread.texi Sun Sep 25 23:19:10 2011 @@ -20,4 +20,10 @@ @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +This function crashes if the stream's file descriptor has already been +closed, if @code{MSVC_INVALID_PARAMETER_HANDLING} is +@code{HAIRY_LIBRARY_HANDLING} or @code{SANE_LIBRARY_HANDLING}, +on some platforms: +MSVC 9. @end itemize --- doc/posix-functions/fwrite.texi.orig Sun Sep 25 23:20:15 2011 +++ doc/posix-functions/fwrite.texi Sun Sep 25 23:19:11 2011 @@ -32,4 +32,10 @@ On some platforms, this function does not set @code{errno} or the stream error indicator on attempts to write to a read-only stream: Cygwin 1.7.9. +@item +This function crashes if the stream's file descriptor has already been +closed, if @code{MSVC_INVALID_PARAMETER_HANDLING} is +@code{HAIRY_LIBRARY_HANDLING} or @code{SANE_LIBRARY_HANDLING}, +on some platforms: +MSVC 9. @end itemize -- In memoriam Safia Ahmed-jan <http://en.wikipedia.org/wiki/Safia_Ahmed-jan>