* mdocml: Compat glue for the FreeBSD comparison function prototype for
@ 2016-10-18 16:07 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2016-10-18 16:07 UTC (permalink / raw)
To: source
Log Message:
-----------
Compat glue for the FreeBSD comparison function prototype for fts_open(3)
which differs from what most other systems use.
While here, improve diagnostic output of ./configure tests.
Modified Files:
--------------
mdocml:
configure
configure.local.example
mandocdb.c
test-fts.c
Revision Data
-------------
Index: configure
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure,v
retrieving revision 1.51
retrieving revision 1.52
diff -Lconfigure -Lconfigure -u -p -r1.51 -r1.52
--- configure
+++ configure
@@ -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 -Werro
# 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}
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.231
retrieving revision 1.232
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.231 -r1.232
--- mandocdb.c
+++ mandocdb.c
@@ -120,7 +120,11 @@ static void dbadd_mlink(const struct ml
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);
}
Index: test-fts.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/test-fts.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Ltest-fts.c -Ltest-fts.c -u -p -r1.3 -r1.4
--- test-fts.c
+++ 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");
@@ -39,4 +46,14 @@ 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);
}
Index: configure.local.example
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure.local.example,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lconfigure.local.example -Lconfigure.local.example -u -p -r1.20 -r1.21
--- configure.local.example
+++ configure.local.example
@@ -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
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-10-18 16:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-18 16:07 mdocml: Compat glue for the FreeBSD comparison function prototype for schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).