From 6254e4fa987437b1d785cae66122d707c886e144 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Thu, 22 Mar 2012 10:18:33 -0700 Subject: * arith.c (int_flo): If sprintf produces something that doesn't begin with a digit, it's most likely NaN or Inf. We can turn that into an exception. * stream.c (vformat): If sprintf produces a non-number, turn it into the printed representation #<bad-float>. --- arith.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'arith.c') diff --git a/arith.c b/arith.c index c98d0531..6bb82efd 100644 --- a/arith.c +++ b/arith.c @@ -39,6 +39,7 @@ #include <wchar.h> #include <limits.h> #include <math.h> +#include <ctype.h> #include "config.h" #include "lib.h" #include "unwind.h" @@ -1315,6 +1316,11 @@ val int_flo(val f) sprintf(text, "%.64g", d); + if (!isdigit(text[0])) + uw_throwf(error_s, + lit("int-flo: cannot convert #<bad-float> to integer"), + nao); + have_exp = (strchr(text, 'e') != 0); have_point = (strchr(text, '.') != 0); -- cgit v1.2.3