Revision
4554
Author
watson1978@gmail.com
Date
2010-09-28 16:38:57 -0700 (Tue, 28 Sep 2010)

Log Message

Fixed what was not able to handle String including '\0' in Zlib::GzipWriter#comment= and Zlib::GzipWriter#orig_name=.

Modified Paths

Diff

Modified: MacRuby/trunk/ext/zlib/zlib.c (4553 => 4554)


--- MacRuby/trunk/ext/zlib/zlib.c	2010-09-28 22:32:38 UTC (rev 4553)
+++ MacRuby/trunk/ext/zlib/zlib.c	2010-09-28 23:38:57 UTC (rev 4554)
@@ -2379,7 +2379,8 @@
     s = rb_str_dup(rb_str_to_str(str));
     p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s));
     if (p) {
-	rb_str_resize(s, p - RSTRING_PTR(s));
+	long beg = p - RSTRING_PTR(s);
+	rb_str_delete(s, beg, RSTRING_LEN(s) - beg);
     }
     gz->orig_name = s;
     return str;
@@ -2401,7 +2402,8 @@
     s = rb_str_dup(rb_str_to_str(str));
     p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s));
     if (p) {
-	rb_str_resize(s, p - (char*)BSTRING_PTR(s));
+	long beg = p - RSTRING_PTR(s);
+	rb_str_delete(s, beg, RSTRING_LEN(s) - beg);
     }
     gz->comment = s;
     return str;