git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES

From
MRMichal Rokos <michal.rokos@nextsoft.cz>
Date
Mar 4, 2008, 14:14 UTC
Message-ID
<200803041514.42783.michal.rokos@nextsoft.cz>
Add test for FREAD_READS_DIRECTORIES to configure script.

When "." could be opened and fread reads more than 0 items, FREAD_READS_DIRECTORIES will be set.

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
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.
Next: Johannes Schindelin
Message 1 of 6 in “autoconf: Test FREAD_READS_DIRECTORIES”
  1. autoconf: Test FREAD_READS_DIRECTORIESMichal Rokos, Mar 4, 2008
  2. Johannes SchindelinMar 4, 2008
  3. Michal RokosMar 4, 2008
  4. Johannes SchindelinMar 4, 2008
  5. Mike RalphsonMar 4, 2008
  6. Fwd: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIESMike Ralphson, Mar 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.