[svn:parrot] r47440 - branches/gsoc_nfg/src/string

darbelo at svn.parrot.org darbelo at svn.parrot.org
Mon Jun 7 23:58:35 UTC 2010


Author: darbelo
Date: Mon Jun  7 23:58:35 2010
New Revision: 47440
URL: https://trac.parrot.org/parrot/changeset/47440

Log:
Clone the grapheme table when cloning the string.

Modified:
   branches/gsoc_nfg/src/string/api.c
   branches/gsoc_nfg/src/string/grapheme.c

Modified: branches/gsoc_nfg/src/string/api.c
==============================================================================
--- branches/gsoc_nfg/src/string/api.c	Mon Jun  7 21:04:53 2010	(r47439)
+++ branches/gsoc_nfg/src/string/api.c	Mon Jun  7 23:58:35 2010	(r47440)
@@ -363,6 +363,9 @@
     /* and copy it over */
     mem_sys_memcopy(result->strstart, s->strstart, alloc_size);
 
+    if (s->encoding == Parrot_nfg_encoding_ptr && s->extra != NULL)
+        result->extra = clone_grapheme_table(s->extra);
+
     return result;
 }
 

Modified: branches/gsoc_nfg/src/string/grapheme.c
==============================================================================
--- branches/gsoc_nfg/src/string/grapheme.c	Mon Jun  7 21:04:53 2010	(r47439)
+++ branches/gsoc_nfg/src/string/grapheme.c	Mon Jun  7 23:58:35 2010	(r47440)
@@ -27,6 +27,17 @@
     return table;
 }
 
+grapheme_table *
+clone_grapheme_table(PARROT_INTERP, grapheme_table *src)
+{
+    grapheme_table * dst = create_grapheme_table(interp, src->used);
+
+    dst->used = src->used;
+    memcpy(&(dst->graphemes), &(dst->graphemes), dst->used * sizeof (grapheme));
+
+    return dst;
+}
+
 UChar32 *
 add_grapheme_from_substr(PARROT_INTERP, grapheme_table *table, STRING *src,
                          UINTVAL start, UINTVAL len, UINTVAL hash)


More information about the parrot-commits mailing list