]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
portability: fix float max check from values.h
authorSami Kerola <kerolasa@iki.fi>
Tue, 23 Aug 2016 18:25:40 +0000 (19:25 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 23 Aug 2016 20:45:06 +0000 (21:45 +0100)
MacOS does not have values.h file.

configure.ac
mtr.c

index 9fceaa9242a900939a667a91d7714b28b972f8cd..5369ec471dc61d8297e9ba56daaf133ea314ae11 100644 (file)
@@ -45,6 +45,7 @@ AC_CHECK_HEADERS([ \
   sys/socket.h \
   sys/types.h \
   sys/xti.h \
+  values.h \
 ])
 
 # Check functions.
diff --git a/mtr.c b/mtr.c
index 3358c4a0d14212bc4a7fcba9bdba5fbdbb6e6e8f..47f5d2a863beecf08d4367d15480aa63231c0414 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -27,7 +27,9 @@
 #include <string.h>
 #include <strings.h>
 #include <error.h>
+#ifdef HAVE_VALUES_H
 #include <values.h>
+#endif
 
 #include <netdb.h>
 #include <netinet/in.h>
@@ -209,8 +211,11 @@ strtofloat_or_err (const char *str, const char *errmesg)
   if (str != NULL && *str != '\0') {
       errno = 0;
       num = strtod (str, &end);
-      if (errno == 0 && str != end && end != NULL && *end == '\0' &&
-          num < FLT_MAX)
+      if (errno == 0 && str != end && end != NULL && *end == '\0'
+#ifdef FLT_MAX
+         && num < FLT_MAX
+#endif
+         )
        return num;
     }
   error (EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);