[svn:parrot] r39287 - trunk/src/string

bacek at svn.parrot.org bacek at svn.parrot.org
Sun May 31 13:19:41 UTC 2009


Author: bacek
Date: Sun May 31 13:19:40 2009
New Revision: 39287
URL: https://trac.parrot.org/parrot/changeset/39287

Log:
[core] Don't use atod in Parrot_str_to_num on non-single-byte encoded strings. Closes TT#724.

Modified:
   trunk/src/string/api.c

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Sun May 31 11:47:51 2009	(r39286)
+++ trunk/src/string/api.c	Sun May 31 13:19:40 2009	(r39287)
@@ -2142,6 +2142,15 @@
     FLOATVAL    f;
     char       *cstr;
     const char *p;
+    STRING     *tmp;
+
+    /* We can't use cstring for non cstring */
+    if (s->encoding->max_bytes_per_codepoint != 1) {
+        /* Avoid COW. We aren't going to share strings */
+        tmp = Parrot_str_repeat(interp, s, 1);
+        tmp = Parrot_ascii_charset_ptr->to_charset(interp, tmp, NULL);
+        return Parrot_str_to_num(interp, tmp);
+    }
 
     /*
      * XXX C99 atof interprets 0x prefix


More information about the parrot-commits mailing list