From 0f04b9a9352e708092017959fa880a2ede36862a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 16 Nov 2016 17:29:40 +0000 Subject: [PATCH] WIP string->number error detection --- runtime.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime.c b/runtime.c index 8edaccb5..94e9e3db 100644 --- a/runtime.c +++ b/runtime.c @@ -1694,6 +1694,14 @@ int str2double(double *out, char *s) return 0; } +int str2double_error(char *str, double result) { + //int i, len = strlen(str); + //for (i = 0; i < len; i++) { + // if (!isspace(str[i]) && str[i] != '.' && + //} + return 0; +} + object Cyc_string2number_(void *data, object cont, object str) { int result, rv; @@ -1709,9 +1717,11 @@ object Cyc_string2number_(void *data, object cont, object str) _return_closcall1(data, cont, obj_int2obj(result)); } else { str2double(&n, s); - { + if (n > 0.0L || n < 0.0L || !str2double_error(s, n)) { make_double(result, n); _return_closcall1(data, cont, &result); + } else { + _return_closcall1(data, cont, boolean_f); } } } else {