develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35576 - trunk/src/pmc

From:
allison
Date:
January 14, 2009 20:00
Subject:
[svn:parrot] r35576 - trunk/src/pmc
Message ID:
20090115040034.639DDCB9AE@x12.develooper.com
Author: allison
Date: Wed Jan 14 20:00:32 2009
New Revision: 35576

Modified:
   trunk/src/pmc/fixedintegerarray.pmc

Log:
[cage] Change the parsing of FixedIntegerArray initialization strings from
poking directly into the guts of a STRING to use a temporary C string.
Partially resolves RT #47011.


Modified: trunk/src/pmc/fixedintegerarray.pmc
==============================================================================
--- trunk/src/pmc/fixedintegerarray.pmc	(original)
+++ trunk/src/pmc/fixedintegerarray.pmc	Wed Jan 14 20:00:32 2009
@@ -59,7 +59,7 @@
     VTABLE PMC *new_from_string(STRING *rep, INTVAL flags) {
         const INTVAL type = SELF->vtable->base_type;
         INTVAL  n, elem, i, l;
-        char   *p, *start;
+        char   *source, *p, *start;
         int     base;
 
         if (flags & PObj_constant_FLAG)
@@ -76,22 +76,28 @@
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_ENCODING,
                     "unhandled string encoding in constructor");
 
+        source = string_to_cstring(interp, rep);
+
         /* "()" - no args */
-        if (l <= 2 && ((char *)rep->strstart)[0] == '(')
+        if (l <= 2 && *source == '(') {
+            string_cstring_free(source);
             return SELF;
+        }
 
         /* count commas */
-        p = rep->strstart;
-        for (i = l, n = 0; i; --i, ++p) {
+        p = source;
+        n = 0;
+        while (*p) {
             if (*p == ',')
                 ++n;
+            p++;
         }
 
         /* presize the array */
         SELF.set_integer_native(n + 1);
 
         /* parse string */
-        p = rep->strstart;
+        p = source;
 
         for (i = l, n = 0; i; --i, ++p) {
             switch (*p) {
@@ -127,6 +133,7 @@
             }
         }
 
+        string_cstring_free(source);
         return SELF;
     }
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About