summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-06-14 05:30:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-15 21:14:33 (GMT)
commit3adf9fdecfb0cd31a83ef3af1d8d631a1acd392b (patch)
treea75b2e3f909a2aafbcc4b050bc153e79417a1d77 /configure.ac
parente5b313442ab7c700d0851e9dbe7d2b029e3893e5 (diff)
downloadgit-3adf9fdecfb0cd31a83ef3af1d8d631a1acd392b.zip
git-3adf9fdecfb0cd31a83ef3af1d8d631a1acd392b.tar.gz
git-3adf9fdecfb0cd31a83ef3af1d8d631a1acd392b.tar.bz2
configure.ac: loosen FREAD_READS_DIRECTORIES test program
We added an FREAD_READS_DIRECTORIES Makefile knob long ago in cba22528f (Add compat/fopen.c which returns NULL on attempt to open directory, 2008-02-08) to handle systems where reading from a directory returned garbage. This works by catching the problem at the fopen() stage and returning NULL. More recently, we found that there is a class of systems (including Linux) where fopen() succeeds but fread() fails. Since the solution is the same (having fopen return NULL), they use the same Makefile knob as of e2d90fd1c (config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD, 2017-05-03). This works fine except for one thing: the autoconf test in configure.ac to set FREAD_READS_DIRECTORIES actually checks whether fread succeeds. Which means that on Linux systems, the knob isn't set (and we even override the config.mak.uname default). t1308 catches the failure. We can fix this by tweaking the autoconf test to cover both cases. In theory we might care about the distinction between the traditional "fread reads directories" case and the new "fopen opens directories". But since our solution catches the problem at the fopen stage either way, we don't actually need to know the difference. The "fopen" case is a superset. This does mean the FREAD_READS_DIRECTORIES name is slightly misleading. Probably FOPEN_OPENS_DIRECTORIES would be more accurate. But it would be disruptive to simply change the name (people's existing build configs would fail), and it's not worth the complexity of handling both. Let's just add a comment in the knob description. Reported-by: √ėyvind A. Holm <sunny@sunbase.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac4
1 files changed, 2 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 1281655..ceeb9de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -865,9 +865,9 @@ AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
[
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
- [[char c;
+ [[
FILE *f = fopen(".", "r");
- return f && fread(&c, 1, 1, f)]])],
+ return f)]])],
[ac_cv_fread_reads_directories=no],
[ac_cv_fread_reads_directories=yes])
])