~ chicken-core (chicken-5) d28e16ab4920a4c587444fa2afba82c219fa79ab
commit d28e16ab4920a4c587444fa2afba82c219fa79ab Author: zbigniew <zbigniewsz@gmail.com> AuthorDate: Thu Jun 23 17:46:16 2011 -0500 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Fri Jun 24 13:28:06 2011 +0200 string->number accepted out-of-range characters for base > 10 diff --git a/runtime.c b/runtime.c index f6e0b934..ab6456b6 100644 --- a/runtime.c +++ b/runtime.c @@ -7347,7 +7347,7 @@ static int from_n_nary(C_char *str, int base, double *r) else if(c >= '0' + base) { if(base < 10) return 0; else if(c < 'a') return 0; - else if(c >= 'a' + base) return 0; + else if(c >= 'a' + base - 10) return 0; else n = n * base + c - 'a' + 10; } else n = n * base + c - '0'; diff --git a/tests/library-tests.scm b/tests/library-tests.scm index a01f2b2f..8aa5441c 100644 --- a/tests/library-tests.scm +++ b/tests/library-tests.scm @@ -69,6 +69,12 @@ '("100000" "1012" "200" "112" "52" "44" "40" "35" "32" "2A" "28" "26" "24" "22" "20"))) +;; string->number conversion + +(assert (= 255 (string->number "ff" 16))) +(assert (not (string->number "fg" 16))) + + ;; fp-math (assert (= (sin 42.0) (fpsin 42.0)))Trap