[svn:parrot] r47092 - in branches/gsoc_nfg/src: io string string/encoding

darbelo at svn.parrot.org darbelo at svn.parrot.org
Fri May 28 15:25:08 UTC 2010


Author: darbelo
Date: Fri May 28 15:25:07 2010
New Revision: 47092
URL: https://trac.parrot.org/parrot/changeset/47092

Log:
Make sure the new 'extra' member is NULL when unused.
Mark a few places as TODO.

Modified:
   branches/gsoc_nfg/src/io/buffer.c
   branches/gsoc_nfg/src/string/api.c
   branches/gsoc_nfg/src/string/encoding/utf16.c
   branches/gsoc_nfg/src/string/encoding/utf8.c

Modified: branches/gsoc_nfg/src/io/buffer.c
==============================================================================
--- branches/gsoc_nfg/src/io/buffer.c	Fri May 28 15:24:51 2010	(r47091)
+++ branches/gsoc_nfg/src/io/buffer.c	Fri May 28 15:25:07 2010	(r47092)
@@ -467,6 +467,7 @@
     }
     s = *buf;
     s->strlen = 0;
+    s->extra  = NULL;
 
     /* fill empty buffer */
     if (!(buffer_flags & PIO_BF_READBUF)) {

Modified: branches/gsoc_nfg/src/string/api.c
==============================================================================
--- branches/gsoc_nfg/src/string/api.c	Fri May 28 15:24:51 2010	(r47091)
+++ branches/gsoc_nfg/src/string/api.c	Fri May 28 15:25:07 2010	(r47092)
@@ -220,6 +220,7 @@
 
     s->charset  = PARROT_DEFAULT_CHARSET;
     s->encoding = CHARSET_GET_PREFERRED_ENCODING(interp, s);
+    s->extra    = NULL;
 
     Parrot_gc_allocate_string_storage(interp, s,
         (size_t)string_max_bytes(interp, s, capacity));
@@ -550,6 +551,7 @@
     result->strlen          = len;
     result->encoding        = Parrot_fixed_8_encoding_ptr;
     result->charset         = Parrot_binary_charset_ptr;
+    result->extra           = NULL;
 
     Buffer_buflen(buffer)   = 0;
     Buffer_bufstart(buffer) = NULL;
@@ -746,6 +748,7 @@
     STRING * const s = Parrot_gc_new_string_header(interp, flags);
     s->encoding      = encoding;
     s->charset       = charset;
+    s->extra         = NULL;
 
     if (flags & PObj_external_FLAG) {
         /*
@@ -1202,6 +1205,10 @@
     dest->encoding = enc;
     dest->charset  = cs;
 
+    /* TODO: We should merge the grapheme tables here and translate the
+       dynamic graphemes in the second string if needed. */
+    dest->extra    = NULL;
+
     /* Clear COW flag. We own buffer */
     PObj_get_FLAGS(dest) = PObj_is_string_FLAG
                          | PObj_is_COWable_FLAG
@@ -2569,6 +2576,7 @@
     reserved = string_max_bytes(interp, result, srclen);
     Parrot_gc_allocate_string_storage(interp, result, reserved);
     result->bufused = reserved;
+    result->extra = NULL; // TODO: Check wether we'll need a grapheme table here and create one if we will.
 
     src->encoding->iter_init(interp, src, &itersrc);
     encoding->iter_init(interp, result, &iterdest);
@@ -3223,6 +3231,7 @@
 
     res->charset  = j->charset;
     res->encoding = j->encoding;
+    res->extra    = NULL;
 
     /* Iterate over chunks and append it to res */
     pos = res->strstart;
@@ -3232,6 +3241,7 @@
     if (!STRING_IS_NULL(s)) {
         mem_sys_memcopy(pos, s->strstart, s->bufused);
         pos += s->bufused;
+        res->extra = s->extra;
     }
 
     for (i = 1; i < ar_len; ++i) {
@@ -3246,6 +3256,8 @@
         mem_sys_memcopy(pos, next->strstart, next->bufused);
         pos += next->bufused;
 
+        // TODO: Merge grapheme tables as we go. If it's needed.
+
         /* We can consume all buffer and pos will be next-after-end of buffer */
         PARROT_ASSERT(pos <= res->strstart + Buffer_buflen(res) + 1);
     }

Modified: branches/gsoc_nfg/src/string/encoding/utf16.c
==============================================================================
--- branches/gsoc_nfg/src/string/encoding/utf16.c	Fri May 28 15:24:51 2010	(r47091)
+++ branches/gsoc_nfg/src/string/encoding/utf16.c	Fri May 28 15:25:07 2010	(r47092)
@@ -196,6 +196,7 @@
 
     result = Parrot_gc_new_string_header(interp, 0);
 
+    result->extra = NULL;
     /*
      * TODO adapt string creation functions
      */

Modified: branches/gsoc_nfg/src/string/encoding/utf8.c
==============================================================================
--- branches/gsoc_nfg/src/string/encoding/utf8.c	Fri May 28 15:24:51 2010	(r47091)
+++ branches/gsoc_nfg/src/string/encoding/utf8.c	Fri May 28 15:25:07 2010	(r47092)
@@ -528,6 +528,7 @@
     result->charset  = Parrot_unicode_charset_ptr;
     result->encoding = Parrot_utf8_encoding_ptr;
     result->strlen   = src_len;
+    result->extra    = NULL;
 
     if (!src->strlen)
         return result;


More information about the parrot-commits mailing list