[gimp] Remove all checks for finite() and isfinite()



commit 4dfcffe4f73a22f4bc87001e24a102a86af91afc
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jan 5 16:36:18 2020 +0100

    Remove all checks for finite() and isfinite()
    
    and simply use isfinite() everywhere, it's part of C99.

 app/core/gimp-transform-resize.c  | 12 +-----------
 app/core/gimpcurve-map.c          | 13 +------------
 app/core/gimpdrawable-transform.c | 11 -----------
 app/pdb/image-cmds.c              | 14 ++------------
 configure.ac                      | 29 -----------------------------
 meson.build                       |  2 --
 pdb/groups/image.pdb              | 16 ++--------------
 7 files changed, 6 insertions(+), 91 deletions(-)
---
diff --git a/app/core/gimp-transform-resize.c b/app/core/gimp-transform-resize.c
index dffc133274..b5a7880299 100644
--- a/app/core/gimp-transform-resize.c
+++ b/app/core/gimp-transform-resize.c
@@ -31,16 +31,6 @@
 #include "gimp-utils.h"
 
 
-#if defined (HAVE_ISFINITE)
-#define FINITE(x) isfinite(x)
-#elif defined (HAVE_FINITE)
-#define FINITE(x) finite(x)
-#elif defined (G_OS_WIN32)
-#define FINITE(x) _finite(x)
-#else
-#error "no FINITE() implementation available?!"
-#endif
-
 #define EPSILON 0.00000001
 
 
@@ -160,7 +150,7 @@ gimp_transform_resize_boundary (const GimpMatrix3   *inv,
 
   /*  check if the transformation matrix is valid at all  */
   for (i = 0; i < n_points && valid; i++)
-    valid = (FINITE (points[i].x) && FINITE (points[i].y));
+    valid = (isfinite (points[i].x) && isfinite (points[i].y));
 
   if (! valid)
     {
diff --git a/app/core/gimpcurve-map.c b/app/core/gimpcurve-map.c
index bd39b27a71..b440c3230f 100644
--- a/app/core/gimpcurve-map.c
+++ b/app/core/gimpcurve-map.c
@@ -30,17 +30,6 @@
 #include "gimpcurve-map.h"
 
 
-#if defined (HAVE_ISFINITE)
-#define FINITE(x) isfinite(x)
-#elif defined (HAVE_FINITE)
-#define FINITE(x) finite(x)
-#elif defined (G_OS_WIN32)
-#define FINITE(x) _finite(x)
-#else
-#error "no FINITE() implementation available?!"
-#endif
-
-
 enum
 {
   CURVE_NONE   = 0,
@@ -216,7 +205,7 @@ gimp_curve_map_value_inline (GimpCurve *curve,
 {
   if (curve->identity)
     {
-      if (FINITE (value))
+      if (isfinite (value))
         return CLAMP (value, 0.0, 1.0);
 
       return 0.0;
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index 386e60c31c..99cc0f5c52 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -51,17 +51,6 @@
 #include "gimp-intl.h"
 
 
-#if defined (HAVE_FINITE)
-#define FINITE(x) finite(x)
-#elif defined (HAVE_ISFINITE)
-#define FINITE(x) isfinite(x)
-#elif defined (G_OS_WIN32)
-#define FINITE(x) _finite(x)
-#else
-#error "no FINITE() implementation available?!"
-#endif
-
-
 /*  public functions  */
 
 GeglBuffer *
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 0daa951d33..1ab6ce4bdc 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -69,16 +69,6 @@
 #include "gimp-intl.h"
 
 
-#if defined (HAVE_ISFINITE)
-#define FINITE(x) isfinite(x)
-#elif defined (HAVE_FINITE)
-#define FINITE(x) finite(x)
-#elif defined (G_OS_WIN32)
-#define FINITE(x) _finite(x)
-#else
-#error "no FINITE() implementation available?!"
-#endif
-
 static GimpValueArray *
 image_id_is_valid_invoker (GimpProcedure         *procedure,
                            Gimp                  *gimp,
@@ -2310,9 +2300,9 @@ image_set_resolution_invoker (GimpProcedure         *procedure,
 
   if (success)
     {
-      if (! FINITE (xresolution) ||
+      if (! isfinite (xresolution) ||
           xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION ||
-          ! FINITE (yresolution) ||
+          ! isfinite (yresolution) ||
           yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
         {
           g_set_error_literal (error, GIMP_PDB_ERROR,
diff --git a/configure.ac b/configure.ac
index 2fe33e64d2..0f82e36b34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1021,35 +1021,6 @@ AC_RUN_IFELSE(
      [AC_MSG_RESULT])],
   [AC_MSG_RESULT()])
 
-# Check for finite
-AC_CHECK_FUNCS(finite, , [
-  AC_MSG_CHECKING(for finite in <math.h>)
-  AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM(
-      [[#include <math.h>]],
-      [[double f = 0.0; finite (f)]])],
-    [AC_DEFINE(HAVE_FINITE, 1)
-     AC_MSG_RESULT(yes)],
-    [AC_MSG_RESULT(no)])
-  ]
-)
-
-# Check for isfinite
-AC_CHECK_FUNCS(isfinite, , [
-  AC_MSG_CHECKING(for isfinite in <math.h>)
-  AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM(
-      [[#include <math.h>]],
-      [[double f = 0.0; isfinite (f)]])],
-    [AC_DEFINE(HAVE_ISFINITE, 1)
-     AC_MSG_RESULT(yes)],
-    [AC_MSG_RESULT(no)])
-  ]
-)
-
-AC_SUBST(HAVE_FINITE)
-AC_SUBST(HAVE_ISFINITE)
-
 LIBS=$gimp_save_LIBS
 
 
diff --git a/meson.build b/meson.build
index d45970e03d..451a7d84be 100644
--- a/meson.build
+++ b/meson.build
@@ -1223,12 +1223,10 @@ foreach fn : [
     { 'm': 'HAVE_ALLOCA',                   'v': 'alloca', },
     { 'm': 'HAVE_DCGETTEXT',                'v': 'dcgettext', },
     { 'm': 'HAVE_DIFFTIME',                 'v': 'difftime', },
-    { 'm': 'HAVE_FINITE',                   'v': 'finite', },
     { 'm': 'HAVE_FSYNC',                    'v': 'fsync', },
     { 'm': 'HAVE_GETADDRINFO',              'v': 'getaddrinfo', },
     { 'm': 'HAVE_GETNAMEINFO',              'v': 'getnameinfo', },
     { 'm': 'HAVE_GETTEXT',                  'v': 'gettext', },
-    { 'm': 'HAVE_ISFINITE',                 'v': 'isfinite', },
     { 'm': 'HAVE_MMAP',                     'v': 'mmap', },
     { 'm': 'HAVE_RINT',                     'v': 'rint', },
     { 'm': 'HAVE_THR_SELF',                 'v': 'thr_self', },
diff --git a/pdb/groups/image.pdb b/pdb/groups/image.pdb
index 08c4a66ed5..bf94632432 100644
--- a/pdb/groups/image.pdb
+++ b/pdb/groups/image.pdb
@@ -2372,9 +2372,9 @@ HELP
     %invoke = (
         code => <<'CODE'
 {
-  if (! FINITE (xresolution) ||
+  if (! isfinite (xresolution) ||
       xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION ||
-      ! FINITE (yresolution) ||
+      ! isfinite (yresolution) ||
       yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
     {
       g_set_error_literal (error, GIMP_PDB_ERROR,
@@ -2887,18 +2887,6 @@ CODE
 }
 
 
-$extra{app}->{code} = <<'CODE';
-#if defined (HAVE_ISFINITE)
-#define FINITE(x) isfinite(x)
-#elif defined (HAVE_FINITE)
-#define FINITE(x) finite(x)
-#elif defined (G_OS_WIN32)
-#define FINITE(x) _finite(x)
-#else
-#error "no FINITE() implementation available?!"
-#endif
-CODE
-
 @headers = qw("libgimpmath/gimpmath.h"
               "libgimpbase/gimpbase.h"
               "gegl/gimp-babl.h"


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