Skip to contentSkip to conversation

autoconf: Test FREAD_READS_DIRECTORIES

PATCH Superseded Michal Rokos 3 participants 4 messages Jun 15, 2016

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

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
index 8e1cd5f..7868dfd 100644
@@ -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
index 287149d..82584e9 100644
@@ -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.
#1 lore raw

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?

author Tested-by Tested-by Tested-by Tested-by Mike Ralphson Tested-by
#2 lore raw
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]
#3 lore raw
In reply to Michal Rokos

Hi,

Quoted 5 lines · Michal Rokos

Add test for FREAD_READS_DIRECTORIES to detect when fread() reads fopen'ed directory.

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