summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-18 12:24:24 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-18 12:24:24 +0000
commitae42c38fbb91db68f7790476f2abeafb2b8a44f7 (patch)
tree7af7dbd83fcde5149a24dda0b9ae3226f08ac7a3
parenta007ea38462fb41a1489e9cb5090c8970db582ab (diff)
downloadmandoc-ae42c38fbb91db68f7790476f2abeafb2b8a44f7.tar.gz
proper test for O_DIRECTORY
-rw-r--r--Makefile1
-rw-r--r--catman.c4
-rw-r--r--compat_fts.c6
-rwxr-xr-xconfigure3
-rw-r--r--configure.local.example1
-rw-r--r--test-O_DIRECTORY.c7
6 files changed, 12 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index ec91fe41..7d8c5eb3 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ TESTSRCS = test-be32toh.c \
test-mkdtemp.c \
test-nanosleep.c \
test-ntohl.c \
+ test-O_DIRECTORY.c \
test-ohash.c \
test-PATH_MAX.c \
test-pledge.c \
diff --git a/catman.c b/catman.c
index 8a3aed3a..871b995b 100644
--- a/catman.c
+++ b/catman.c
@@ -41,10 +41,6 @@
#include <time.h>
#include <unistd.h>
-#ifndef O_DIRECTORY
-#define O_DIRECTORY 0
-#endif
-
int process_manpage(int, int, const char *);
int process_tree(int, int);
void run_mandocd(int, const char *, const char *)
diff --git a/compat_fts.c b/compat_fts.c
index 7e78e829..87847927 100644
--- a/compat_fts.c
+++ b/compat_fts.c
@@ -63,15 +63,9 @@ static FTSENT *fts_sort(FTS *, FTSENT *, int);
static unsigned short fts_stat(FTS *, FTSENT *);
#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
-#ifndef O_DIRECTORY
-#define O_DIRECTORY 0
-#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
#define CLR(opt) (sp->fts_options &= ~(opt))
#define ISSET(opt) (sp->fts_options & (opt))
diff --git a/configure b/configure
index 001f0da8..0bc63131 100755
--- a/configure
+++ b/configure
@@ -67,6 +67,7 @@ HAVE_ISBLANK=
HAVE_MKDTEMP=
HAVE_NANOSLEEP=
HAVE_NTOHL=
+HAVE_O_DIRECTORY=
HAVE_OHASH=
HAVE_PATH_MAX=
HAVE_PLEDGE=
@@ -221,6 +222,7 @@ runtest getsubopt GETSUBOPT || true
runtest isblank ISBLANK || true
runtest mkdtemp MKDTEMP || true
runtest ntohl NTOHL || true
+runtest O_DIRECTORY O_DIRECTORY || true
runtest PATH_MAX PATH_MAX || true
runtest pledge PLEDGE || true
runtest sandbox_init SANDBOX_INIT || true
@@ -358,6 +360,7 @@ echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
[ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
[ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
+[ ${HAVE_O_DIRECTORY} -eq 0 ] && echo "#define O_DIRECTORY 0"
[ ${HAVE_PATH_MAX} -eq 0 ] && echo "#define PATH_MAX 4096"
if [ ${HAVE_ENDIAN} -eq 0 -a ${HAVE_SYS_ENDIAN} -eq 0 ]; then
echo "#define be32toh ntohl"
diff --git a/configure.local.example b/configure.local.example
index 8d1958d4..33a7bdec 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -279,6 +279,7 @@ HAVE_GETSUBOPT=0
HAVE_ISBLANK=0
HAVE_MKDTEMP=0
HAVE_NTOHL=0
+HAVE_O_DIRECTORY=0
HAVE_OHASH=0
HAVE_PATH_MAX=0
HAVE_PLEDGE=0
diff --git a/test-O_DIRECTORY.c b/test-O_DIRECTORY.c
new file mode 100644
index 00000000..e44d51ca
--- /dev/null
+++ b/test-O_DIRECTORY.c
@@ -0,0 +1,7 @@
+#include <fcntl.h>
+
+int
+main(void)
+{
+ return open(".", O_RDONLY | O_DIRECTORY) == -1;
+}