From 19f74a832b0b12a0a78e8fc0ea5af03025ebd9c4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 9 May 2016 15:55:12 +1200 Subject: [PATCH] Rework sys_errlist and sys_nerr configure tests Test for them pairwise, which is simpler and what we actually care about. --- xapian-core/common/errno_to_string.cc | 10 +++---- xapian-core/configure.ac | 55 ++++++++--------------------------- 2 files changed, 17 insertions(+), 48 deletions(-) diff --git a/xapian-core/common/errno_to_string.cc b/xapian-core/common/errno_to_string.cc index 3aca6bb8d..572ffc157 100644 --- a/xapian-core/common/errno_to_string.cc +++ b/xapian-core/common/errno_to_string.cc @@ -1,7 +1,7 @@ /** @file errno_to_string.cc * @brief Convert errno value to std::string, thread-safely if possible */ -/* Copyright (C) 2014,2015 Olly Betts +/* Copyright (C) 2014,2015,2016 Olly Betts * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -29,8 +29,8 @@ #include "safeerrno.h" // doesn't give us strerror_r() with Sun C++ 5.9. #include -#if (HAVE_DECL__SYS_ERRLIST && HAVE_DECL__SYS_NERR) || \ - (HAVE_DECL_SYS_ERRLIST && HAVE_DECL_SYS_NERR) +#if defined HAVE__SYS_ERRLIST_AND__SYS_NERR || \ + defined HAVE_SYS_ERRLIST_AND_SYS_NERR # include // Under mingw, these are in stdlib.h. # include @@ -42,14 +42,14 @@ using namespace std; void errno_to_string(int e, string & s) { -#if HAVE_DECL__SYS_ERRLIST && HAVE_DECL__SYS_NERR +#if defined HAVE__SYS_ERRLIST_AND__SYS_NERR if (e >= 0 && e < _sys_nerr && _sys_errlist[e]) { s += _sys_errlist[e]; } else { s += "Unknown error "; s += str(e); } -#elif HAVE_DECL_SYS_ERRLIST && HAVE_DECL_SYS_NERR +#elif defined HAVE_SYS_ERRLIST_AND_SYS_NERR if (e >= 0 && e < sys_nerr && sys_errlist[e]) { s += sys_errlist[e]; } else { diff --git a/xapian-core/configure.ac b/xapian-core/configure.ac index 80777309d..c1ee87383 100644 --- a/xapian-core/configure.ac +++ b/xapian-core/configure.ac @@ -625,56 +625,25 @@ dnl Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_STRERROR_R -AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [ +AC_CACHE_CHECK([for sys_errlist and sys_nerr], ac_cv_sys_errlist_and_sys_nerr, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], -[[ printf("%s", sys_errlist[0]);]])], - [ ac_cv_libc_defines_sys_errlist="yes" ], - [ ac_cv_libc_defines_sys_errlist="no" - ]) -]) -if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then - AC_DEFINE([HAVE_DECL_SYS_ERRLIST], [1],[Define if your system defines sys_errlist[]]) -else - AC_DEFINE([HAVE_DECL_SYS_ERRLIST], [0],[Define if your system defines sys_errlist[]]) -fi - -AC_CACHE_CHECK([if libc defines _sys_errlist], ac_cv_libc_defines__sys_errlist, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], -[[ printf("%s", _sys_errlist[0]);]])], - [ ac_cv_libc_defines__sys_errlist="yes" ], - [ ac_cv_libc_defines__sys_errlist="no" - ]) +[[ printf("%s", sys_errlist[sys_nerr - 1]);]])], + [ ac_cv_sys_errlist_and_sys_nerr=yes ], + [ ac_cv_sys_errlist_and_sys_nerr=no ]) ]) -if test "x$ac_cv_libc_defines__sys_errlist" = "xyes" ; then - AC_DEFINE([HAVE_DECL__SYS_ERRLIST], [1], [Define if your system defines _sys_errlist[]]) -else - AC_DEFINE([HAVE_DECL__SYS_ERRLIST], [0], [Define if your system defines _sys_errlist[]]) +if test "x$ac_cv_sys_errlist_and_sys_nerr" = "xyes" ; then + AC_DEFINE([HAVE_SYS_ERRLIST_AND_SYS_NERR], [1],[Define if you have 'sys_errlist' and 'sys_nerr']) fi -AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [ +AC_CACHE_CHECK([for _sys_errlist and _sys_nerr], ac_cv__sys_errlist_and__sys_nerr, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], -[[ printf("%i", sys_nerr);]])], - [ ac_cv_libc_defines_sys_nerr="yes" ], - [ ac_cv_libc_defines_sys_nerr="no" +[[ printf("%s", _sys_errlist[_sys_nerr - 1]);]])], + [ ac_cv__sys_errlist_and__sys_nerr=yes ], + [ ac_cv__sys_errlist_and__sys_nerr=no ]) ]) -if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then - AC_DEFINE([HAVE_DECL_SYS_NERR], [1], [Define if your system defines sys_nerr]) -else - AC_DEFINE([HAVE_DECL_SYS_NERR], [0], [Define if your system defines sys_nerr]) -fi - -AC_CACHE_CHECK([if libc defines _sys_nerr], ac_cv_libc_defines__sys_nerr, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], -[[ printf("%i", _sys_nerr);]])], - [ ac_cv_libc_defines__sys_nerr="yes" ], - [ ac_cv_libc_defines__sys_nerr="no" - ]) -]) -if test "x$ac_cv_libc_defines__sys_nerr" = "xyes" ; then - AC_DEFINE([HAVE_DECL__SYS_NERR], [1], [Define if your system defines _sys_nerr]) -else - AC_DEFINE([HAVE_DECL__SYS_NERR], [0], [Define if your system defines _sys_nerr]) +if test "x$ac_cv__sys_errlist_and__sys_nerr" = "xyes" ; then + AC_DEFINE([HAVE__SYS_ERRLIST_AND__SYS_NERR], [1],[Define if you have '_sys_errlist' and '_sys_nerr']) fi dnl Check that snprintf actually works as it's meant to. -- 2.11.4.GIT