[PATCH v6] autoconf: Test FREAD_READS_DIRECTORIES

Previous thread: Mercurial's only true "plugin" extension: inotify... and can it be done in Git? by Jakub Narebski on Sunday, March 9, 2008 - 6:59 am. (9 messages)

Next thread: [PATCH 1/2] Add a lockfile function to append to a file by Daniel Barkalow on Sunday, March 9, 2008 - 3:46 pm. (1 message)
From: Michal Rokos
Date: Sunday, March 9, 2008 - 1:44 pm

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>

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.
--

From: Junio C Hamano
Date: Sunday, March 9, 2008 - 11:21 pm

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?

--

From: Michal Rokos
Date: Monday, March 10, 2008 - 1:54 am

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
--

From: Johannes Schindelin
Date: Monday, March 10, 2008 - 8:46 am

Hi,


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
--

Previous thread: Mercurial's only true "plugin" extension: inotify... and can it be done in Git? by Jakub Narebski on Sunday, March 9, 2008 - 6:59 am. (9 messages)

Next thread: [PATCH 1/2] Add a lockfile function to append to a file by Daniel Barkalow on Sunday, March 9, 2008 - 3:46 pm. (1 message)