changeset 29983:8dfb000624c2

test-strtod: allow compilation without -lm * tests/test-strtod.c (main): Avoid link dependence on fabs. Reported by Dennis Clarke <blastwave@gmail.com>. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Wed, 30 Jul 2008 08:37:31 -0600
parents 0ea6fa49964d
children a15adfcdef07
files ChangeLog tests/test-strtod.c
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jul 28 20:40:23 2008 +0200
+++ b/ChangeLog	Wed Jul 30 08:37:31 2008 -0600
@@ -1,3 +1,9 @@
+2008-07-30  Eric Blake  <ebb9@byu.net>
+
+	test-strtod: allow compilation without -lm
+	* tests/test-strtod.c (main): Avoid link dependence on fabs.
+	Reported by Dennis Clarke <blastwave@gmail.com>.
+
 2008-07-28  Jim Meyering  <meyering@redhat.com>
 
 	bootstrap: work also when there are no .po files in po/
--- a/tests/test-strtod.c	Mon Jul 28 20:40:23 2008 +0200
+++ b/tests/test-strtod.c	Wed Jul 30 08:37:31 2008 -0600
@@ -39,6 +39,9 @@
     }									     \
   while (0)
 
+/* Avoid requiring -lm just for fabs.  */
+#define FABS(d) ((d) < 0.0 ? -(d) : (d))
+
 int
 main ()
 {
@@ -163,7 +166,7 @@
     /* FIXME - gnulib's version is rather inaccurate.  It would be
        nice to guarantee an exact result, but for now, we settle for a
        1-ulp error.  */
-    ASSERT (fabs (result - 0.5) < DBL_EPSILON);
+    ASSERT (FABS (result - 0.5) < DBL_EPSILON);
     ASSERT (ptr == input + 2);
     ASSERT (errno == 0);
   }
@@ -246,7 +249,7 @@
     /* FIXME - gnulib's version is rather inaccurate.  It would be
        nice to guarantee an exact result, but for now, we settle for a
        1-ulp error.  */
-    ASSERT (fabs (result - 0.5) < DBL_EPSILON);
+    ASSERT (FABS (result - 0.5) < DBL_EPSILON);
     ASSERT (ptr == input + 4);
     ASSERT (errno == 0);
   }