# [PATCH v2] Configure test for FREAD_READS_DIRECTORIES

3 messages from 2008-03-04 to 2008-03-04. Participants: Michal Rokos, Johannes Schindelin.
Thread: https://gitlist.dev/t/12491

## Michal Rokos, 2008-03-04 11:44

Subject: [PATCH v2] Configure test for FREAD_READS_DIRECTORIES
Message-ID: <200803041244.11315.michal.rokos@nextsoft.cz>
URL: https://gitlist.dev/e/200803041244.11315.michal.rokos%40nextsoft.cz

```
Hello,

this patch adds missing tests for FREAD_READS_DIRECTORIES.

Could anyone volunteer to test it on different platforms?
So far I know it works well on Linux (no FREAD_READS_DIRECTORIES),
HP-UXes 11.11 and 11.23 (FREAD_READS_DIRECTORIES defined).

Thanks

MR

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>

diff --git a/Makefile b/Makefile
index ca5aad9..344ab49 100644
--- a/Makefile
+++ b/Makefile
@@ -526,6 +526,7 @@ ifeq ($(uname_S),HP-UX)
 	NO_UNSETENV = YesPlease
 	NO_HSTRERROR = YesPlease
 	NO_SYS_SELECT_H = YesPlease
+	FREAD_READS_DIRECTORIES = UnfortunatelyYes
 endif
 ifneq (,$(findstring arm,$(uname_M)))
 	ARM_SHA1 = YesPlease
diff --git a/config.mak.in b/config.mak.in
index ee6c33d..516c468 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -46,3 +46,4 @@ NO_MKDTEMP=@NO_MKDTEMP@
 NO_ICONV=@NO_ICONV@
 OLD_ICONV=@OLD_ICONV@
 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
+FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
diff --git a/configure.ac b/configure.ac
index 85d7ef5..8f748a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -326,6 +326,27 @@ else
 	NO_C99_FORMAT=
 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");
+		if (! f) return 0;
+		if (f && fread(&c, 1, 1, f) > 0) return 1]])],
+	[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)
 
 
 ## Checks for library functions.


```

## Johannes Schindelin, 2008-03-04 12:05

Subject: Re: [PATCH v2] Configure test for FREAD_READS_DIRECTORIES
Message-ID: <alpine.LSU.1.00.0803041204490.22527@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0803041204490.22527%40racer.site
In-Reply-To: <200803041244.11315.michal.rokos@nextsoft.cz>

```
Hi,

On Tue, 4 Mar 2008, Michal Rokos wrote:

> Hello,

this is still wrong in the commit message.

I will test on msysGit in a moment.

Ciao,
Dscho

```

## Johannes Schindelin, 2008-03-04 13:43

Subject: Re: [PATCH v2] Configure test for FREAD_READS_DIRECTORIES
Message-ID: <alpine.LSU.1.00.0803041332580.22527@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0803041332580.22527%40racer.site
In-Reply-To: <alpine.LSU.1.00.0803041204490.22527@racer.site>

```
Hi,

On Tue, 4 Mar 2008, Johannes Schindelin wrote:

> I will test on msysGit in a moment.

Unfortunately, "autoconf" does not work in msysGit at the moment.

However, applying this patch on Linux, extracting the product of "make 
dist" on msysGit, and running "./configure" yields this:

...
checking whether system succeeds to read fopen'ed directory... yes
...

And indeed, FREAD_READS_DIRECTORIES is set in config.mak.autogen.  
However, "f" was NULL in your test, so I am not quite sure what is going 
wrong...

Besides, you miss a return 0 in the end, I think.  Or even better: you 
should

	return f && fread(&c, 1, 1, f);

BTW the commit message looks like this here... not nice (the commit log 
is not a mailing list):

commit 67418ff5d4f548f7de23e97bf165a8529ebf6a31
Author: Michal Rokos <michal.rokos@nextsoft.cz>
Date:   Tue Mar 4 12:44:11 2008 +0100

    Configure test for FREAD_READS_DIRECTORIES

    Hello,

    this patch adds missing tests for FREAD_READS_DIRECTORIES.

    Could anyone volunteer to test it on different platforms?
    So far I know it works well on Linux (no FREAD_READS_DIRECTORIES),
    HP-UXes 11.11 and 11.23 (FREAD_READS_DIRECTORIES defined).

    Thanks

    MR

    Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>


Ciao,
Dscho


```
