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

yamaken at freedesktop.org yamaken at freedesktop.org
Fri Jan 6 21:11:55 PST 2006


Author: yamaken
Date: 2006-01-06 21:11:50 -0800 (Fri, 06 Jan 2006)
New Revision: 2830

Modified:
   branches/r5rs/sigscheme/operations.c
Log:
* sigscheme/operations.c
  - (scm_p_string2number): Fix "" -> 0 to "" -> #f


Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c	2006-01-07 05:00:31 UTC (rev 2829)
+++ branches/r5rs/sigscheme/operations.c	2006-01-07 05:11:50 UTC (rev 2830)
@@ -602,7 +602,9 @@
 scm_p_string2number(ScmObj str, ScmObj args)
 {
     int n, r;
-    char *first_nondigit;
+    char *end;
+    const char *c_str;
+    scm_bool empty_strp;
     DECLARE_FUNCTION("string->number", procedure_variadic_1);
 
     ENSURE_STRING(str);
@@ -630,10 +632,12 @@
      *   #f whenever a decimal point is used.
      */
 
+    c_str = SCM_STRING_STR(str);
     r = prepare_radix(SCM_MANGLE(name), args);
-    n = (int)strtol(SCM_STRING_STR(str), &first_nondigit, r);
+    n = (int)strtol(c_str, &end, r);
 
-    return (*first_nondigit) ? SCM_FALSE : MAKE_INT(n);
+    empty_strp = (end == c_str);  /* apply the first rule above */
+    return (empty_strp || *end) ? SCM_FALSE : MAKE_INT(n);
 }
 
 /*===================================



More information about the uim-commit mailing list