]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: use appropriate precision when printing float limits
authorPádraig Brady <P@draigBrady.com>
Tue, 18 Jun 2013 14:47:35 +0000 (15:47 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 18 Jun 2013 15:18:56 +0000 (16:18 +0100)
* src/getlimits.c (print_float): Adjust to use the ftoastr module,
which uses the appropriate precision so that no info is lost.
* cfg.mk (sc_prohibit_continued_string_alpha_in_column_1): Exclude od.c
fixes http://bugs.gnu.org/14650

cfg.mk
src/getlimits.c

diff --git a/cfg.mk b/cfg.mk
index 04c8a8a05ede457ff148360584cf0f611e4e9774..7b14c07f139f3aeced701f1135640fbf8da4ab87 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -603,7 +603,7 @@ exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
   ^(src/system\.h|tests/du/2g\.sh)$$
 
 exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
-  ^src/(system\.h|od\.c|printf\.c)$$
+  ^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
 
 exclude_file_name_regexp--sc_prohibit_test_backticks = \
   ^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$
index 7c1fbe26e026283474f09394955964a23bdfb38a..99140255f7f3a7258b4c52c0bee4640f9c257b10 100644 (file)
@@ -21,6 +21,7 @@
 #include <sys/types.h>
 #include <float.h>
 
+#include "ftoastr.h"
 #include "system.h"
 #include "long-options.h"
 
@@ -97,6 +98,19 @@ decimal_absval_add_one (char *buf)
   return result;
 }
 
+#define PRINT_FLOATTYPE(N, T, FTOASTR, BUFSIZE)                         \
+static void                                                             \
+N (T x)                                                                 \
+{                                                                       \
+  char buf[BUFSIZE];                                                    \
+  FTOASTR (buf, sizeof buf, FTOASTR_LEFT_JUSTIFY, 0, x);                \
+  puts (buf);                                                           \
+}
+
+PRINT_FLOATTYPE (print_FLT, float, ftoastr, FLT_BUFSIZE_BOUND)
+PRINT_FLOATTYPE (print_DBL, double, dtoastr, DBL_BUFSIZE_BOUND)
+PRINT_FLOATTYPE (print_LDBL, long double, ldtoastr, LDBL_BUFSIZE_BOUND)
+
 int
 main (int argc, char **argv)
 {
@@ -127,8 +141,8 @@ main (int argc, char **argv)
     }
 
 #define print_float(TYPE)                                                \
-  printf (#TYPE"_MIN=%Le\n", (long double)TYPE##_MIN);                   \
-  printf (#TYPE"_MAX=%Le\n", (long double)TYPE##_MAX);
+  printf (#TYPE"_MIN="); print_##TYPE (TYPE##_MIN);                      \
+  printf (#TYPE"_MAX="); print_##TYPE (TYPE##_MAX);
 
   /* Variable sized ints */
   print_int (CHAR);