[macruby-changes] [189] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue May 6 16:07:12 PDT 2008


Revision: 189
          http://trac.macosforge.org/projects/ruby/changeset/189
Author:   lsansonetti at apple.com
Date:     2008-05-06 16:07:11 -0700 (Tue, 06 May 2008)

Log Message:
-----------
improving perfs, passing more tests, rubygems support wip

Modified Paths:
--------------
    MacRuby/trunk/array.c
    MacRuby/trunk/blockinlining.c
    MacRuby/trunk/dir.c
    MacRuby/trunk/error.c
    MacRuby/trunk/eval.c
    MacRuby/trunk/eval_error.c
    MacRuby/trunk/eval_jump.c
    MacRuby/trunk/ext/syck/rubyext.c
    MacRuby/trunk/include/ruby/encoding.h
    MacRuby/trunk/include/ruby/ruby.h
    MacRuby/trunk/io.c
    MacRuby/trunk/iseq.c
    MacRuby/trunk/load.c
    MacRuby/trunk/marshal.c
    MacRuby/trunk/objc.m
    MacRuby/trunk/object.c
    MacRuby/trunk/pack.c
    MacRuby/trunk/parse.y
    MacRuby/trunk/proc.c
    MacRuby/trunk/process.c
    MacRuby/trunk/range.c
    MacRuby/trunk/re.c
    MacRuby/trunk/string.c
    MacRuby/trunk/test/ruby/test_string.rb

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/array.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -1640,14 +1640,15 @@
 VALUE
 rb_ary_join(VALUE ary, VALUE sep)
 {
-    long len = 1, i;
+    long len = 1, i, count;
     int taint = Qfalse;
     VALUE result, tmp;
 
     if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
     if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue;
-#if !WITH_OBJC
-    /* TODO should use CFStringCreateByCombiningStrings */
+#if WITH_OBJC
+    result = rb_str_buf_new(0);
+#else
     for (i=0; i<RARRAY_LEN(ary); i++) {
 	tmp = rb_check_string_type(RARRAY_AT(ary, i));
 	len += NIL_P(tmp) ? 10 : RSTRING_LEN(tmp);
@@ -1656,10 +1657,10 @@
 	StringValue(sep);
 	len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
     }
+    result = rb_str_buf_new(len);
 #endif
-    result = rb_str_buf_new(len);
 
-    for (i=0; i<RARRAY_LEN(ary); i++) {
+    for (i=0, count=RARRAY_LEN(ary); i<count; i++) {
 	tmp = RARRAY_AT(ary, i);
 	switch (TYPE(tmp)) {
 	  case T_STRING:

Modified: MacRuby/trunk/blockinlining.c
===================================================================
--- MacRuby/trunk/blockinlining.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/blockinlining.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -43,7 +43,7 @@
 				      parent, iseq->type,
 				      GC_GUARDED_PTR(builder));
     if (0) {
-	printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
+	printf("%s\n", RSTRING_CPTR(ruby_iseq_disasm(iseqval)));
     }
     iseq->cached_special_block = iseqval;
     iseq->cached_special_block_builder = builder;

Modified: MacRuby/trunk/dir.c
===================================================================
--- MacRuby/trunk/dir.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/dir.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -386,6 +386,7 @@
 dir_initialize(VALUE dir, VALUE dirname)
 {
     struct dir_data *dp;
+    const char *dirname_cstr;
 
     FilePathValue(dirname);
     Data_Get_Struct(dir, struct dir_data, dp);
@@ -393,17 +394,18 @@
     if (dp->path) free(dp->path);
     dp->dir = NULL;
     dp->path = NULL;
-    dp->dir = opendir(RSTRING_PTR(dirname));
+    dirname_cstr = RSTRING_CPTR(dirname);
+    dp->dir = opendir(dirname_cstr);
     if (dp->dir == NULL) {
 	if (errno == EMFILE || errno == ENFILE) {
 	    rb_gc();
-	    dp->dir = opendir(RSTRING_PTR(dirname));
+	    dp->dir = opendir(dirname_cstr);
 	}
 	if (dp->dir == NULL) {
-	    rb_sys_fail(RSTRING_PTR(dirname));
+	    rb_sys_fail(dirname_cstr);
 	}
     }
-    dp->path = strdup(RSTRING_PTR(dirname));
+    dp->path = strdup(dirname_cstr);
 
     return dir;
 }
@@ -470,6 +472,7 @@
 	int len = strlen(c) + strlen(dirp->path) + 4;
 	VALUE s = rb_str_new(0, len);
 	snprintf(RSTRING_PTR(s), len+1, "#<%s:%s>", c, dirp->path);
+	RSTRING_SYNC(s);
 	return s;
     }
     return rb_funcall(dir, rb_intern("to_s"), 0, 0);
@@ -829,11 +832,11 @@
 static void
 check_dirname(volatile VALUE *dir)
 {
-    char *path, *pend;
+    const char *path, *pend;
 
     rb_secure(2);
     FilePathValue(*dir);
-    path = RSTRING_PTR(*dir);
+    path = RSTRING_CPTR(*dir);
     if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
 	*dir = rb_str_new(path, pend - path);
     }
@@ -852,10 +855,12 @@
 dir_s_chroot(VALUE dir, VALUE path)
 {
 #if defined(HAVE_CHROOT) && !defined(__CHECKER__)
+    const char *path_cstr = RSTRING_CPTR(path);
+
     check_dirname(&path);
 
-    if (chroot(RSTRING_PTR(path)) == -1)
-	rb_sys_fail(RSTRING_PTR(path));
+    if (chroot(path_cstr) == -1)
+	rb_sys_fail(path_cstr);
 
     return INT2FIX(0);
 #else
@@ -882,6 +887,7 @@
 {
     VALUE path, vmode;
     int mode;
+    const char *path_cstr;
 
     if (rb_scan_args(argc, argv, "11", &path, &vmode) == 2) {
 	mode = NUM2INT(vmode);
@@ -891,8 +897,9 @@
     }
 
     check_dirname(&path);
-    if (mkdir(RSTRING_PTR(path), mode) == -1)
-	rb_sys_fail(RSTRING_PTR(path));
+    path_cstr = RSTRING_CPTR(path);
+    if (mkdir(path_cstr, mode) == -1)
+	rb_sys_fail(path_cstr);
 
     return INT2FIX(0);
 }
@@ -909,9 +916,12 @@
 static VALUE
 dir_s_rmdir(VALUE obj, VALUE dir)
 {
+    const char *dir_cstr;
+
     check_dirname(&dir);
-    if (rmdir(RSTRING_PTR(dir)) < 0)
-	rb_sys_fail(RSTRING_PTR(dir));
+    dir_cstr = RSTRING_CPTR(dir);
+    if (rmdir(dir_cstr) < 0)
+	rb_sys_fail(dir_cstr);
 
     return INT2FIX(0);
 }
@@ -1550,23 +1560,27 @@
 static VALUE
 rb_push_glob(VALUE str, int flags) /* '\0' is delimiter */
 {
+    const char *cstr;
+    long clen;
     long offset = 0;
     VALUE ary;
 
     StringValue(str);
     ary = rb_ary_new();
+    cstr = RSTRING_CPTR(str);
+    clen = RSTRING_CLEN(str);
 
-    while (offset < RSTRING_LEN(str)) {
-	int status = push_glob(ary, RSTRING_PTR(str) + offset, flags);
-	char *p, *pend;
+    while (offset < clen) {
+	int status = push_glob(ary, cstr + offset, flags);
+	const char *p, *pend;
 	if (status) GLOB_JUMP_TAG(status);
-	if (offset >= RSTRING_LEN(str)) break;
-	p = RSTRING_PTR(str) + offset;
+	if (offset >= clen) break;
+	p = cstr + offset;
 	p += strlen(p) + 1;
-	pend = RSTRING_PTR(str) + RSTRING_LEN(str);
+	pend = cstr + clen;
 	while (p < pend && !*p)
 	    p++;
-	offset = p - RSTRING_PTR(str);
+	offset = p - cstr;
     }
 
     return ary;
@@ -1582,7 +1596,7 @@
 	int status;
 	VALUE str = argv[i];
 	StringValue(str);
-	status = push_glob(ary, RSTRING_PTR(str), flags);
+	status = push_glob(ary, RSTRING_CPTR(str), flags);
 	if (status) GLOB_JUMP_TAG(status);
     }
 
@@ -1684,7 +1698,7 @@
 	ary = rb_push_glob(str, flags);
     }
     else {
-	volatile VALUE v = ary;
+	VALUE v = ary;
 	ary = dir_globs(RARRAY_LEN(v), RARRAY_PTR(v), flags);
     }
 
@@ -1853,7 +1867,7 @@
     StringValue(pattern);
     FilePathStringValue(path);
 
-    if (fnmatch(RSTRING_PTR(pattern), RSTRING_PTR(path), flags) == 0)
+    if (fnmatch(RSTRING_CPTR(pattern), RSTRING_CPTR(path), flags) == 0)
 	return Qtrue;
 
     return Qfalse;

Modified: MacRuby/trunk/error.c
===================================================================
--- MacRuby/trunk/error.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/error.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -290,7 +290,7 @@
 		    etype = "Symbol";
 		}
 		else if (rb_special_const_p(x)) {
-		    etype = RSTRING_PTR(rb_obj_as_string(x));
+		    etype = RSTRING_CPTR(rb_obj_as_string(x));
 		}
 		else {
 		    etype = rb_obj_classname(x);
@@ -771,7 +771,7 @@
 	    if (NIL_P(d) || RSTRING_LEN(d) > 65) {
 		d = rb_any_to_s(obj);
 	    }
-	    desc = RSTRING_PTR(d);
+	    desc = RSTRING_CPTR(d);
 	    break;
 	}
 	if (desc && desc[0] != '#') {
@@ -814,7 +814,7 @@
 {
     VALUE s = rb_str_inspect(rb_str_new2(str));
 
-    rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
+    rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_CPTR(s));
 }
 
 /* 
@@ -925,7 +925,7 @@
 
 	StringValue(str);
 	mesg = rb_sprintf("%s - %.*s", err,
-			  (int)RSTRING_LEN(str), RSTRING_PTR(str));
+			  (int)RSTRING_CLEN(str), RSTRING_CPTR(str));
     }
     else {
 	mesg = rb_str_new2(err);

Modified: MacRuby/trunk/eval.c
===================================================================
--- MacRuby/trunk/eval.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/eval.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -697,12 +697,12 @@
 	    if (file) {
 		warn_printf("Exception `%s' at %s:%d - %s\n",
 			    rb_obj_classname(th->errinfo),
-			    file, line, RSTRING_PTR(e));
+			    file, line, RSTRING_CPTR(e));
 	    }
 	    else {
 		warn_printf("Exception `%s' - %s\n",
 			    rb_obj_classname(th->errinfo),
-			    RSTRING_PTR(e));
+			    RSTRING_CPTR(e));
 	    }
 	}
 	POP_TAG();
@@ -1650,7 +1650,7 @@
 
     ary = backtrace(-1);
     for (i = 0; i < RARRAY_LEN(ary); i++) {
-	printf("\tfrom %s\n", RSTRING_PTR(RARRAY_AT(ary, i)));
+	printf("\tfrom %s\n", RSTRING_CPTR(RARRAY_AT(ary, i)));
     }
 }
 
@@ -1763,7 +1763,7 @@
 
 	if (0) {		/* for debug */
 	    extern VALUE ruby_iseq_disasm(VALUE);
-	    printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
+	    printf("%s\n", RSTRING_CPTR(ruby_iseq_disasm(iseqval)));
 	}
 
 	/* save new env */
@@ -1857,7 +1857,7 @@
     }
 
     if (!NIL_P(vfile))
-	file = RSTRING_PTR(vfile);
+	file = RSTRING_CPTR(vfile);
     return eval(self, src, scope, file, line);
 }
 

Modified: MacRuby/trunk/eval_error.c
===================================================================
--- MacRuby/trunk/eval_error.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/eval_error.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -10,7 +10,7 @@
     rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
 
     if (cfp) {
-	return RSTRING_PTR(cfp->iseq->filename);
+	return RSTRING_CPTR(cfp->iseq->filename);
     }
     else {
 	return 0;
@@ -123,7 +123,7 @@
 	if (NIL_P(mesg))
 	    error_pos();
 	else {
-	    warn_print2(RSTRING_PTR(mesg), RSTRING_LEN(mesg));
+	    warn_print2(RSTRING_CPTR(mesg), RSTRING_CLEN(mesg));
 	}
     }
 
@@ -131,8 +131,8 @@
     if (EXEC_TAG() == 0) {
 	e = rb_funcall(errinfo, rb_intern("message"), 0, 0);
 	StringValue(e);
-	einfo = RSTRING_PTR(e);
-	elen = RSTRING_LEN(e);
+	einfo = RSTRING_CPTR(e);
+	elen = RSTRING_CLEN(e);
     }
     else {
 	einfo = "";
@@ -149,14 +149,14 @@
 	epath = rb_class_name(eclass);
 	if (elen == 0) {
 	    warn_print(": ");
-	    warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
+	    warn_print2(RSTRING_CPTR(epath), RSTRING_CLEN(epath));
 	    warn_print("\n");
 	}
 	else {
 	    char *tail = 0;
 	    long len = elen;
 
-	    if (RSTRING_PTR(epath)[0] == '#')
+	    if (RSTRING_CPTR(epath)[0] == '#')
 		epath = 0;
 	    if ((tail = memchr(einfo, '\n', elen)) != 0) {
 		len = tail - einfo;
@@ -166,7 +166,7 @@
 	    warn_print2(einfo, len);
 	    if (epath) {
 		warn_print(" (");
-		warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
+		warn_print2(RSTRING_CPTR(epath), RSTRING_CLEN(epath));
 		warn_print(")\n");
 	    }
 	    if (tail) {
@@ -188,7 +188,7 @@
 	for (i = 1; i < len; i++) {
 	    VALUE v = RARRAY_AT(errat, i);
 	    if (TYPE(v) == T_STRING) {
-		warn_printf("\tfrom %s\n", RSTRING_PTR(v));
+		warn_printf("\tfrom %s\n", RSTRING_CPTR(v));
 	    }
 	    if (skip && i == TRACE_HEAD && len > TRACE_MAX) {
 		warn_printf("\t ... %ld levels...\n",

Modified: MacRuby/trunk/eval_jump.c
===================================================================
--- MacRuby/trunk/eval_jump.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/eval_jump.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -36,7 +36,7 @@
     }
     if (!tt) {
 	VALUE desc = rb_inspect(tag);
-	rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc));
+	rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_CPTR(desc));
     }
     rb_trap_restore_mask();
     th->errinfo = NEW_THROW_OBJECT(tag, 0, TAG_THROW);

Modified: MacRuby/trunk/ext/syck/rubyext.c
===================================================================
--- MacRuby/trunk/ext/syck/rubyext.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/ext/syck/rubyext.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -150,8 +150,8 @@
         if (!NIL_P(str2))
         {
             StringValue(str2);
-            len = RSTRING_LEN(str2);
-            memcpy( buf + skip, RSTRING_PTR(str2), len );
+            len = RSTRING_CLEN(str2);
+            memcpy( buf + skip, RSTRING_CPTR(str2), len );
         }
     }
     len += skip;
@@ -171,7 +171,7 @@
     if (!NIL_P(tmp = rb_check_string_type(port))) {
         taint = OBJ_TAINTED(port); /* original taintedness */
         port = tmp;
-        syck_parser_str( parser, RSTRING_PTR(port), RSTRING_LEN(port), NULL );
+        syck_parser_str( parser, RSTRING_CPTR(port), RSTRING_CLEN(port), NULL );
     }
     else if (rb_respond_to(port, s_read)) {
         if (rb_respond_to(port, s_binmode)) {
@@ -1011,10 +1011,10 @@
     VALUE ivname = rb_ary_entry( vars, 0 );
     char *ivn;
     StringValue( ivname );
-    ivn = S_ALLOCA_N( char, RSTRING_LEN(ivname) + 2 );
+    ivn = S_ALLOCA_N( char, RSTRING_CLEN(ivname) + 2 );
     ivn[0] = '@';
     ivn[1] = '\0';
-    strncat( ivn, RSTRING_PTR(ivname), RSTRING_LEN(ivname) );
+    strncat( ivn, RSTRING_CPTR(ivname), RSTRING_CLEN(ivname) );
     rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
     return Qnil;
 }
@@ -1042,12 +1042,12 @@
 VALUE
 syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
 {
-    if (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) 
+    if (NIL_P(type) || RSTRING_CLEN(StringValue(type)) == 0) 
     {
         type = rb_funcall( self, s_detect_implicit, 1, val );
     }
 
-    if ( ! (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) )
+    if ( ! (NIL_P(type) || RSTRING_CLEN(StringValue(type)) == 0) )
     {
         VALUE str_xprivate = rb_str_new2( "x-private" );
         VALUE colon = rb_str_new2( ":" );
@@ -1177,7 +1177,7 @@
 
     if ( !NIL_P(tmp) )
     {
-        char *taguri = syck_type_id_to_uri( RSTRING_PTR(tmp) );
+        char *taguri = syck_type_id_to_uri( RSTRING_CPTR(tmp) );
         val = rb_str_new2( taguri );
         S_FREE( taguri );
     }
@@ -1197,7 +1197,7 @@
     if ( !NIL_P(tmp) )
     {
         val = tmp;
-        type_id = syck_match_implicit( RSTRING_PTR(val), RSTRING_LEN(val) );
+        type_id = syck_match_implicit( RSTRING_CPTR(val), RSTRING_CLEN(val) );
         return rb_str_new2( type_id );
     }
 
@@ -1456,8 +1456,8 @@
     Data_Get_Struct( self, SyckNode, node );
 
     StringValue( val );
-    node->data.str->ptr = syck_strndup( RSTRING_PTR(val), RSTRING_LEN(val) );
-    node->data.str->len = RSTRING_LEN(val);
+    node->data.str->ptr = syck_strndup( RSTRING_CPTR(val), RSTRING_CLEN(val) );
+    node->data.str->len = RSTRING_CLEN(val);
     node->data.str->style = scalar_none;
 
     rb_iv_set( self, "@value", val );
@@ -1716,7 +1716,7 @@
 
     if ( !NIL_P( type_id ) ) {
         StringValue( type_id );
-        node->type_id = syck_strndup( RSTRING_PTR(type_id), RSTRING_LEN(type_id) );
+        node->type_id = syck_strndup( RSTRING_CPTR(type_id), RSTRING_CLEN(type_id) );
     }
 
     rb_iv_set( self, "@type_id", type_id );

Modified: MacRuby/trunk/include/ruby/encoding.h
===================================================================
--- MacRuby/trunk/include/ruby/encoding.h	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/include/ruby/encoding.h	2008-05-06 23:07:11 UTC (rev 189)
@@ -42,7 +42,11 @@
      ENCODING_GET_INLINED(obj) : \
      rb_enc_internal_get_index(obj))
 
-#define ENCODING_IS_ASCII8BIT(obj) (ENCODING_GET_INLINED(obj) == 0)
+#if WITH_OBJC
+# define ENCODING_IS_ASCII8BIT(obj) (1)
+#else
+# define ENCODING_IS_ASCII8BIT(obj) (ENCODING_GET_INLINED(obj) == 0)
+#endif
 
 #define ENCODING_MAXNAMELEN 42
 

Modified: MacRuby/trunk/include/ruby/ruby.h
===================================================================
--- MacRuby/trunk/include/ruby/ruby.h	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/include/ruby/ruby.h	2008-05-06 23:07:11 UTC (rev 189)
@@ -732,12 +732,23 @@
 #define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
 #define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
 
-#define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
-#define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
+#if WITH_OBJC
+# define OBJ_TAINTED(x) (rb_obj_tainted((VALUE)x))
+# define OBJ_TAINT(x)   (rb_obj_taint((VALUE)x))
+#else
+# define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
+# define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
+#endif
+
 #define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
 
-#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
-#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
+#if WITH_OBJC
+# define OBJ_FROZEN(x) (rb_obj_frozen_p((VALUE)x))
+# define OBJ_FREEZE(x) (rb_obj_freeze((VALUE)x))
+#else
+# define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
+# define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
+#endif
 
 #define ALLOC_N(type,n) (type*)xmalloc2((n),sizeof(type))
 #define ALLOC(type) (type*)xmalloc(sizeof(type))

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/io.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -1470,6 +1470,7 @@
         }
     }
     rb_str_resize(str, n);
+    RSTRING_SYNC(str);
 
     if (n == 0)
         return Qnil;
@@ -2999,6 +3000,7 @@
     }
     rb_str_resize(str, n);
     OBJ_TAINT(str);
+    RSTRING_SYNC(str);
 
     return str;
 }

Modified: MacRuby/trunk/iseq.c
===================================================================
--- MacRuby/trunk/iseq.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/iseq.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -49,8 +49,8 @@
     if (ptr) {
 	iseq = ptr;
 	/* It's possible that strings are freed
-         * GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name),
-         *                      RSTRING_PTR(iseq->filename));
+         * GC_INFO("%s @ %s\n", RSTRING_CPTR(iseq->name),
+         *                      RSTRING_CPTR(iseq->filename));
 	 */
 	if (iseq->iseq != iseq->iseq_encoded) {
 	    RUBY_FREE_UNLESS_NULL(iseq->iseq_encoded);
@@ -75,7 +75,7 @@
 
     if (ptr) {
 	iseq = ptr;
-	RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->filename));
+	RUBY_GC_INFO("%s @ %s\n", RSTRING_CPTR(iseq->name), RSTRING_CPTR(iseq->filename));
 	RUBY_MARK_UNLESS_NULL(iseq->mark_ary);
 	RUBY_MARK_UNLESS_NULL(iseq->name);
 	RUBY_MARK_UNLESS_NULL(iseq->filename);
@@ -533,7 +533,7 @@
     rb_iseq_t *iseq = iseq_check(self);
 
     snprintf(buff, sizeof(buff), "<ISeq:%s@%s>",
-	     RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->filename));
+	     RSTRING_CPTR(iseq->name), RSTRING_CPTR(iseq->filename));
 
     return rb_str_new2(buff);
 }
@@ -745,7 +745,7 @@
 	int line_no = find_line_no(iseqdat, pos);
 	int prev = find_prev_line_no(iseqdat, pos);
 	if (line_no && line_no != prev) {
-	    snprintf(buff, sizeof(buff), "%-70s(%4d)", RSTRING_PTR(str),
+	    snprintf(buff, sizeof(buff), "%-70s(%4d)", RSTRING_CPTR(str),
 		     line_no);
 	    str = rb_str_new2(buff);
 	}
@@ -754,7 +754,7 @@
 	/* for debug */
 	struct iseq_insn_info_entry *entry = get_insn_info(iseqdat, pos);
 	snprintf(buff, sizeof(buff), "%-60s(line: %d, sp: %d)",
-		 RSTRING_PTR(str), entry->line_no, entry->sp);
+		 RSTRING_CPTR(str), entry->line_no, entry->sp);
 	str = rb_str_new2(buff);
     }
 
@@ -763,7 +763,7 @@
 	rb_str_concat(ret, str);
     }
     else {
-	printf("%s\n", RSTRING_PTR(str));
+	printf("%s\n", RSTRING_CPTR(str));
     }
     return len;
 }
@@ -814,6 +814,7 @@
     if ((i = RSTRING_LEN(str)) < header_minlen) {
 	rb_str_resize(str, header_minlen);
 	memset(RSTRING_PTR(str) + i, '=', header_minlen - i);
+	RSTRING_SYNC(str);
     }
     rb_str_cat2(str, "\n");
 

Modified: MacRuby/trunk/load.c
===================================================================
--- MacRuby/trunk/load.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/load.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -171,7 +171,7 @@
 
 	    if (ext && *ext) return 0;
 	    bufstr = rb_str_tmp_new(len + DLEXT_MAXLEN);
-	    buf = RSTRING_PTR(bufstr);
+	    buf = RSTRING_PTR(bufstr); /* ok */
 	    MEMCPY(buf, feature, char, len);
 	    for (i = 0; (e = loadable_ext[i]) != 0; i++) {
 		strncpy(buf + len, e, DLEXT_MAXLEN + 1);
@@ -400,7 +400,7 @@
 search_required(VALUE fname, volatile VALUE *path)
 {
     VALUE tmp;
-    char *ext, *ftptr;
+    const char *ext, *ftptr;
     int type, ft = 0;
     const char *loading;
 

Modified: MacRuby/trunk/marshal.c
===================================================================
--- MacRuby/trunk/marshal.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/marshal.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -54,7 +54,7 @@
 #define TYPE_FALSE	'F'
 #define TYPE_FIXNUM	'i'
 
-#define TYPE_EXTENDED	'e'
+#define TYPE_EXTENDED_R	'e'
 #define TYPE_UCLASS	'C'
 #define TYPE_OBJECT	'o'
 #define TYPE_DATA       'd'
@@ -162,7 +162,7 @@
 class2path(VALUE klass)
 {
     VALUE path = rb_class_path(klass);
-    char *n = RSTRING_PTR(path);
+    const char *n = RSTRING_CPTR(path);
 
     if (n[0] == '#') {
 	rb_raise(rb_eTypeError, "can't dump anonymous %s %s",
@@ -417,7 +417,7 @@
     }
     while (BUILTIN_TYPE(klass) == T_ICLASS) {
 	path = rb_class2name(RBASIC(klass)->klass);
-	w_byte(TYPE_EXTENDED, arg);
+	w_byte(TYPE_EXTENDED_R, arg);
 	w_unique(path, arg);
 	klass = RCLASS_SUPER(klass);
     }
@@ -427,7 +427,7 @@
 w_class(char type, VALUE obj, struct dump_arg *arg, int check)
 {
     volatile VALUE p;
-    char *path;
+    const char *path;
     st_data_t real_obj;
     VALUE klass;
 
@@ -438,7 +438,7 @@
     w_extended(klass, arg, check);
     w_byte(type, arg);
     p = class2path(rb_class_real(klass));
-    path = RSTRING_PTR(p);
+    path = RSTRING_CPTR(p);
     w_unique(path, arg);
 }
 
@@ -452,7 +452,7 @@
 #if 0
     if (klass != super) {
 	w_byte(TYPE_UCLASS, arg);
-	w_unique(RSTRING_PTR(class2path(klass)), arg);
+	w_unique(RSTRING_CPTR(class2path(klass)), arg);
     }
 #endif
 }
@@ -620,7 +620,7 @@
 		w_byte(TYPE_IVAR, arg);
 	    }
 	    w_class(TYPE_USERDEF, obj, arg, Qfalse);
-	    w_bytes(RSTRING_PTR(v), RSTRING_LEN(v), arg);
+	    w_bytes(RSTRING_CPTR(v), RSTRING_CLEN(v), arg);
             if (hasiv2) {
 		w_ivar(v, ivtbl2, &c_arg);
             }
@@ -638,7 +638,7 @@
 	    w_byte(TYPE_CLASS, arg);
 	    {
 		volatile VALUE path = class2path(obj);
-		w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
+		w_bytes(RSTRING_CPTR(path), RSTRING_CLEN(path), arg);
 	    }
 	    break;
 
@@ -646,7 +646,7 @@
 	    w_byte(TYPE_MODULE, arg);
 	    {
 		VALUE path = class2path(obj);
-		w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
+		w_bytes(RSTRING_CPTR(path), RSTRING_CLEN(path), arg);
 	    }
 	    break;
 
@@ -685,7 +685,7 @@
 	  case T_STRING:
 	    w_uclass(obj, rb_cString, arg);
 	    w_byte(TYPE_STRING, arg);
-	    w_bytes(RSTRING_PTR(obj), RSTRING_LEN(obj), arg);
+	    w_bytes(RSTRING_CPTR(obj), RSTRING_CLEN(obj), arg);
 	    break;
 
 	  case T_REGEXP:
@@ -917,7 +917,7 @@
 
     if (TYPE(arg->src) == T_STRING) {
 	if (RSTRING_LEN(arg->src) > arg->offset) {
-	    c = (unsigned char)RSTRING_PTR(arg->src)[arg->offset++];
+	    c = (unsigned char)RSTRING_CPTR(arg->src)[arg->offset++];
 	}
 	else {
 	    rb_raise(rb_eArgError, "marshal data too short");
@@ -990,7 +990,7 @@
     if (len == 0) return rb_str_new(0, 0);
     if (TYPE(arg->src) == T_STRING) {
 	if (RSTRING_LEN(arg->src) - arg->offset >= len) {
-	    str = rb_str_new(RSTRING_PTR(arg->src)+arg->offset, len);
+	    str = rb_str_new(RSTRING_CPTR(arg->src)+arg->offset, len);
 	    arg->offset += len;
 	}
 	else {
@@ -1026,7 +1026,7 @@
 r_symreal(struct load_arg *arg)
 {
     volatile VALUE s = r_bytes(arg);
-    ID id = rb_intern(RSTRING_PTR(s));
+    ID id = rb_intern(RSTRING_CPTR(s));
 
     st_insert(arg->symbols, arg->symbols->num_entries, id);
 
@@ -1192,7 +1192,7 @@
 	}
 	break;
 
-      case TYPE_EXTENDED:
+      case TYPE_EXTENDED_R:
 	{
 	    VALUE m = path2module(r_unique(arg));
 
@@ -1255,7 +1255,7 @@
 	{
 	    double d, t = 0.0;
 	    VALUE str = r_bytes(arg);
-	    const char *ptr = RSTRING_PTR(str);
+	    const char *ptr = RSTRING_CPTR(str);
 
 	    if (strcmp(ptr, "nan") == 0) {
 		d = t / t;
@@ -1294,7 +1294,7 @@
             rb_big_resize((VALUE)big, (len + 1) * 2 / sizeof(BDIGIT));
 #endif
             digits = RBIGNUM_DIGITS(big);
-	    MEMCPY(digits, RSTRING_PTR(data), char, len * 2);
+	    MEMCPY(digits, RSTRING_CPTR(data), char, len * 2);
 #if SIZEOF_BDIGITS > SIZEOF_SHORT
 	    MEMZERO((char *)digits + len * 2, char,
 		    RBIGNUM_LEN(big) * sizeof(BDIGIT) - len * 2);
@@ -1497,7 +1497,7 @@
         {
 	    volatile VALUE str = r_bytes(arg);
 
-	    v = rb_path2class(RSTRING_PTR(str));
+	    v = rb_path2class(RSTRING_CPTR(str));
 	    v = r_entry(v, arg);
             v = r_leave(v, arg);
 	}
@@ -1507,7 +1507,7 @@
         {
 	    volatile VALUE str = r_bytes(arg);
 
-	    v = path2class(RSTRING_PTR(str));
+	    v = path2class(RSTRING_CPTR(str));
 	    v = r_entry(v, arg);
             v = r_leave(v, arg);
 	}
@@ -1517,7 +1517,7 @@
         {
 	    volatile VALUE str = r_bytes(arg);
 
-	    v = path2module(RSTRING_PTR(str));
+	    v = path2module(RSTRING_CPTR(str));
 	    v = r_entry(v, arg);
             v = r_leave(v, arg);
 	}

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/objc.m	2008-05-06 23:07:11 UTC (rev 189)
@@ -2120,7 +2120,7 @@
     if (bs_find_path(framework_path, path, sizeof path)) {
 	if (!bs_parse(path, 0, bs_parse_cb, NULL, &error))
 	    rb_raise(rb_eRuntimeError, error);
-#if 0
+#if 1
 	/* FIXME 'GC capability mismatch' with .dylib files */
 	p = strrchr(path, '.');
 	assert(p != NULL);

Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/object.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -682,7 +682,7 @@
 rb_obj_tainted(VALUE obj)
 {
 #if WITH_OBJC
-    if (rb_objc_is_non_native(obj)) {
+    if (!SPECIAL_CONST_P(obj) && rb_objc_is_non_native(obj)) {
 	int type = TYPE(obj);
 	if (type == T_ARRAY)
 	    return rb_ary_tainted(obj);
@@ -693,7 +693,7 @@
 	return Qfalse;
     }
 #endif
-    if (OBJ_TAINTED(obj))
+    if (FL_TEST(obj, FL_TAINT))
 	return Qtrue;
     return Qfalse;
 }
@@ -712,7 +712,7 @@
 {
     rb_secure(4);
 #if WITH_OBJC
-    if (rb_objc_is_non_native(obj)) {
+    if (!SPECIAL_CONST_P(obj) && rb_objc_is_non_native(obj)) {
 	int type = TYPE(obj);
 	if (type == T_ARRAY)
 	    return rb_ary_taint(obj);
@@ -727,7 +727,7 @@
 	if (OBJ_FROZEN(obj)) {
 	    rb_error_frozen("object");
 	}
-	OBJ_TAINT(obj);
+	FL_SET(obj, FL_TAINT);
     }
     return obj;
 }
@@ -745,7 +745,7 @@
 {
     rb_secure(3);
 #if WITH_OBJC
-    if (rb_objc_is_non_native(obj)) {
+    if (!SPECIAL_CONST_P(obj) && rb_objc_is_non_native(obj)) {
 	int type = TYPE(obj);
 	if (type == T_ARRAY)
 	    return rb_ary_untaint(obj);
@@ -797,32 +797,36 @@
 VALUE
 rb_obj_freeze(VALUE obj)
 {
-#if WITH_OBJC
-    if (rb_objc_is_non_native(obj)) {
-	int type = TYPE(obj);
-	if (type == T_ARRAY)
-	    rb_ary_freeze(obj);
-	else if (type == T_HASH)
-	    rb_hash_freeze(obj);
-	else if (type == T_STRING)
-	    rb_str_freeze(obj);
-	else
-	    rb_raise(rb_eRuntimeError, "can't freeze pure objc object `%s'",
-		    RSTRING_PTR(rb_inspect(obj)));
-    }
-#endif
     if (!OBJ_FROZEN(obj)) {
 	if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {
 	    rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
 	}
-	OBJ_FREEZE(obj);
-	if (SPECIAL_CONST_P(obj)) {
+	else if (SPECIAL_CONST_P(obj)) {
 	    if (!immediate_frozen_tbl) {
 		immediate_frozen_tbl = st_init_numtable();
 		GC_ROOT(&immediate_frozen_tbl);
 	    }
 	    st_insert(immediate_frozen_tbl, obj, (st_data_t)Qtrue);
 	}
+#if WITH_OBJC
+	else if (rb_objc_is_non_native(obj)) {
+	    int type = TYPE(obj);
+	    if (type == T_ARRAY)
+		return rb_ary_freeze(obj);
+	    else if (type == T_HASH)
+		return rb_hash_freeze(obj);
+	    else if (type == T_STRING)
+		return rb_str_freeze(obj);
+	    else {
+		if (rb_cString != 0 && rb_cArray != 0 && rb_cHash != 0)
+		    rb_raise(rb_eRuntimeError, "can't freeze pure objc " \
+			     "object `%p'", RSTRING_CPTR(rb_inspect(obj)));
+	    }
+	}
+#endif
+	else {
+	    FL_SET(obj, FL_FREEZE);
+	}
     }
     return obj;
 }
@@ -857,7 +861,7 @@
 	return Qfalse;
     }
 #endif
-    if (OBJ_FROZEN(obj)) return Qtrue;
+    if (FL_TEST(obj, FL_FREEZE)) return Qtrue;
     return Qfalse;
 }
 

Modified: MacRuby/trunk/pack.c
===================================================================
--- MacRuby/trunk/pack.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/pack.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -446,8 +446,8 @@
 #endif
 
     StringValue(fmt);
-    p = RSTRING_PTR(fmt);
-    pend = p + RSTRING_LEN(fmt);
+    p = RSTRING_CPTR(fmt);
+    pend = p + RSTRING_CLEN(fmt);
     res = rb_str_buf_new(0);
 
     items = RARRAY_LEN(ary);
@@ -458,7 +458,7 @@
 #define NEXTFROM (items-- > 0 ? RARRAY_AT(ary, idx++) : TOO_FEW)
 
     while (p < pend) {
-	if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) {
+	if (RSTRING_CPTR(fmt) + RSTRING_CLEN(fmt) != pend) {
 	    rb_raise(rb_eRuntimeError, "format string modified");
 	}
 	type = *p++;		/* get data type */
@@ -508,8 +508,8 @@
 	    }
 	    else {
 		StringValue(from);
-		ptr = RSTRING_PTR(from);
-		plen = RSTRING_LEN(from);
+		ptr = RSTRING_CPTR(from);
+		plen = RSTRING_CLEN(from);
 		OBJ_INFECT(res, from);
 	    }
 
@@ -879,8 +879,8 @@
 	  case 'm':		/* base64 encoded string */
 	    from = NEXTFROM;
 	    StringValue(from);
-	    ptr = RSTRING_PTR(from);
-	    plen = RSTRING_LEN(from);
+	    ptr = RSTRING_CPTR(from);
+	    plen = RSTRING_CLEN(from);
 
 	    if (len <= 2)
 		len = 45;
@@ -1047,8 +1047,8 @@
 {
     char buff[1024];
     long i = 0, n = 0, prev = EOF;
-    unsigned char *s = (unsigned char*)RSTRING_PTR(from);
-    unsigned char *send = s + RSTRING_LEN(from);
+    const unsigned char *s = (unsigned char*)RSTRING_CPTR(from);
+    const unsigned char *send = s + RSTRING_CLEN(from);
 
     while (s < send) {
         if ((*s > 126) ||
@@ -1287,8 +1287,8 @@
 pack_unpack(VALUE str, VALUE fmt)
 {
     static const char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
-    char *s, *send;
-    char *p, *pend;
+    const char *s, *send;
+    const char *p, *pend;
     VALUE ary;
     char type;
     long len;
@@ -1309,10 +1309,10 @@
 
     StringValue(str);
     StringValue(fmt);
-    s = RSTRING_PTR(str);
-    send = s + RSTRING_LEN(str);
-    p = RSTRING_PTR(fmt);
-    pend = p + RSTRING_LEN(fmt);
+    s = RSTRING_CPTR(str);
+    send = s + RSTRING_CLEN(str);
+    p = RSTRING_CPTR(fmt);
+    pend = p + RSTRING_CLEN(fmt);
 
     ary = block_p ? Qnil : rb_ary_new();
     while (p < pend) {
@@ -1365,7 +1365,7 @@
 	    if (len > send - s) len = send - s;
 	    {
 		long end = len;
-		char *t = s + len - 1;
+		const char *t = s + len - 1;
 
 		while (t >= s) {
 		    if (*t != ' ' && *t != '\0') break;
@@ -1378,7 +1378,7 @@
 
 	  case 'Z':
 	    {
-		char *t = s;
+		const char *t = s;
 
 		if (len > send-s) len = send-s;
 		while (t < s+len && *t) t++;
@@ -1411,6 +1411,7 @@
 		    else bits = *s++;
 		    *t++ = (bits & 1) ? '1' : '0';
 		}
+		RSTRING_SYNC(bitstr);
 	    }
 	    break;
 
@@ -1431,6 +1432,7 @@
 		    else bits = *s++;
 		    *t++ = (bits & 128) ? '1' : '0';
 		}
+		RSTRING_SYNC(bitstr);
 	    }
 	    break;
 
@@ -1453,6 +1455,7 @@
 			bits = *s++;
 		    *t++ = hexdigits[bits & 15];
 		}
+		RSTRING_SYNC(bitstr);
 	    }
 	    break;
 
@@ -1475,6 +1478,7 @@
 			bits = *s++;
 		    *t++ = hexdigits[(bits >> 4) & 15];
 		}
+		RSTRING_SYNC(bitstr);
 	    }
 	    break;
 
@@ -1770,6 +1774,7 @@
 
 		rb_str_set_len(buf, total);
 		UNPACK_PUSH(buf);
+		RSTRING_SYNC(buf);
 	    }
 	    break;
 
@@ -1820,6 +1825,7 @@
 		}
 		rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
 		UNPACK_PUSH(buf);
+		RSTRING_SYNC(buf);
 	    }
 	    break;
 
@@ -1848,17 +1854,18 @@
 		}
 		rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
 		UNPACK_PUSH(buf);
+		RSTRING_SYNC(buf);
 	    }
 	    break;
 
 	  case '@':
-	    if (len > RSTRING_LEN(str))
+	    if (len > RSTRING_CLEN(str))
 		rb_raise(rb_eArgError, "@ outside of string");
-	    s = RSTRING_PTR(str) + len;
+	    s = RSTRING_CPTR(str) + len;
 	    break;
 
 	  case 'X':
-	    if (len > s - RSTRING_PTR(str))
+	    if (len > s - RSTRING_CPTR(str))
 		rb_raise(rb_eArgError, "X outside of string");
 	    s -= len;
 	    break;
@@ -1887,7 +1894,7 @@
 		    count = RARRAY_LEN(a);
 		    for (i = 0; i < count; i++) {
 			VALUE p = RARRAY_AT(a, i);
-			if (TYPE(p) == T_STRING && RSTRING_PTR(p) == t) {
+			if (TYPE(p) == T_STRING && RSTRING_CPTR(p) == t) {
 			    if (len < RSTRING_LEN(p)) {
 				tmp = rb_tainted_str_new(t, len);
 				rb_str_associate(tmp, a);
@@ -1910,7 +1917,7 @@
 		    p = RARRAY_PTR(a);
 		    pend = p + RARRAY_LEN(a);
 		    while (p < pend) {
-			if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) {
+			if (TYPE(*p) == T_STRING && RSTRING_CPTR(*p) == t) {
 			    if (len < RSTRING_LEN(*p)) {
 				tmp = rb_tainted_str_new(t, len);
 				rb_str_associate(tmp, a);
@@ -1958,7 +1965,7 @@
 			count = RARRAY_LEN(a);
 			for (i = 0; i < count; i++) {
 			    VALUE p = RARRAY_AT(a, i);
-			    if (TYPE(p) == T_STRING && RSTRING_PTR(p) == t) {
+			    if (TYPE(p) == T_STRING && RSTRING_CPTR(p) == t) {
 				tmp = p;
 				break;
 			    }
@@ -1975,7 +1982,7 @@
 			p = RARRAY_PTR(a);
 			pend = p + RARRAY_LEN(a);
 			while (p < pend) {
-			    if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) {
+			    if (TYPE(*p) == T_STRING && RSTRING_CPTR(*p) == t) {
 				tmp = *p;
 				break;
 			    }

Modified: MacRuby/trunk/parse.y
===================================================================
--- MacRuby/trunk/parse.y	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/parse.y	2008-05-06 23:07:11 UTC (rev 189)
@@ -5015,7 +5015,7 @@
 #ifdef RIPPER
 	    ripper_flush(parser);
 #endif
-	    lex_lastline = v;
+	    lex_lastline =v;
 	}
     }
     c = (unsigned char)*lex_p++;
@@ -5931,9 +5931,9 @@
 {
     VALUE name = 0, val = 0;
     const char *beg, *end, *vbeg, *vend;
-#if 0// WITH_OBJC
+#if WITH_OBJC
 # define str_copy(_s, _p, _n) ((_s) \
-	? CFStringPad((CFMutableStringRef)_s, CFStringCreateWithCString(NULL, _p, kCFStringEncodingUTF8), _n, 0) \
+	? CFStringPad((CFMutableStringRef)_s, CFMakeCollectable(CFStringCreateWithCString(NULL, _p, kCFStringEncodingUTF8)), _n, 0) \
 	: ((_s) = STR_NEW((_p), (_n)))) 
 #else
 # define str_copy(_s, _p, _n) ((_s) \
@@ -6001,13 +6001,13 @@
 	str_copy(name, beg, n);
 #ifndef RIPPER
 	do {
-	    if (STRNCASECMP(p->name, RSTRING_PTR(name), n) == 0) {
+	    if (STRNCASECMP(p->name, RSTRING_CPTR(name), n) == 0) {
 		n = vend - vbeg;
 		if (p->length) {
 		    n = (*p->length)(parser, vbeg, n);
 		}
 		str_copy(val, vbeg, n);
-		(*p->func)(parser, RSTRING_PTR(name), RSTRING_PTR(val));
+		(*p->func)(parser, RSTRING_CPTR(name), RSTRING_CPTR(val));
 		break;
 	    }
 	} while (++p < magic_comments + sizeof(magic_comments) / sizeof(*p));
@@ -6058,7 +6058,7 @@
     beg = str;
     while ((*str == '-' || *str == '_' || ISALNUM(*str)) && ++str < send);
     s = rb_str_new(beg, parser_encode_length(parser, beg, str - beg));
-    parser_set_encode(parser, RSTRING_PTR(s));
+    parser_set_encode(parser, RSTRING_CPTR(s));
     rb_str_resize(s, 0);
 }
 

Modified: MacRuby/trunk/proc.c
===================================================================
--- MacRuby/trunk/proc.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/proc.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -680,7 +680,7 @@
 	    line_no = iseq->insn_info_table[0].line_no;
 	}
 	str = rb_sprintf("#<%s:%p@%s:%d%s>", cname, (void *)self,
-			 RSTRING_PTR(iseq->filename),
+			 RSTRING_CPTR(iseq->filename),
 			 line_no, is_lambda);
     }
     else {

Modified: MacRuby/trunk/process.c
===================================================================
--- MacRuby/trunk/process.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/process.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -1022,7 +1022,7 @@
 
     args = ALLOCA_N(char*, argc+1);
     for (i=0; i<argc; i++) {
-	args[i] = RSTRING_PTR(argv[i]);
+	args[i] = RSTRING_CPTR(argv[i]);
     }
     args[i] = 0;
     if (args[0]) {
@@ -1161,11 +1161,11 @@
 
     args = ALLOCA_N(char*, argc + 1);
     for (i = 0; i < argc; i++) {
-	args[i] = RSTRING_PTR(argv[i]);
+	args[i] = RSTRING_CPTR(argv[i]);
     }
     args[i] = (char*) 0;
     if (args[0])
-	return proc_spawn_v(args, prog ? RSTRING_PTR(prog) : 0);
+	return proc_spawn_v(args, prog ? RSTRING_CPTR(prog) : 0);
     return -1;
 }
 
@@ -1224,14 +1224,14 @@
 	SafeStringValue(prog);
 	StringValueCStr(prog);
 	prog = rb_str_new4(prog);
-	name = RSTRING_PTR(prog);
+	name = RSTRING_CPTR(prog);
     }
     for (i = 0; i < argc; i++) {
 	SafeStringValue(argv[i]);
 	argv[i] = rb_str_new4(argv[i]);
 	StringValueCStr(argv[i]);
     }
-    security(name ? name : RSTRING_PTR(argv[0]));
+    security(name ? name : RSTRING_CPTR(argv[0]));
     return prog;
 }
 
@@ -1273,12 +1273,12 @@
     if (!prog && argc == 1) {
 	e.argc = 0;
 	e.argv = 0;
-	e.prog = RSTRING_PTR(argv[0]);
+	e.prog = RSTRING_CPTR(argv[0]);
     }
     else {
 	e.argc = argc;
 	e.argv = argv;
-	e.prog = prog ? RSTRING_PTR(prog) : 0;
+	e.prog = prog ? RSTRING_CPTR(prog) : 0;
     }
     rb_exec(&e);
     rb_sys_fail(e.prog);
@@ -1727,13 +1727,13 @@
 	struct rb_exec_arg earg;
 	earg.argc = argc;
 	earg.argv = argv;
-	earg.prog = prog ? RSTRING_PTR(prog) : 0;
+	earg.prog = prog ? RSTRING_CPTR(prog) : 0;
 	status = rb_fork(&status, rb_exec_atfork, &earg);
 	if (prog && argc) argv[0] = prog;
     }
 #elif defined HAVE_SPAWNV
     if (!argc) {
-	status = proc_spawn(RSTRING_PTR(prog));
+	status = proc_spawn(RSTRING_CPTR(prog));
     }
     else {
 	status = proc_spawn_n(argc, argv, prog);
@@ -1816,7 +1816,7 @@
     rb_pid_t pid;
 
     pid = rb_spawn(argc, argv);
-    if (pid == -1) rb_sys_fail(RSTRING_PTR(argv[0]));
+    if (pid == -1) rb_sys_fail(RSTRING_CPTR(argv[0]));
 #if defined(HAVE_FORK) || defined(HAVE_SPAWNV)
     return PIDT2NUM(pid);
 #else
@@ -3004,10 +3004,10 @@
 		groups[i] = NUM2GIDT(g);
 	    }
 	    else {
-		gr = getgrnam(RSTRING_PTR(tmp));
+		gr = getgrnam(RSTRING_CPTR(tmp));
 		if (gr == NULL)
 		    rb_raise(rb_eArgError,
-			     "can't find group for %s", RSTRING_PTR(tmp));
+			     "can't find group for %s", RSTRING_CPTR(tmp));
 		groups[i] = gr->gr_gid;
 	    }
 	}

Modified: MacRuby/trunk/range.c
===================================================================
--- MacRuby/trunk/range.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/range.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -748,15 +748,15 @@
 	return Qfalse;
     }
     else if (TYPE(beg) == T_STRING && TYPE(end) == T_STRING &&
-	     RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1) {
+	     RSTRING_CLEN(beg) == 1 && RSTRING_CLEN(end) == 1) {
 	if (NIL_P(val)) return Qfalse;
 	if (TYPE(val) == T_STRING) {
-	    if (RSTRING_LEN(val) == 0 || RSTRING_LEN(val) > 1)
+	    if (RSTRING_CLEN(val) == 0 || RSTRING_CLEN(val) > 1)
 		return Qfalse;
 	    else {
-		char b = RSTRING_PTR(beg)[0];
-		char e = RSTRING_PTR(end)[0];
-		char v = RSTRING_PTR(val)[0];
+		char b = RSTRING_CPTR(beg)[0];
+		char e = RSTRING_CPTR(end)[0];
+		char v = RSTRING_CPTR(val)[0];
 
 		if (ISASCII(b) && ISASCII(e) && ISASCII(v)) {
 		    if (b <= v && v < e) return Qtrue;

Modified: MacRuby/trunk/re.c
===================================================================
--- MacRuby/trunk/re.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/re.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -450,7 +450,7 @@
 {
     VALUE desc = rb_reg_desc(s, len, re);
 
-    rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING_PTR(desc));
+    rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING_CPTR(desc));
 }
 
 static VALUE
@@ -477,7 +477,7 @@
 static VALUE
 rb_reg_error_desc(VALUE str, int options, const char *err)
 {
-    return rb_enc_reg_error_desc(RSTRING_PTR(str), RSTRING_LEN(str),
+    return rb_enc_reg_error_desc(RSTRING_CPTR(str), RSTRING_CLEN(str),
 				 rb_enc_get(str), options, err);
 }
 
@@ -696,7 +696,7 @@
     struct re_registers *regs;
     int num_regs;
     int i, num_pos, c;
-    char *s, *p, *q, *e;
+    const char *s, *p, *q, *e;
     rb_encoding *enc;
     pair_t *pairs;
 
@@ -731,8 +731,8 @@
     }
     qsort(pairs, num_pos, sizeof(pair_t), pair_byte_cmp);
 
-    s = p = RSTRING_PTR(RMATCH(match)->str);
-    e = s + RSTRING_LEN(RMATCH(match)->str);
+    s = p = RSTRING_CPTR(RMATCH(match)->str);
+    e = s + RSTRING_CLEN(RMATCH(match)->str);
     c = 0;
     for (i = 0; i < num_pos; i++) {
         q = s + pairs[i].byte_pos;
@@ -1098,8 +1098,9 @@
             rb_raise(rb_eArgError, "regexp preprocess failed: %s", err);
         }
 
-	r = onig_new(&reg2, (UChar* )RSTRING_PTR(unescaped),
-		     (UChar* )(RSTRING_PTR(unescaped) + RSTRING_LEN(unescaped)),
+	r = onig_new(&reg2, (UChar* )RSTRING_CPTR(unescaped),
+		     (UChar* )(RSTRING_CPTR(unescaped) 
+			 + RSTRING_CLEN(unescaped)),
 		     reg->options, enc,
 		     OnigDefaultSyntax, &einfo);
 	if (r) {
@@ -1132,7 +1133,7 @@
     enc = (RREGEXP(re)->ptr)->enc;
 
     if (pos > 0 && ONIGENC_MBC_MAXLEN(enc) != 1 && pos < RSTRING_LEN(str)) {
-	 string = (UChar*)RSTRING_PTR(str);
+	 string = (UChar*)RSTRING_CPTR(str);
 
 	 if (range > 0) {
 	      p = onigenc_get_right_adjust_char_head(enc, string, string + pos);
@@ -1152,7 +1153,11 @@
     int result;
     VALUE match;
     struct re_registers *pregs;
-    char *range = RSTRING_PTR(str);
+    const char *cstr, *range;
+    long clen;
+
+    cstr = range = RSTRING_CPTR(str);
+    clen = RSTRING_CLEN(str);
 #if WITH_OBJC
     static struct re_registers *regs = NULL;
     if (regs == NULL) {
@@ -1165,7 +1170,7 @@
     pregs = &regs;
 #endif
 
-    if (pos > RSTRING_LEN(str) || pos < 0) {
+    if (pos > clen || pos < 0) {
 	rb_backref_set(Qnil);
 	return -1;
     }
@@ -1173,12 +1178,12 @@
     rb_reg_prepare_re(re, str, 1);
 
     if (!reverse) {
-	range += RSTRING_LEN(str);
+	range += RSTRING_CLEN(str);
     }
     result = onig_search(RREGEXP(re)->ptr,
-			 (UChar*)(RSTRING_PTR(str)),
-			 ((UChar*)(RSTRING_PTR(str)) + RSTRING_LEN(str)),
-			 ((UChar*)(RSTRING_PTR(str)) + pos),
+			 (UChar*)cstr,
+			 ((UChar*)cstr + clen),
+			 ((UChar*)cstr + pos),
 			 ((UChar*)range),
 			 pregs, ONIG_OPTION_NONE);
 
@@ -2065,12 +2070,12 @@
     rb_encoding *fixed_enc = 0;
     onig_errmsg_buffer err = "";
     VALUE buf;
-    char *p, *end;
+    const char *p, *end;
     rb_encoding *enc;
 
     StringValue(str);
-    p = RSTRING_PTR(str);
-    end = p + RSTRING_LEN(str);
+    p = RSTRING_CPTR(str);
+    end = p + RSTRING_CLEN(str);
     enc = rb_enc_get(str);
 
     buf = rb_reg_preprocess(p, end, enc, &fixed_enc, err);
@@ -2106,12 +2111,12 @@
         VALUE str = argv[i];
 #endif
         VALUE buf;
-        char *p, *end;
+        const char *p, *end;
         rb_encoding *src_enc;
 
         StringValue(str);
-        p = RSTRING_PTR(str);
-        end = p + RSTRING_LEN(str);
+        p = RSTRING_CPTR(str);
+        end = p + RSTRING_CLEN(str);
         src_enc = rb_enc_get(str);
 
         buf = rb_reg_preprocess(p, end, src_enc, &fixed_enc, err);
@@ -2185,7 +2190,8 @@
         re->basic.flags |= REG_ENCODING_NONE;
     }
     
-    GC_WB(&re->ptr, make_regexp(RSTRING_PTR(unescaped), RSTRING_LEN(unescaped), enc,
+    GC_WB(&re->ptr, make_regexp(RSTRING_CPTR(unescaped), 
+				RSTRING_CLEN(unescaped), enc,
                                 options & ARG_REG_OPTION_MASK, err));
     if (!re->ptr) return -1;
     GC_WB(&re->str, ALLOC_N(char, len+1));
@@ -2211,7 +2217,7 @@
             enc = ascii8bit;
         }
     }
-    ret = rb_reg_initialize(obj, RSTRING_PTR(str), RSTRING_LEN(str), enc,
+    ret = rb_reg_initialize(obj, RSTRING_CPTR(str), RSTRING_CLEN(str), enc,
 			    options, err);
     RB_GC_GUARD(str);
     return ret;
@@ -2291,7 +2297,7 @@
     volatile VALUE save_str = str;
     if (reg_cache && RREGEXP(reg_cache)->len == RSTRING_LEN(str)
 	&& ENCODING_GET(reg_cache) == ENCODING_GET(str)
-        && memcmp(RREGEXP(reg_cache)->str, RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
+        && memcmp(RREGEXP(reg_cache)->str, RSTRING_CPTR(str), RSTRING_CLEN(str)) == 0)
 	return reg_cache;
 
     return reg_cache = rb_reg_new_str(save_str, 0);

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/string.c	2008-05-06 23:07:11 UTC (rev 189)
@@ -138,7 +138,8 @@
 	n = rb_objc_str_get_struct2(new);
 	memcpy(n, s, sizeof(struct rb_objc_str_struct));
 	if (n->cfdata != NULL) {
-	    GC_WB(&n->cfdata, CFDataCreateMutableCopy(NULL, 0, (CFDataRef)n->cfdata));
+	    GC_WB(&n->cfdata, CFDataCreateMutableCopy(NULL, 0, 
+		(CFDataRef)n->cfdata));
 	    CFMakeCollectable(n->cfdata);
 	}
     }
@@ -501,6 +502,9 @@
 int
 rb_enc_str_coderange(VALUE str)
 {
+#if WITH_OBJC
+    return ENC_CODERANGE_VALID;
+#else
     int cr = ENC_CODERANGE(str);
 
     if (cr == ENC_CODERANGE_UNKNOWN) {
@@ -509,6 +513,7 @@
         ENC_CODERANGE_SET(str, cr);
     }
     return cr;
+#endif
 }
 
 int
@@ -981,20 +986,9 @@
     CFMutableStringRef copy = CFStringCreateMutableCopy(NULL, 0, 
 	(CFStringRef)str);
     CFMakeCollectable(copy);
+    if (OBJ_TAINTED(str)) 
+	OBJ_TAINT(copy);
     return (VALUE)copy;
-#if 0
-    struct rb_objc_str_struct *s = rb_objc_str_get_struct(str);
-    if (s != NULL && s->cfdata != NULL) {
-	rb_str_bytesync(str);
-	if (rb_str_cfdata2(str) != NULL) {
-	    struct rb_objc_str_struct *s2 = rb_objc_str_get_struct2(dup);
-	    CFMutableDataRef data = CFDataCreateMutableCopy(NULL, 0, 
-		    (CFDataRef)s->cfdata);	
-	    GC_WB(&s2->cfdata, data);
-	    CFMakeCollectable(data);
-	}
-    }
-#endif
 #else
     VALUE dup = str_alloc(rb_obj_class(str));
     rb_str_replace(dup, str);
@@ -1221,9 +1215,10 @@
 {
 #if WITH_OBJC
     VALUE str3 = rb_str_new(0, 0);
-    CFStringAppend((CFMutableStringRef)str3, (CFStringRef)str1);
-    CFStringAppend((CFMutableStringRef)str3, (CFStringRef)str2);
-    /* TODO copy taint flag if needed */
+    rb_str_buf_append(str3, str1);
+    rb_str_buf_append(str3, str2);
+    if (OBJ_TAINTED(str1) || OBJ_TAINTED(str2))
+	OBJ_TAINT(str3);
 #else
     VALUE str3;
     rb_encoding *enc;
@@ -1446,10 +1441,16 @@
 const char *
 rb_str_cstr(VALUE ptr)
 {
-    CFDataRef data = (CFDataRef)rb_str_cfdata2(ptr);
-    return data == NULL 
-	? CFStringGetCStringPtr((CFStringRef)ptr, 0) 
-	: (const char *)CFDataGetBytePtr(data);
+    CFDataRef data;
+    const char *cptr;
+   
+    data = (CFDataRef)rb_str_cfdata2(ptr);
+    if (data == NULL) {
+	cptr = CFStringGetCStringPtr((CFStringRef)ptr, 0);
+    	if (cptr == NULL && CFStringGetLength((CFStringRef)ptr) > 0)
+	    data = (CFDataRef)rb_str_cfdata(ptr);
+    }
+    return data == NULL ? cptr : (const char *)CFDataGetBytePtr(data);
 }
 
 long
@@ -2107,7 +2108,7 @@
 rb_str_buf_cat_ascii(VALUE str, const char *ptr)
 {
 #if WITH_OBJC
-    CFStringAppendCString((CFMutableStringRef)str, ptr, kCFStringEncodingASCII);
+    rb_objc_str_cat(str, ptr, strlen(ptr), kCFStringEncodingASCII);
     return str;
 #else
     /* ptr must reference NUL terminated ASCII string. */
@@ -2136,7 +2137,29 @@
 rb_str_buf_append(VALUE str, VALUE str2)
 {
 #if WITH_OBJC
-    CFStringAppend((CFMutableStringRef)str, (CFStringRef)str2);
+    CFMutableDataRef mdata;
+    CFDataRef data;
+
+    if (RSTRING_CLEN(str2) == 0)
+	return str;
+
+    data = (CFDataRef)rb_str_cfdata2(str2);
+    if (data != NULL) {
+	mdata = (CFMutableDataRef)rb_str_cfdata(str);
+	CFDataAppendBytes(mdata, CFDataGetBytePtr(data),
+	    CFDataGetLength(data));
+    }
+    else {
+	mdata = (CFMutableDataRef)rb_str_cfdata2(str);
+	if (mdata == NULL) {
+	    CFStringAppend((CFMutableStringRef)str, (CFStringRef)str2);
+	}
+	else {
+	    data = (CFDataRef)rb_str_cfdata(str2);
+	    CFDataAppendBytes(mdata, CFDataGetBytePtr(data), 
+		CFDataGetLength(data));
+	}
+    }
 #else
     int str2_cr;
 
@@ -3801,11 +3824,9 @@
 #if WITH_OBJC
 	RSTRING_SYNC(str);
 	rb_str_splice_0(str, BEG(0), END(0) - BEG(0), repl);
-	if (rb_obj_tainted(repl))
-	    rb_str_taint(str);
+	if (OBJ_TAINTED(repl)) tainted = 1;
 #else
 	rb_enc_associate(str, enc);
-	if (OBJ_TAINTED(repl)) tainted = 1;
 	if (ENC_CODERANGE_UNKNOWN < cr && cr < ENC_CODERANGE_BROKEN) {
 	    int cr2 = ENC_CODERANGE(repl);
 	    if (cr2 == ENC_CODERANGE_UNKNOWN || cr2 > cr) cr = cr2;
@@ -3824,8 +3845,8 @@
 	STR_SET_LEN(str, RSTRING_LEN(str) + RSTRING_LEN(repl) - plen);
 	RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
 	ENC_CODERANGE_SET(str, cr);
+#endif
 	if (tainted) OBJ_TAINT(str);
-#endif
 
 	return str;
     }
@@ -3880,7 +3901,7 @@
     long beg, n;
     long offset, blen, slen, len;
     int iter = 0;
-    char *sp, *cp;
+    const char *sp, *cp;
     int tainted = 0;
     rb_encoding *str_enc;
     
@@ -3911,8 +3932,8 @@
 
 #if WITH_OBJC
     dest = rb_str_new5(str, NULL, 0);
-    slen = RSTRING_LEN(str);
-    sp = RSTRING_PTR(str);
+    slen = RSTRING_CLEN(str);
+    sp = RSTRING_CPTR(str);
     cp = sp;
 #else
     blen = RSTRING_LEN(str) + 30; /* len + margin */
@@ -6095,12 +6116,17 @@
     long beg, end, i = 0;
     int lim = 0;
     VALUE result, tmp;
+    const char *cstr;
+    long clen;
 
+    cstr = RSTRING_CPTR(str);
+    clen = RSTRING_CLEN(str);
+
     if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) {
 	lim = NUM2INT(limit);
 	if (lim <= 0) limit = Qnil;
 	else if (lim == 1) {
-	    if (RSTRING_LEN(str) == 0)
+	    if (clen == 0)
 		return rb_ary_new2(0);
 	    return rb_ary_new3(1, str);
 	}
@@ -6127,16 +6153,21 @@
 #else
 	    rb_encoding *enc2 = STR_ENC_GET(spat);
 #endif
+	    const char *spat_cstr;
+	    long spat_clen;
 
+	    spat_cstr = RSTRING_CPTR(spat);
+	    spat_clen = RSTRING_CLEN(spat);
+
 	    if (rb_enc_mbminlen(enc2) == 1) {
-		if (RSTRING_LEN(spat) == 1 && RSTRING_PTR(spat)[0] == ' '){
+		if (spat_clen == 1 && spat_cstr[0] == ' '){
 		awk_split = Qtrue;
 	    }
 	    }
 	    else {
 		int l;
-		if (rb_enc_ascget(RSTRING_PTR(spat), RSTRING_END(spat), &l, enc2) == ' ' &&
-		    RSTRING_LEN(spat) == l) {
+		if (rb_enc_ascget(spat_cstr, spat_cstr+spat_clen, &l, enc2) == ' ' &&
+		    spat_clen == l) {
 		    awk_split = Qtrue;
 		}
 	    }
@@ -6152,9 +6183,9 @@
     result = rb_ary_new();
     beg = 0;
     if (awk_split) {
-	char *ptr = RSTRING_PTR(str);
-	char *eptr = RSTRING_END(str);
-	char *bptr = ptr;
+	const char *ptr = cstr;
+	const char *eptr = cstr+clen;
+	const char *bptr = ptr;
 	int skip = 1;
 	int c;
 
@@ -6194,22 +6225,22 @@
 	while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
 	    regs = RMATCH_REGS(rb_backref_get());
 	    if (start == end && BEG(0) == END(0)) {
-		if (!RSTRING_PTR(str)) {
-		    rb_ary_push(result, rb_str_new("", 0));
+		if (!cstr) {
+		    //rb_ary_push(result, rb_str_new("", 0));
 		    break;
 		}
 		else if (last_null == 1) {
 		    rb_ary_push(result, rb_str_subseq(str, beg,
-						      rb_enc_mbclen(RSTRING_PTR(str)+beg,
-								    RSTRING_END(str),
+						      rb_enc_mbclen(cstr+beg,
+								    cstr+clen,
 								    enc)));
 		    beg = start;
 		}
 		else {
-                    if (RSTRING_PTR(str)+start == RSTRING_END(str))
+                    if (cstr+start == cstr+clen)
                         start++;
                     else
-                        start += rb_enc_mbclen(RSTRING_PTR(str)+start,RSTRING_END(str),enc);
+                        start += rb_enc_mbclen(cstr+start,cstr+clen,enc);
 		    last_null = 1;
 		    continue;
 		}
@@ -6231,16 +6262,16 @@
 	    if (!NIL_P(limit) && lim <= ++i) break;
 	}
     }
-    if (RSTRING_LEN(str) > 0 && (!NIL_P(limit) || RSTRING_LEN(str) > beg || lim < 0)) {
-	if (RSTRING_LEN(str) == beg)
+    if (clen > 0 && (!NIL_P(limit) || clen > beg || lim < 0)) {
+	if (clen == beg)
 	    tmp = rb_str_new5(str, 0, 0);
 	else
-	    tmp = rb_str_subseq(str, beg, RSTRING_LEN(str)-beg);
+	    tmp = rb_str_subseq(str, beg, clen-beg);
 	rb_ary_push(result, tmp);
     }
     if (NIL_P(limit) && lim == 0) {
 	while (RARRAY_LEN(result) > 0 &&
-	       RSTRING_LEN(RARRAY_AT(result, RARRAY_LEN(result)-1)) == 0)
+	       RSTRING_CLEN(RARRAY_AT(result, RARRAY_LEN(result)-1)) == 0)
 	    rb_ary_pop(result);
     }
 
@@ -7767,7 +7798,7 @@
 {
     str_modifiable(str);
 #if WITH_OBJC
-    rb_notimplement();
+    /* TODO */
 #else
     rb_enc_associate(str, rb_to_encoding(enc));
 #endif

Modified: MacRuby/trunk/test/ruby/test_string.rb
===================================================================
--- MacRuby/trunk/test/ruby/test_string.rb	2008-05-05 21:13:55 UTC (rev 188)
+++ MacRuby/trunk/test/ruby/test_string.rb	2008-05-06 23:07:11 UTC (rev 189)
@@ -957,6 +957,8 @@
 
     assert_equal([S("a"), S(""), S("b"), S("c")], S("a||b|c|").split(S('|')))
     assert_equal([S("a"), S(""), S("b"), S("c"), S("")], S("a||b|c|").split(S('|'), -1))
+
+    assert_equal([], S("").split(//))
   end
 
   def test_squeeze

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080506/af05a80b/attachment-0001.html


More information about the macruby-changes mailing list