[libxslt] Don't check for standard C89 library functions



commit e9c075cfa8fc441f89131728529f798b85ddeddc
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu Mar 31 01:18:59 2022 +0200

    Don't check for standard C89 library functions

 CMakeLists.txt        | 12 -----------
 config.h.cmake.in     | 36 --------------------------------
 configure.ac          | 16 +++++---------
 libexslt/date.c       | 52 ---------------------------------------------
 libxslt/win32config.h | 58 ---------------------------------------------------
 5 files changed, 5 insertions(+), 169 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50e27bbf..8d9152a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,25 +93,16 @@ else()
                set(CMAKE_REQUIRED_LIBRARIES m)
        endif()
        check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
-       check_function_exists(fabs HAVE_FABS)
-       check_function_exists(floor HAVE_FLOOR)
-       check_function_exists(fprintf HAVE_FPRINTF)
        check_function_exists(ftime HAVE_FTIME)
        check_library_exists(gcrypt gcry_control "gcrypt.h" HAVE_GCRYPT)
        check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
-       check_function_exists(gmtime HAVE_GMTIME)
        check_function_exists(gmtime_r HAVE_GMTIME_R)
        check_include_files(inttypes.h HAVE_INTTYPES_H)
        check_library_exists(pthread pthread_join "" HAVE_LIBPTHREAD)
        check_include_files(locale.h HAVE_LOCALE_H)
-       check_function_exists(localtime HAVE_LOCALTIME)
        check_function_exists(localtime_r HAVE_LOCALTIME_R)
-       check_function_exists(pow HAVE_POW)
-       check_function_exists(printf HAVE_PRINTF)
        check_include_files(pthread.h HAVE_PTHREAD_H)
        check_function_exists(snprintf HAVE_SNPRINTF)
-       check_function_exists(sprintf HAVE_SPRINTF)
-       check_function_exists(sscanf HAVE_SSCANF)
        check_function_exists(stat HAVE_STAT)
        check_function_exists(strxfrm_l HAVE_STRXFRM_L)
        check_include_files(sys/select.h HAVE_SYS_SELECT_H)
@@ -119,11 +110,8 @@ else()
        check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H)
        check_include_files(sys/time.h HAVE_SYS_TIME_H)
        check_include_files(sys/types.h HAVE_SYS_TYPES_H)
-       check_function_exists(time HAVE_TIME)
        check_include_files(unistd.h HAVE_UNISTD_H)
-       check_function_exists(vfprintf HAVE_VFPRINTF)
        check_function_exists(vsnprintf HAVE_VSNPRINTF)
-       check_function_exists(vsprintf HAVE_VSPRINTF)
        check_include_files(xlocale.h HAVE_XLOCALE_H)
        check_function_exists(_stat HAVE__STAT)
        set(LT_OBJDIR ".libs/")
diff --git a/config.h.cmake.in b/config.h.cmake.in
index 2a4de49e..3ae9c96a 100644
--- a/config.h.cmake.in
+++ b/config.h.cmake.in
@@ -4,15 +4,6 @@
 /* Define to 1 if you have the `clock_gettime' function. */
 #cmakedefine HAVE_CLOCK_GETTIME 1
 
-/* Define if fabs is there */
-#cmakedefine HAVE_FABS
-
-/* Define if floor is there */
-#cmakedefine HAVE_FLOOR
-
-/* Define to 1 if you have the `fprintf' function. */
-#cmakedefine HAVE_FPRINTF 1
-
 /* Define to 1 if you have the `ftime' function. */
 #cmakedefine HAVE_FTIME 1
 
@@ -22,9 +13,6 @@
 /* Define to 1 if you have the `gettimeofday' function. */
 #cmakedefine HAVE_GETTIMEOFDAY 1
 
-/* Define to 1 if you have the `gmtime' function. */
-#cmakedefine HAVE_GMTIME 1
-
 /* Define to 1 if you have the `gmtime_r' function. */
 #cmakedefine HAVE_GMTIME_R 1
 
@@ -37,30 +25,15 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #cmakedefine HAVE_LOCALE_H 1
 
-/* Define to 1 if you have the `localtime' function. */
-#cmakedefine HAVE_LOCALTIME 1
-
 /* Define to 1 if you have the `localtime_r' function. */
 #cmakedefine HAVE_LOCALTIME_R 1
 
-/* Define if pow is there */
-#cmakedefine HAVE_POW
-
-/* Define to 1 if you have the `printf' function. */
-#cmakedefine HAVE_PRINTF 1
-
 /* Define if <pthread.h> is there */
 #cmakedefine HAVE_PTHREAD_H
 
 /* Define to 1 if you have the `snprintf' function. */
 #cmakedefine HAVE_SNPRINTF 1
 
-/* Define to 1 if you have the `sprintf' function. */
-#cmakedefine HAVE_SPRINTF 1
-
-/* Define to 1 if you have the `sscanf' function. */
-#cmakedefine HAVE_SSCANF 1
-
 /* Define to 1 if you have the `stat' function. */
 #cmakedefine HAVE_STAT 1
 
@@ -82,21 +55,12 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #cmakedefine HAVE_SYS_TYPES_H 1
 
-/* Define to 1 if you have the `time' function. */
-#cmakedefine HAVE_TIME 1
-
 /* Define to 1 if you have the <unistd.h> header file. */
 #cmakedefine HAVE_UNISTD_H 1
 
-/* Define to 1 if you have the `vfprintf' function. */
-#cmakedefine HAVE_VFPRINTF 1
-
 /* Define to 1 if you have the `vsnprintf' function. */
 #cmakedefine HAVE_VSNPRINTF 1
 
-/* Define to 1 if you have the `vsprintf' function. */
-#cmakedefine HAVE_VSPRINTF 1
-
 /* Define to 1 if you have the <xlocale.h> header file. */
 #cmakedefine HAVE_XLOCALE_H 1
 
diff --git a/configure.ac b/configure.ac
index 51b4da49..e5893838 100644
--- a/configure.ac
+++ b/configure.ac
@@ -137,21 +137,15 @@ dnl
 
 AC_CHECK_HEADERS(sys/timeb.h sys/stat.h sys/select.h)
 AC_CHECK_FUNCS(stat _stat)
-AC_CHECK_FUNC(pow, , AC_CHECK_LIB(m, pow,
-  [M_LIBS="-lm"; AC_DEFINE([HAVE_POW],[], [Define if pow is there])]))
-
-AC_CHECK_FUNC(floor, , AC_CHECK_LIB(m, floor,
-  [M_LIBS="-lm"; AC_DEFINE([HAVE_FLOOR],[], [Define if floor is there])]))
-
-AC_CHECK_FUNC(fabs, , AC_CHECK_LIB(m, fabs,
-  [M_LIBS="-lm"; AC_DEFINE([HAVE_FABS],[], [Define if fabs is there])]))
-
+AC_CHECK_LIB(m, pow, [M_LIBS="-lm"])
+AC_CHECK_LIB(m, floor, [M_LIBS="-lm"])
+AC_CHECK_LIB(m, fabs, [M_LIBS="-lm"])
 
 AC_CHECK_FUNCS(gettimeofday)
-AC_CHECK_FUNCS(localtime localtime_r time gmtime gmtime_r ftime)
+AC_CHECK_FUNCS(localtime_r gmtime_r ftime)
 
 dnl Checking the standard string functions availability
-AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
+AC_CHECK_FUNCS(snprintf vsnprintf,,
                NEED_TRIO=1)
 
 dnl Checking for POSIX timers
diff --git a/libexslt/date.c b/libexslt/date.c
index a16e26b8..60d353d5 100644
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -94,18 +94,6 @@ struct _exsltDateDurVal {
                           0 <= sec < SECS_PER_DAY */
 };
 
-/****************************************************************
- *                                                             *
- *                     Compat./Port. macros                    *
- *                                                             *
- ****************************************************************/
-
-#if (defined(HAVE_LOCALTIME) || defined(HAVE_LOCALTIME_R))     \
-    && (defined(HAVE_GMTIME) || defined(HAVE_GMTIME_R))                \
-    && defined(HAVE_TIME)
-#define WITH_TIME
-#endif
-
 /****************************************************************
  *                                                             *
  *             Convenience macros and functions                *
@@ -721,7 +709,6 @@ exsltDateFreeDuration (exsltDateDurValPtr duration) {
     xmlFree(duration);
 }
 
-#ifdef WITH_TIME
 /**
  * exsltDateCurrent:
  *
@@ -831,7 +818,6 @@ exsltDateCurrent (void)
 
     return ret;
 }
-#endif
 
 /**
  * exsltDateParse:
@@ -1790,7 +1776,6 @@ static xmlChar *
 exsltDateDateTime (void)
 {
     xmlChar *ret = NULL;
-#ifdef WITH_TIME
     exsltDateValPtr cur;
 
     cur = exsltDateCurrent();
@@ -1798,7 +1783,6 @@ exsltDateDateTime (void)
        ret = exsltDateFormatDateTime(cur);
        exsltDateFreeDate(cur);
     }
-#endif
 
     return ret;
 }
@@ -1826,10 +1810,8 @@ exsltDateDate (const xmlChar *dateTime)
     xmlChar *ret = NULL;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return NULL;
     } else {
        dt = exsltDateParse(dateTime);
@@ -1870,10 +1852,8 @@ exsltDateTime (const xmlChar *dateTime)
     xmlChar *ret = NULL;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return NULL;
     } else {
        dt = exsltDateParse(dateTime);
@@ -1919,10 +1899,8 @@ exsltDateYear (const xmlChar *dateTime)
     double ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -1970,9 +1948,7 @@ exsltDateLeapYear (const xmlChar *dateTime)
     xmlXPathObjectPtr ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
-#endif
     } else {
        dt = exsltDateParse(dateTime);
        if ((dt != NULL) &&
@@ -2022,10 +1998,8 @@ exsltDateMonthInYear (const xmlChar *dateTime)
     double ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2171,10 +2145,8 @@ exsltDateWeekInYear (const xmlChar *dateTime)
     long diy, diw, year, ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2239,10 +2211,8 @@ exsltDateWeekInMonth (const xmlChar *dateTime)
     long fdiy, fdiw, ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2293,10 +2263,8 @@ exsltDateDayInYear (const xmlChar *dateTime)
     long ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2342,10 +2310,8 @@ exsltDateDayInMonth (const xmlChar *dateTime)
     double ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2390,10 +2356,8 @@ exsltDateDayOfWeekInMonth (const xmlChar *dateTime)
     long ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2439,10 +2403,8 @@ exsltDateDayInWeek (const xmlChar *dateTime)
     long diy, ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2570,10 +2532,8 @@ exsltDateHourInDay (const xmlChar *dateTime)
     double ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2616,10 +2576,8 @@ exsltDateMinuteInHour (const xmlChar *dateTime)
     double ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2664,10 +2622,8 @@ exsltDateSecondInMinute (const xmlChar *dateTime)
     double ret;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
        dt = exsltDateParse(dateTime);
@@ -2938,10 +2894,8 @@ exsltDateSeconds (const xmlChar *dateTime)
     double ret = xmlXPathNAN;
 
     if (dateTime == NULL) {
-#ifdef WITH_TIME
        dt = exsltDateCurrent();
        if (dt == NULL)
-#endif
            return xmlXPathNAN;
     } else {
         dt = exsltDateParse(dateTime);
@@ -3120,7 +3074,6 @@ exsltDateDuration (const xmlChar *number)
  *                                                             *
  ****************************************************************/
 
-#ifdef WITH_TIME
 /**
  * exsltDateDateTimeFunction:
  * @ctxt: an XPath parser context
@@ -3144,7 +3097,6 @@ exsltDateDateTimeFunction (xmlXPathParserContextPtr ctxt, int nargs)
     else
         xmlXPathReturnString(ctxt, ret);
 }
-#endif
 
 /**
  * exsltDateDateFunction:
@@ -3757,11 +3709,9 @@ exsltDateRegister (void)
     xsltRegisterExtModuleFunction ((const xmlChar *) "date",
                                   (const xmlChar *) EXSLT_DATE_NAMESPACE,
                                   exsltDateDateFunction);
-#ifdef WITH_TIME
     xsltRegisterExtModuleFunction ((const xmlChar *) "date-time",
                                   (const xmlChar *) EXSLT_DATE_NAMESPACE,
                                   exsltDateDateTimeFunction);
-#endif
     xsltRegisterExtModuleFunction ((const xmlChar *) "day-abbreviation",
                                   (const xmlChar *) EXSLT_DATE_NAMESPACE,
                                   exsltDateDayAbbreviationFunction);
@@ -3852,12 +3802,10 @@ exsltDateXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
                                    (const xmlChar *) "date",
                                    (const xmlChar *) EXSLT_DATE_NAMESPACE,
                                    exsltDateDateFunction)
-#ifdef WITH_TIME
         && !xmlXPathRegisterFuncNS(ctxt,
                                    (const xmlChar *) "date-time",
                                    (const xmlChar *) EXSLT_DATE_NAMESPACE,
                                    exsltDateDateTimeFunction)
-#endif
         && !xmlXPathRegisterFuncNS(ctxt,
                                    (const xmlChar *) "day-abbreviation",
                                    (const xmlChar *) EXSLT_DATE_NAMESPACE,
diff --git a/libxslt/win32config.h b/libxslt/win32config.h
index 688983c3..e4c73a60 100644
--- a/libxslt/win32config.h
+++ b/libxslt/win32config.h
@@ -9,67 +9,9 @@
 #ifndef __LIBXSLT_WIN32_CONFIG__
 #define __LIBXSLT_WIN32_CONFIG__
 
-#define HAVE_LOCALTIME 1
-#define HAVE_GMTIME 1
-#define HAVE_TIME 1
 #define HAVE_FCNTL_H 1
 
 #include <io.h>
-
-#define HAVE_ISINF
-#define HAVE_ISNAN
-
-#include <math.h>
-#if defined _MSC_VER || defined __MINGW32__
-/* MS C-runtime has functions which can be used in order to determine if
-   a given floating-point variable contains NaN, (+-)INF. These are
-   preferred, because floating-point technology is considered propriatary
-   by MS and we can assume that their functions know more about their
-   oddities than we do. */
-#include <float.h>
-/* Bjorn Reese figured a quite nice construct for isinf() using the
-   _fpclass() function. */
-#ifndef isinf
-#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
-       : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
-#endif
-/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
-#ifndef isnan
-#define isnan(d) (_isnan(d))
-#endif
-#else /* _MSC_VER */
-static int isinf (double d) {
-    int expon = 0;
-    double val = frexp (d, &expon);
-    if (expon == 1025) {
-        if (val == 0.5) {
-            return 1;
-        } else if (val == -0.5) {
-            return -1;
-        } else {
-            return 0;
-        }
-    } else {
-        return 0;
-    }
-}
-static int isnan (double d) {
-    int expon = 0;
-    double val = frexp (d, &expon);
-    if (expon == 1025) {
-        if (val == 0.5) {
-            return 0;
-        } else if (val == -0.5) {
-            return 0;
-        } else {
-            return 1;
-        }
-    } else {
-        return 0;
-    }
-}
-#endif /* _MSC_VER */
-
 #include <direct.h>
 
 /* snprintf emulation taken from http://stackoverflow.com/a/8712996/1956010 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]