[uim-commit] r2827 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Fri Jan 6 20:17:59 PST 2006


Author: yamaken
Date: 2006-01-06 20:17:51 -0800 (Fri, 06 Jan 2006)
New Revision: 2827

Modified:
   branches/r5rs/sigscheme/operations.c
Log:
* sigscheme/operations.c
  - (scm_p_string2number): Fix non-R5RS compatible error handling


Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c	2006-01-07 04:06:55 UTC (rev 2826)
+++ branches/r5rs/sigscheme/operations.c	2006-01-07 04:17:51 UTC (rev 2827)
@@ -607,12 +607,33 @@
 
     ENSURE_STRING(str);
 
+    /* R5RS:
+     *
+     * - If string is not a syntactically valid notation for a number, then
+     *   `string->number' returns #f.
+     *
+     * - `String->number' is permitted to return #f whenever string contains an
+     *   explicit radix prefix.
+     *
+     * - If all numbers supported by an implementation are real, then
+     *   `string->number' is permitted to return #f whenever string uses the
+     *   polar or rectangular notations for complex numbers.
+     *
+     * - If all numbers are integers, then `string->number' may return #f
+     *   whenever the fractional notation is used.
+     *
+     * - If all numbers are exact, then `string->number' may return #f whenever
+     *   an exponent marker or explicit exactness prefix is used, or if a #
+     *   appears in place of a digit.
+     *
+     * - If all inexact numbers are integers, then `string->number' may return
+     *   #f whenever a decimal point is used.
+     */
+
     r = prepare_radix(SCM_MANGLE(name), args);
     n = (int)strtol(SCM_STRING_STR(str), &first_nondigit, r);
-    if (*first_nondigit)
-        ERR("ill-formatted number: %s", SCM_STRING_STR(str));
 
-    return MAKE_INT(n);
+    return (*first_nondigit) ? SCM_FALSE : MAKE_INT(n);
 }
 
 /*===================================



More information about the uim-commit mailing list