@matheusbsbs / matheus-bagliano / commits / 8ce1f243e5
Fork 0

autoconf: Test FREAD_READS_DIRECTORIES

Add test for FREAD_READS_DIRECTORIES to detect when fread() reads fopen'ed directory. Tested on these platforms: AIX 5.3 - FREAD_READS_DIRECTORIES=UnfortunatelyYes HP-UX B.11.11 - FREAD_READS_DIRECTORIES=UnfortunatelyYes HP-UX B.11.23 - FREAD_READS_DIRECTORIES=UnfortunatelyYes Linux 2.6.25-rc4 - FREAD_READS_DIRECTORIES= Tru64 V5.1 - FREAD_READS_DIRECTORIES=UnfortunatelyYes Windows - FREAD_READS_DIRECTORIES= Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz> Tested-by: Mike Ralphson <mike@abacus.co.uk> Tested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michal Rokos committed Mar 11, 2008 at 09:48 UTC 8ce1f243e5456eab52486b955389be2521dfcca5
2 files changed +21
config.mak.in
+1
@@ -46,4 +46,5 @@ NO_MKDTEMP=@NO_MKDTEMP@
46 NO_ICONV=@NO_ICONV@
47 OLD_ICONV=@OLD_ICONV@
48 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
49 +FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
50 SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
configure.ac
+20
@@ -327,6 +327,26 @@ else
327 fi
328 AC_SUBST(NO_C99_FORMAT)
329 #
330 +# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
331 +# when attempting to read from an fopen'ed directory.
332 +AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
333 + [ac_cv_fread_reads_directories],
334 +[
335 +AC_RUN_IFELSE(
336 + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
337 + [[char c;
338 + FILE *f = fopen(".", "r");
339 + return f && fread(&c, 1, 1, f)]])],
340 + [ac_cv_fread_reads_directories=no],
341 + [ac_cv_fread_reads_directories=yes])
342 +])
343 +if test $ac_cv_fread_reads_directories = yes; then
344 + FREAD_READS_DIRECTORIES=UnfortunatelyYes
345 +else
346 + FREAD_READS_DIRECTORIES=
347 +fi
348 +AC_SUBST(FREAD_READS_DIRECTORIES)
349 +#
350 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
351 # or vsnprintf() return -1 instead of number of characters which would
352 # have been written to the final string if enough space had been available.