1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-10-29 03:49:21 +03:00

Don't check for standard C89 library functions

This commit is contained in:
Nick Wellnhofer
2022-03-31 01:18:59 +02:00
parent dd16508642
commit e9c075cfa8
5 changed files with 5 additions and 169 deletions

View File

@@ -93,25 +93,16 @@ else()
set(CMAKE_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES m)
endif() endif()
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) 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_function_exists(ftime HAVE_FTIME)
check_library_exists(gcrypt gcry_control "gcrypt.h" HAVE_GCRYPT) check_library_exists(gcrypt gcry_control "gcrypt.h" HAVE_GCRYPT)
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists(gmtime HAVE_GMTIME)
check_function_exists(gmtime_r HAVE_GMTIME_R) check_function_exists(gmtime_r HAVE_GMTIME_R)
check_include_files(inttypes.h HAVE_INTTYPES_H) check_include_files(inttypes.h HAVE_INTTYPES_H)
check_library_exists(pthread pthread_join "" HAVE_LIBPTHREAD) check_library_exists(pthread pthread_join "" HAVE_LIBPTHREAD)
check_include_files(locale.h HAVE_LOCALE_H) 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(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_include_files(pthread.h HAVE_PTHREAD_H)
check_function_exists(snprintf HAVE_SNPRINTF) 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(stat HAVE_STAT)
check_function_exists(strxfrm_l HAVE_STRXFRM_L) check_function_exists(strxfrm_l HAVE_STRXFRM_L)
check_include_files(sys/select.h HAVE_SYS_SELECT_H) 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/timeb.h HAVE_SYS_TIMEB_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H) check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_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_include_files(unistd.h HAVE_UNISTD_H)
check_function_exists(vfprintf HAVE_VFPRINTF)
check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(vsnprintf HAVE_VSNPRINTF)
check_function_exists(vsprintf HAVE_VSPRINTF)
check_include_files(xlocale.h HAVE_XLOCALE_H) check_include_files(xlocale.h HAVE_XLOCALE_H)
check_function_exists(_stat HAVE__STAT) check_function_exists(_stat HAVE__STAT)
set(LT_OBJDIR ".libs/") set(LT_OBJDIR ".libs/")

View File

@@ -4,15 +4,6 @@
/* Define to 1 if you have the `clock_gettime' function. */ /* Define to 1 if you have the `clock_gettime' function. */
#cmakedefine HAVE_CLOCK_GETTIME 1 #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. */ /* Define to 1 if you have the `ftime' function. */
#cmakedefine HAVE_FTIME 1 #cmakedefine HAVE_FTIME 1
@@ -22,9 +13,6 @@
/* Define to 1 if you have the `gettimeofday' function. */ /* Define to 1 if you have the `gettimeofday' function. */
#cmakedefine HAVE_GETTIMEOFDAY 1 #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. */ /* Define to 1 if you have the `gmtime_r' function. */
#cmakedefine HAVE_GMTIME_R 1 #cmakedefine HAVE_GMTIME_R 1
@@ -37,30 +25,15 @@
/* Define to 1 if you have the <locale.h> header file. */ /* Define to 1 if you have the <locale.h> header file. */
#cmakedefine HAVE_LOCALE_H 1 #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. */ /* Define to 1 if you have the `localtime_r' function. */
#cmakedefine HAVE_LOCALTIME_R 1 #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 */ /* Define if <pthread.h> is there */
#cmakedefine HAVE_PTHREAD_H #cmakedefine HAVE_PTHREAD_H
/* Define to 1 if you have the `snprintf' function. */ /* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF 1 #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. */ /* Define to 1 if you have the `stat' function. */
#cmakedefine HAVE_STAT 1 #cmakedefine HAVE_STAT 1
@@ -82,21 +55,12 @@
/* Define to 1 if you have the <sys/types.h> header file. */ /* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1 #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. */ /* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1 #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. */ /* Define to 1 if you have the `vsnprintf' function. */
#cmakedefine HAVE_VSNPRINTF 1 #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. */ /* Define to 1 if you have the <xlocale.h> header file. */
#cmakedefine HAVE_XLOCALE_H 1 #cmakedefine HAVE_XLOCALE_H 1

View File

@@ -137,21 +137,15 @@ dnl
AC_CHECK_HEADERS(sys/timeb.h sys/stat.h sys/select.h) AC_CHECK_HEADERS(sys/timeb.h sys/stat.h sys/select.h)
AC_CHECK_FUNCS(stat _stat) AC_CHECK_FUNCS(stat _stat)
AC_CHECK_FUNC(pow, , AC_CHECK_LIB(m, pow, AC_CHECK_LIB(m, pow, [M_LIBS="-lm"])
[M_LIBS="-lm"; AC_DEFINE([HAVE_POW],[], [Define if pow is there])])) AC_CHECK_LIB(m, floor, [M_LIBS="-lm"])
AC_CHECK_LIB(m, fabs, [M_LIBS="-lm"])
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_FUNCS(gettimeofday) 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 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) NEED_TRIO=1)
dnl Checking for POSIX timers dnl Checking for POSIX timers

View File

@@ -94,18 +94,6 @@ struct _exsltDateDurVal {
0 <= sec < SECS_PER_DAY */ 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 * * Convenience macros and functions *
@@ -721,7 +709,6 @@ exsltDateFreeDuration (exsltDateDurValPtr duration) {
xmlFree(duration); xmlFree(duration);
} }
#ifdef WITH_TIME
/** /**
* exsltDateCurrent: * exsltDateCurrent:
* *
@@ -831,7 +818,6 @@ exsltDateCurrent (void)
return ret; return ret;
} }
#endif
/** /**
* exsltDateParse: * exsltDateParse:
@@ -1790,7 +1776,6 @@ static xmlChar *
exsltDateDateTime (void) exsltDateDateTime (void)
{ {
xmlChar *ret = NULL; xmlChar *ret = NULL;
#ifdef WITH_TIME
exsltDateValPtr cur; exsltDateValPtr cur;
cur = exsltDateCurrent(); cur = exsltDateCurrent();
@@ -1798,7 +1783,6 @@ exsltDateDateTime (void)
ret = exsltDateFormatDateTime(cur); ret = exsltDateFormatDateTime(cur);
exsltDateFreeDate(cur); exsltDateFreeDate(cur);
} }
#endif
return ret; return ret;
} }
@@ -1826,10 +1810,8 @@ exsltDateDate (const xmlChar *dateTime)
xmlChar *ret = NULL; xmlChar *ret = NULL;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return NULL; return NULL;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -1870,10 +1852,8 @@ exsltDateTime (const xmlChar *dateTime)
xmlChar *ret = NULL; xmlChar *ret = NULL;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return NULL; return NULL;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -1919,10 +1899,8 @@ exsltDateYear (const xmlChar *dateTime)
double ret; double ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -1970,9 +1948,7 @@ exsltDateLeapYear (const xmlChar *dateTime)
xmlXPathObjectPtr ret; xmlXPathObjectPtr ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
#endif
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if ((dt != NULL) && if ((dt != NULL) &&
@@ -2022,10 +1998,8 @@ exsltDateMonthInYear (const xmlChar *dateTime)
double ret; double ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2171,10 +2145,8 @@ exsltDateWeekInYear (const xmlChar *dateTime)
long diy, diw, year, ret; long diy, diw, year, ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2239,10 +2211,8 @@ exsltDateWeekInMonth (const xmlChar *dateTime)
long fdiy, fdiw, ret; long fdiy, fdiw, ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2293,10 +2263,8 @@ exsltDateDayInYear (const xmlChar *dateTime)
long ret; long ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2342,10 +2310,8 @@ exsltDateDayInMonth (const xmlChar *dateTime)
double ret; double ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2390,10 +2356,8 @@ exsltDateDayOfWeekInMonth (const xmlChar *dateTime)
long ret; long ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2439,10 +2403,8 @@ exsltDateDayInWeek (const xmlChar *dateTime)
long diy, ret; long diy, ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2570,10 +2532,8 @@ exsltDateHourInDay (const xmlChar *dateTime)
double ret; double ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2616,10 +2576,8 @@ exsltDateMinuteInHour (const xmlChar *dateTime)
double ret; double ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2664,10 +2622,8 @@ exsltDateSecondInMinute (const xmlChar *dateTime)
double ret; double ret;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -2938,10 +2894,8 @@ exsltDateSeconds (const xmlChar *dateTime)
double ret = xmlXPathNAN; double ret = xmlXPathNAN;
if (dateTime == NULL) { if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
#endif
return xmlXPathNAN; return xmlXPathNAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
@@ -3120,7 +3074,6 @@ exsltDateDuration (const xmlChar *number)
* * * *
****************************************************************/ ****************************************************************/
#ifdef WITH_TIME
/** /**
* exsltDateDateTimeFunction: * exsltDateDateTimeFunction:
* @ctxt: an XPath parser context * @ctxt: an XPath parser context
@@ -3144,7 +3097,6 @@ exsltDateDateTimeFunction (xmlXPathParserContextPtr ctxt, int nargs)
else else
xmlXPathReturnString(ctxt, ret); xmlXPathReturnString(ctxt, ret);
} }
#endif
/** /**
* exsltDateDateFunction: * exsltDateDateFunction:
@@ -3757,11 +3709,9 @@ exsltDateRegister (void)
xsltRegisterExtModuleFunction ((const xmlChar *) "date", xsltRegisterExtModuleFunction ((const xmlChar *) "date",
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDateFunction); exsltDateDateFunction);
#ifdef WITH_TIME
xsltRegisterExtModuleFunction ((const xmlChar *) "date-time", xsltRegisterExtModuleFunction ((const xmlChar *) "date-time",
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDateTimeFunction); exsltDateDateTimeFunction);
#endif
xsltRegisterExtModuleFunction ((const xmlChar *) "day-abbreviation", xsltRegisterExtModuleFunction ((const xmlChar *) "day-abbreviation",
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDayAbbreviationFunction); exsltDateDayAbbreviationFunction);
@@ -3852,12 +3802,10 @@ exsltDateXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)
(const xmlChar *) "date", (const xmlChar *) "date",
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDateFunction) exsltDateDateFunction)
#ifdef WITH_TIME
&& !xmlXPathRegisterFuncNS(ctxt, && !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "date-time", (const xmlChar *) "date-time",
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,
exsltDateDateTimeFunction) exsltDateDateTimeFunction)
#endif
&& !xmlXPathRegisterFuncNS(ctxt, && !xmlXPathRegisterFuncNS(ctxt,
(const xmlChar *) "day-abbreviation", (const xmlChar *) "day-abbreviation",
(const xmlChar *) EXSLT_DATE_NAMESPACE, (const xmlChar *) EXSLT_DATE_NAMESPACE,

View File

@@ -9,67 +9,9 @@
#ifndef __LIBXSLT_WIN32_CONFIG__ #ifndef __LIBXSLT_WIN32_CONFIG__
#define __LIBXSLT_WIN32_CONFIG__ #define __LIBXSLT_WIN32_CONFIG__
#define HAVE_LOCALTIME 1
#define HAVE_GMTIME 1
#define HAVE_TIME 1
#define HAVE_FCNTL_H 1 #define HAVE_FCNTL_H 1
#include <io.h> #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> #include <direct.h>
/* snprintf emulation taken from http://stackoverflow.com/a/8712996/1956010 */ /* snprintf emulation taken from http://stackoverflow.com/a/8712996/1956010 */