From 03da56a11fd37004cd7d507a8624a0d1ae681ad6 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 18 Jul 2017 17:07:59 +0000 Subject: [PATCH] Issue #182 - string->number fails with #f Per spec, #f should be returned for a conversion failure. Previously certain bases were returning 0 instead. --- runtime.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/runtime.c b/runtime.c index 734fef9f..dcd7406b 100644 --- a/runtime.c +++ b/runtime.c @@ -1892,13 +1892,12 @@ object Cyc_string2number2_(void *data, object cont, int argc, object str, ...) } // If result is mp_zero and str does not contain a 0, then fail -// mp_init(&tmp); -// mp_zero(&tmp); -// if (MP_EQ == mp_cmp(&(bignum_value(bn)), &tmp) && -// // TODO: str does not contain '0' -// ) { -// _return_closcall1(data, cont, boolean_f); -// } + mp_init(&tmp); + mp_zero(&tmp); + if (MP_EQ == mp_cmp(&(bignum_value(bn)), &tmp) && + NULL == strchr(string_str(str), '0')) { + _return_closcall1(data, cont, boolean_f); + } _return_closcall1(data, cont, Cyc_bignum_normalize(data, bn)); } else {