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

darbelo at svn.parrot.org darbelo at svn.parrot.org
Thu Jun 10 21:15:43 UTC 2010


Author: darbelo
Date: Thu Jun 10 21:15:43 2010
New Revision: 47546
URL: https://trac.parrot.org/parrot/changeset/47546

Log:
Make sure we grow the table before merging.

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	Thu Jun 10 21:09:12 2010	(r47545)
+++ branches/gsoc_nfg/src/string/api.c	Thu Jun 10 21:15:43 2010	(r47546)
@@ -364,7 +364,7 @@
     mem_sys_memcopy(result->strstart, s->strstart, alloc_size);
 
 #if PARROT_HAS_ICU
-    if (s->encoding == Parrot_nfg_encoding_ptr && s->extra != NULL)
+    if (s->encoding == Parrot_nfg_encoding_ptr)
         result->extra = clone_grapheme_table(s->extra);
 #endif /* PARROT_HAS_ICU */
 
@@ -499,12 +499,14 @@
 
 #if PARROT_HAS_ICU
     if (enc == Parrot_nfg_encoding_ptr) {
-		if (a->extra != NULL) {
-            dest->extra = clone_grapheme_table(a->extra);
-            if (b->extra != NULL)
+        if (a->extra != NULL) {
+            dest->extra = clone_grapheme_table(interp, a->extra);
+            if (b->extra != NULL) {
+                dest->extra = grow_grapheme_table(interp, a->extra, b->used);
                 merge_tables_and_fixup_string(interp, dest, b->extra, a->strlen);
-		}
-		else {
+            }
+        }
+        else {
             dest->extra = clone_grapheme_table(b->extra);
         }
     }

Modified: branches/gsoc_nfg/src/string/grapheme.c
==============================================================================
--- branches/gsoc_nfg/src/string/grapheme.c	Thu Jun 10 21:09:12 2010	(r47545)
+++ branches/gsoc_nfg/src/string/grapheme.c	Thu Jun 10 21:15:43 2010	(r47546)
@@ -116,6 +116,8 @@
             return (UChar32) (-1 - i);
     }
 
+    PARROT_ASSERT(table->used < table->size);
+
     /* ... and add it if it isn't */
     table->graphemes[i].len = src->len;
     table->graphemes[i].hash = src->hash;


More information about the parrot-commits mailing list