threads / patch / 12607

v6autoconf: Test FREAD_READS_DIRECTORIES

Subject: [PATCH v6] autoconf: Test FREAD_READS_DIRECTORIES

## tl;dr

4 messages between Mar 9, 2008 and Mar 10, 2008. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Michal Rokos· Mar 9, 2008, 20:44 UTC · lore

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

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
Tested-by: Mike Ralphson <mike@abacus.co.uk>
Show changes to 2 files +21 −0

config.mak.in, configure.ac

diff --git a/config.mak.in b/config.mak.in
index 8e1cd5f..7868dfd 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -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@
diff --git a/configure.ac b/configure.ac
index 287149d..82584e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.
Junio C Hamano· Mar 10, 2008, 06:21 UTC · re: Michal Rokos · lore

Re: [PATCH v6] autoconf: Test FREAD_READS_DIRECTORIES

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?

Michal Rokos· Mar 10, 2008, 08:54 UTC · re: Junio C Hamano · lore

Re: [PATCH v6] autoconf: Test FREAD_READS_DIRECTORIES

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=
Tested-by: Michal Rokos <michal.rokos@nextsoft.cz>
HP-UX B.11.11 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
Tested-by: Michal Rokos <michal.rokos@nextsoft.cz>
HP-UX B.11.23 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
Tested-by: Michal Rokos <michal.rokos@nextsoft.cz>
AIX 5.3 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
Tested-by: Mike Ralphson <mike@abacus.co.uk>
Tru64 V5.1 - FREAD_READS_DIRECTORIES=UnfortunatelyYes
Tested-by: Michal Rokos <michal.rokos@nextsoft.cz>
-- 
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: michal.rokos@nextsoft.cz
Johannes Schindelin· Mar 10, 2008, 15:46 UTC · re: Michal Rokos · lore

Re: [PATCH v6] autoconf: Test FREAD_READS_DIRECTORIES

Hi,
On Sun, 9 Mar 2008, Michal Rokos wrote:
Show 5 quoted lines
> Add test for FREAD_READS_DIRECTORIES to detect when fread() reads fopen'ed 
> directory.
> 
> Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
> Tested-by: Mike Ralphson <mike@abacus.co.uk>

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

← back to recent threads