[macruby-changes] [3567] MacRuby/branches/icu

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 16 21:10:48 PST 2010


Revision: 3567
          http://trac.macosforge.org/projects/ruby/changeset/3567
Author:   lsansonetti at apple.com
Date:     2010-02-16 21:10:45 -0800 (Tue, 16 Feb 2010)
Log Message:
-----------
some bug fixes

Modified Paths:
--------------
    MacRuby/branches/icu/io.c
    MacRuby/branches/icu/string.c

Modified: MacRuby/branches/icu/io.c
===================================================================
--- MacRuby/branches/icu/io.c	2010-02-17 04:41:33 UTC (rev 3566)
+++ MacRuby/branches/icu/io.c	2010-02-17 05:10:45 UTC (rev 3567)
@@ -985,7 +985,7 @@
     const long original_position = bstr_length(outbuf);
 
     while (true) {
-	bstr_resize(outbuf, BUFSIZE);
+	bstr_resize(outbuf, original_position + bytes_read + BUFSIZE);
 	uint8_t *bytes = bstr_bytes(outbuf) + original_position + bytes_read;
         const long last_read = rb_io_read_internal(io_struct, bytes, BUFSIZE);
         bytes_read += last_read;

Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c	2010-02-17 04:41:33 UTC (rev 3566)
+++ MacRuby/branches/icu/string.c	2010-02-17 05:10:45 UTC (rev 3567)
@@ -242,7 +242,7 @@
 str_replace_with_unichars(rb_str_t *self, const UniChar *chars, long len)
 {
     self->flags = 0;
-    self->encoding = rb_encodings[ENCODING_UTF16_NATIVE];
+    self->encoding = rb_encodings[ENCODING_UTF8];
     self->capacity_in_bytes = self->length_in_bytes = UCHARS_TO_BYTES(len);
     if (self->length_in_bytes != 0) {
 	GC_WB(&self->data.uchars, xmalloc(self->length_in_bytes));
@@ -1496,7 +1496,6 @@
 {
     assert(IS_RSTR(str));
     assert(len < RSTR(str)->capacity_in_bytes);
-    assert(len < RSTR(str)->length_in_bytes);
     RSTR(str)->length_in_bytes = len;
 }
 
@@ -1516,6 +1515,10 @@
 rb_enc_str_new(const char *cstr, long len, rb_encoding_t *enc)
 {
     // XXX should we assert that enc is single byte?
+    if (enc == NULL) {
+	// This function can be called with a NULL encoding. 
+	enc = rb_encodings[ENCODING_BINARY];
+    }
     rb_str_t *str = str_alloc(rb_cRubyString);
     str_replace_with_bytes(str, cstr, len, enc);
     return (VALUE)str;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100216/a67434aa/attachment.html>


More information about the macruby-changes mailing list