aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xconfigure39
-rw-r--r--configure.local.example5
-rw-r--r--mandocdb.c10
-rw-r--r--test-fts.c19
4 files changed, 54 insertions, 19 deletions
diff --git a/configure b/configure
index 9d43a192..4b8b06cd 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: configure,v 1.51 2016/08/10 12:50:24 schwarze Exp $
+# $Id: configure,v 1.52 2016/10/18 16:06:44 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -53,6 +53,7 @@ HAVE_EFTYPE=
HAVE_ENDIAN=
HAVE_ERR=
HAVE_FTS=
+HAVE_FTS_COMPARE_CONST=
HAVE_GETLINE=
HAVE_GETSUBOPT=
HAVE_ISBLANK=
@@ -129,9 +130,9 @@ COMP="${CC} ${CFLAGS} -Wno-unused -Werror"
# If yes, use the override, if no, do not decide anything yet.
# Arguments: lower-case test name, manual value
ismanual() {
- [ -z "${2}" ] && return 1
- echo "${1}: manual (${2})" 1>&2
- echo "${1}: manual (${2})" 1>&3
+ [ -z "${3}" ] && return 1
+ echo "${1}: manual (HAVE_${2}=${3})" 1>&2
+ echo "${1}: manual (HAVE_${2}=${3})" 1>&3
echo 1>&3
return 0
}
@@ -142,27 +143,27 @@ ismanual() {
# Arguments: lower-case test name, upper-case test name, additional CFLAGS
singletest() {
cat 1>&3 << __HEREDOC__
-${1}: testing...
+${1}${3}: testing...
${COMP} ${3} -o test-${1} test-${1}.c
__HEREDOC__
if ${COMP} ${3} -o "test-${1}" "test-${1}.c" 1>&3 2>&3; then
- echo "${1}: ${CC} succeeded" 1>&3
+ echo "${1}${3}: ${CC} succeeded" 1>&3
else
- echo "${1}: ${CC} failed with $?" 1>&3
+ echo "${1}${3}: ${CC} failed with $?" 1>&3
echo 1>&3
return 1
fi
if ./test-${1} 1>&3 2>&3; then
- echo "${1}: yes" 1>&2
- echo "${1}: yes" 1>&3
+ echo "${1}${3}: yes" 1>&2
+ echo "${1}${3}: yes" 1>&3
echo 1>&3
eval HAVE_${2}=1
rm "test-${1}"
return 0
else
- echo "${1}: execution failed with $?" 1>&3
+ echo "${1}${3}: execution failed with $?" 1>&3
echo 1>&3
rm "test-${1}"
return 1
@@ -174,9 +175,9 @@ __HEREDOC__
# Arguments: lower case name, upper case name, additional CFLAGS
runtest() {
eval _manual=\${HAVE_${2}}
- ismanual "${1}" "${_manual}" && return 0
+ ismanual "${1}" "${2}" "${_manual}" && return 0
singletest "${1}" "${2}" "${3}" && return 0
- echo "${1}: no" 1>&2
+ echo "${1}${3}: no" 1>&2
eval HAVE_${2}=0
return 1
}
@@ -184,7 +185,7 @@ runtest() {
# Select a UTF-8 locale.
get_locale() {
[ -n "${HAVE_WCHAR}" ] && [ "${HAVE_WCHAR}" -eq 0 ] && return 0
- ismanual UTF8_LOCALE "$UTF8_LOCALE" && return 0
+ ismanual UTF8_LOCALE UTF_LOCALE "$UTF8_LOCALE" && return 0
echo "UTF8_LOCALE: testing..." 1>&3
UTF8_LOCALE=`locale -a | grep -i '^en_US\.UTF-*8$' | head -n 1`
if [ -z "${UTF8_LOCALE}" ]; then
@@ -204,7 +205,6 @@ runtest be32toh ENDIAN || true
runtest be32toh SYS_ENDIAN -DSYS_ENDIAN || true
runtest EFTYPE EFTYPE || true
runtest err ERR || true
-runtest fts FTS || true
runtest getline GETLINE || true
runtest getsubopt GETSUBOPT || true
runtest isblank ISBLANK || true
@@ -234,6 +234,14 @@ if [ ${HAVE_ENDIAN} -eq 0 -a \
exit 1
fi
+if ismanual fts FTS ${HAVE_FTS}; then
+ HAVE_FTS_COMPARE_CONST=0
+elif runtest fts FTS_COMPARE_CONST -DFTS_COMPARE_CONST; then
+ HAVE_FTS=1
+else
+ runtest fts FTS || true
+fi
+
# --- wide character and locale support ---
if get_locale; then
runtest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true
@@ -258,7 +266,7 @@ if [ "${HAVE_NANOSLEEP}" -eq 0 ]; then
fi
# --- ohash ---
-if ismanual ohash "${HAVE_OHASH}"; then
+if ismanual ohash OHASH "${HAVE_OHASH}"; then
:
elif [ -n "${LD_OHASH}" ]; then
runtest ohash OHASH "${LD_OHASH}" || true
@@ -320,6 +328,7 @@ cat << __HEREDOC__
#define HAVE_ENDIAN ${HAVE_ENDIAN}
#define HAVE_ERR ${HAVE_ERR}
#define HAVE_FTS ${HAVE_FTS}
+#define HAVE_FTS_COMPARE_CONST ${HAVE_FTS_COMPARE_CONST}
#define HAVE_GETLINE ${HAVE_GETLINE}
#define HAVE_GETSUBOPT ${HAVE_GETSUBOPT}
#define HAVE_ISBLANK ${HAVE_ISBLANK}
diff --git a/configure.local.example b/configure.local.example
index 7554fe30..df4f13c4 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -1,4 +1,4 @@
-# $Id: configure.local.example,v 1.20 2016/08/05 23:15:08 schwarze Exp $
+# $Id: configure.local.example,v 1.21 2016/10/18 16:06:44 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -230,7 +230,8 @@ HAVE_DIRENT_NAMLEN=0
HAVE_ENDIAN=0
HAVE_EFTYPE=0
HAVE_ERR=0
-HAVE_FTS=0
+HAVE_FTS=0 # Setting this implies HAVE_FTS_COMPARE_CONST=0.
+HAVE_FTS_COMPARE_CONST=0 # Setting this implies HAVE_FTS=1.
HAVE_GETLINE=0
HAVE_GETSUBOPT=0
HAVE_ISBLANK=0
diff --git a/mandocdb.c b/mandocdb.c
index 7e7ccd90..16bb4c9a 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.231 2016/10/18 14:15:33 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.232 2016/10/18 16:06:44 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -120,7 +120,11 @@ static void dbadd_mlink(const struct mlink *mlink);
static void dbprune(struct dba *);
static void dbwrite(struct dba *);
static void filescan(const char *);
+#if HAVE_FTS_COMPARE_CONST
+static int fts_compare(const FTSENT *const *, const FTSENT *const *);
+#else
static int fts_compare(const FTSENT **, const FTSENT **);
+#endif
static void mlink_add(struct mlink *, const struct stat *);
static void mlink_check(struct mpage *, struct mlink *);
static void mlink_free(struct mlink *);
@@ -547,7 +551,11 @@ usage:
* at the beginning, process directory entries in reverse alpha order.
*/
static int
+#if HAVE_FTS_COMPARE_CONST
+fts_compare(const FTSENT *const *a, const FTSENT *const *b)
+#else
fts_compare(const FTSENT **a, const FTSENT **b)
+#endif
{
return -strcmp((*a)->fts_name, (*b)->fts_name);
}
diff --git a/test-fts.c b/test-fts.c
index dbee5292..23e44152 100644
--- a/test-fts.c
+++ b/test-fts.c
@@ -2,6 +2,13 @@
#include <sys/stat.h>
#include <fts.h>
#include <stdio.h>
+#include <string.h>
+
+#ifdef FTS_COMPARE_CONST
+int fts_compare(const FTSENT *const *, const FTSENT *const *);
+#else
+int fts_compare(const FTSENT **, const FTSENT **);
+#endif
int
main(void)
@@ -14,7 +21,7 @@ main(void)
argv[1] = (char *)NULL;
ftsp = fts_open((char * const *)argv,
- FTS_PHYSICAL | FTS_NOCHDIR, NULL);
+ FTS_PHYSICAL | FTS_NOCHDIR, fts_compare);
if (ftsp == NULL) {
perror("fts_open");
@@ -40,3 +47,13 @@ main(void)
return 0;
}
+
+int
+#ifdef FTS_COMPARE_CONST
+fts_compare(const FTSENT *const *a, const FTSENT *const *b)
+#else
+fts_compare(const FTSENT **a, const FTSENT **b)
+#endif
+{
+ return strcmp((*a)->fts_name, (*b)->fts_name);
+}