summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatías Fonzo <selk@dragora.org>2020-01-21 21:56:02 -0300
committerTDE Gitea <gitea@mirror.git.trinitydesktop.org>2020-01-22 23:03:40 +0000
commit8ae17a5d9d77d489a2d16529f16680d31374537e (patch)
treee9637b17830787dcd6fab20ed5ab17486fd7ba60
parentaa9b9581a97daa50855d815b6724b9112448c96f (diff)
downloadtdelibs-8ae17a5d9d77d489a2d16529f16680d31374537e.tar.gz
tdelibs-8ae17a5d9d77d489a2d16529f16680d31374537e.zip
Use the correct macros isnan, isinf for libc compatibility
Changes related to this commit: - Clean up #if mess. - Use unconditionally the correct macros isnan, isinf. - Remove redudant macros from the build system. Signed-off-by: Matías Fonzo <selk@dragora.org>
-rw-r--r--CMakeLists.txt4
-rw-r--r--config.h.cmake12
-rw-r--r--kjs/configure.in.in40
-rw-r--r--kjs/operations.cpp37
4 files changed, 2 insertions, 91 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36a7e80fb..809653a79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -395,10 +395,6 @@ check_function_exists( setgroups HAVE_SETGROUPS )
check_function_exists( setlocale HAVE_SETLOCALE )
check_function_exists( setmntent HAVE_SETMNTENT )
check_function_exists( setpriority HAVE_SETPRIORITY )
-check_function_exists( isnan HAVE_FUNC_ISNAN )
-check_function_exists( _finite HAVE_FUNC__FINITE )
-check_function_exists( finite HAVE_FUNC_FINITE )
-check_function_exists( isinf HAVE_FUNC_ISINF )
check_function_exists( freeaddrinfo HAVE_FREEADDRINFO )
check_function_exists( strtoll HAVE_STRTOLL )
check_function_exists( socket HAVE_SOCKET )
diff --git a/config.h.cmake b/config.h.cmake
index 5ee6f156b..49b689983 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -212,18 +212,6 @@
/* Define to 1 if you have the <fstab.h> header file. */
#cmakedefine HAVE_FSTAB_H 1
-/* Define if you have finite */
-#cmakedefine HAVE_FUNC_FINITE 1
-
-/* Define if you have isinf */
-#cmakedefine HAVE_FUNC_ISINF 1
-
-/* Define if you have isnan */
-#cmakedefine HAVE_FUNC_ISNAN 1
-
-/* Define if you have _finite */
-#cmakedefine HAVE_FUNC__FINITE 1
-
/* Define to 1 if you have the `gai_strerror' function. */
#cmakedefine HAVE_GAI_STRERROR 1
diff --git a/kjs/configure.in.in b/kjs/configure.in.in
index fd23612e0..1c4d3ac52 100644
--- a/kjs/configure.in.in
+++ b/kjs/configure.in.in
@@ -1,46 +1,6 @@
dnl KDE JavaScript specific configure tests
AC_CHECK_HEADERS(ieeefp.h float.h)
-AC_CHECK_LIB(m, finite, [
- AC_DEFINE_UNQUOTED(HAVE_FUNC_FINITE, 1, [Define if you have finite])
-])
-AC_CHECK_LIB(m, _finite, [
- AC_DEFINE_UNQUOTED(HAVE_FUNC__FINITE, 1, [Define if you have _finite])
-])
-
-dnl The C99 standard says that isinf and isnan are macros, but they might
-dnl be functions on some platforms.
-AC_DEFUN([AC_CHECK_ISNAN],
-[
- ac_save_libs="$LIBS"
- LIBS="-lm"
- AC_MSG_CHECKING([for isnan with <math.h>])
- AC_TRY_LINK(
- [#include <math.h>
- float f;], [return isnan(f)],
- [AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_FUNC_ISNAN], [1], [Define if you have isnan])],
- AC_MSG_RESULT(no)
- )
- LIBS="$ac_save_libs"
-])
-AC_DEFUN([AC_CHECK_ISINF],
-[
- ac_save_libs="$LIBS"
- LIBS="-lm"
- AC_MSG_CHECKING([for isinf with <math.h>])
- AC_TRY_LINK(
- [#include <math.h>
- float f;], [return isinf(f)],
- [AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_FUNC_ISINF], [1], [Define if you have isinf])],
- AC_MSG_RESULT(no)
- )
- LIBS="$ac_save_libs"
-])
-
-AC_CHECK_ISNAN
-AC_CHECK_ISINF
AC_DEFUN([AC_CHECK_PCREPOSIX],
[
diff --git a/kjs/operations.cpp b/kjs/operations.cpp
index 63c1e669e..b9314eccb 100644
--- a/kjs/operations.cpp
+++ b/kjs/operations.cpp
@@ -25,7 +25,6 @@
#endif
#ifndef HAVE_FLOAT_H /* just for !Windows */
#define HAVE_FLOAT_H 0
-#define HAVE_FUNC__FINITE 0
#endif
#include <stdio.h>
@@ -38,11 +37,9 @@
#include <sunmath.h>
#endif
-#ifndef HAVE_FUNC_ISINF
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
-#endif /* HAVE_FUNC_ISINF */
#if HAVE_FLOAT_H
#include <float.h>
@@ -55,52 +52,22 @@ using namespace KJS;
bool KJS::isNaN(double d)
{
-#ifdef HAVE_FUNC_ISNAN
return isnan(d);
-#elif defined HAVE_FLOAT_H
- return _isnan(d) != 0;
-#else
- return !(d == d);
-#endif
}
bool KJS::isInf(double d)
{
-#if defined(HAVE_FUNC_ISINF)
return isinf(d);
-#elif HAVE_FUNC_FINITE
- return finite(d) == 0 && d == d;
-#elif HAVE_FUNC__FINITE
- return _finite(d) == 0 && d == d;
-#else
- return false;
-#endif
}
bool KJS::isPosInf(double d)
{
-#if defined(HAVE_FUNC_ISINF)
- return (isinf(d) == 1);
-#elif HAVE_FUNC_FINITE
- return finite(d) == 0 && d == d; // ### can we distinguish between + and - ?
-#elif HAVE_FUNC__FINITE
- return _finite(d) == 0 && d == d; // ###
-#else
- return false;
-#endif
+ return ( isinf(d) && d > 0 );
}
bool KJS::isNegInf(double d)
{
-#if defined(HAVE_FUNC_ISINF)
- return (isinf(d) == -1);
-#elif HAVE_FUNC_FINITE
- return finite(d) == 0 && d == d; // ###
-#elif HAVE_FUNC__FINITE
- return _finite(d) == 0 && d == d; // ###
-#else
- return false;
-#endif
+ return ( isinf(d) && d < 0 );
}
// ECMA 11.9.3