autoconf: Test FREAD_READS_DIRECTORIES
PATCH v6 1/1 autoconf: Test FREAD_READS_DIRECTORIES
Add test for FREAD_READS_DIRECTORIES to detect when fread() reads fopen'ed directory.
config.mak.in +1 -0
@@ -46,4 +46,5 @@ NO_MKDTEMP=@NO_MKDTEMP@ NO_ICONV=@NO_ICONV@ OLD_ICONV=@OLD_ICONV@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ +FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
configure.ac +20 -0
@@ -327,6 +327,26 @@ else fi AC_SUBST(NO_C99_FORMAT) # +# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds +# when attempting to read from an fopen'ed directory. +AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory], + [ac_cv_fread_reads_directories], +[ +AC_RUN_IFELSE( + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], + [[char c; + FILE *f = fopen(".", "r"); + return f && fread(&c, 1, 1, f)]])], + [ac_cv_fread_reads_directories=no], + [ac_cv_fread_reads_directories=yes]) +]) +if test $ac_cv_fread_reads_directories = yes; then + FREAD_READS_DIRECTORIES=UnfortunatelyYes +else + FREAD_READS_DIRECTORIES= +fi +AC_SUBST(FREAD_READS_DIRECTORIES) +# # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf() # or vsnprintf() return -1 instead of number of characters which would # have been written to the final string if enough space had been available.
Looks fine to me. I was not keeping on an close eye on the discussion, however. Can we have a list of platforms we saw success stories on, so that I can mention them when I queue this?
Quoted 3 lines · On Monday 10 March 2008 07:21:27 Junio C Hamano wrote:
Looks fine to me. I was not keeping on an close eye on the discussion, however. Can we have a list of platforms we saw success stories on, so that I can mention them when I queue this?
Linux 2.6.25-rc4 - FREAD_READS_DIRECTORIES=
HP-UX B.11.11 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
HP-UX B.11.23 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
AIX 5.3 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
Tru64 V5.1 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
Signature · 9 lines
Michal Rokos NextSoft s.r.o. Vyskočilova 1/1410 140 21 Praha 4 phone: +420 267 224 311 fax: +420 267 224 307 mobile: +420 736 646 591 e-mail: [email protected]
Hi,
Quoted 5 lines · Michal Rokos
Add test for
FREAD_READS_DIRECTORIESto detect whenfread()reads fopen'ed directory.Signed-off-by Michal Rokos <[email protected]>Tested-by Mike Ralphson <[email protected]>
Okay, I just forced the stupid "socket in -lc" test to succeed, and now your patch does exactly what it is supposed to on MinGW (it says that fopen()ed directories cannot be read).
Of course, the building blocks are not in place, so I cannot compile on MinGW, but that is another issue.
So, you can readd my Tested-by: ;-)
Thanks,
Dscho