[macruby-changes] [448] MacRuby/branches/lrz_unstable

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 15 19:25:22 PDT 2008


Revision: 448
          http://trac.macosforge.org/projects/ruby/changeset/448
Author:   lsansonetti at apple.com
Date:     2008-08-15 19:25:22 -0700 (Fri, 15 Aug 2008)
Log Message:
-----------
cleaning up re-implemented files

Modified Paths:
--------------
    MacRuby/branches/lrz_unstable/array.c
    MacRuby/branches/lrz_unstable/compile.c
    MacRuby/branches/lrz_unstable/gc.c
    MacRuby/branches/lrz_unstable/hash.c
    MacRuby/branches/lrz_unstable/string.c

Modified: MacRuby/branches/lrz_unstable/array.c
===================================================================
--- MacRuby/branches/lrz_unstable/array.c	2008-08-15 06:08:01 UTC (rev 447)
+++ MacRuby/branches/lrz_unstable/array.c	2008-08-16 02:25:22 UTC (rev 448)
@@ -1,27 +1,23 @@
-/**********************************************************************
+/* 
+ * MacRuby implementation of Ruby 1.9's array.c.
+ *
+ * This file is covered by the Ruby license. See COPYING for more details.
+ * 
+ * Copyright (C) 2007-2008, Apple Inc. All rights reserved.
+ * Copyright (C) 1993-2007 Yukihiro Matsumoto
+ * Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ * Copyright (C) 2000 Information-technology Promotion Agency, Japan
+ */
 
-  array.c -
-
-  $Author: matz $
-  created at: Fri Aug  6 09:46:12 JST 1993
-
-  Copyright (C) 1993-2007 Yukihiro Matsumoto
-  Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
-  Copyright (C) 2000  Information-technology Promotion Agency, Japan
-
-**********************************************************************/
-
 #include "ruby/ruby.h"
 #include "ruby/util.h"
 #include "ruby/st.h"
 #include "id.h"
 
 VALUE rb_cArray;
-#if WITH_OBJC
 VALUE rb_cCFArray;
 VALUE rb_cNSArray;
 VALUE rb_cNSMutableArray;
-#endif
 
 static ID id_cmp;
 
@@ -35,15 +31,6 @@
     }
 }
 
-static inline void
-memfill(register VALUE *mem, register long size, register VALUE val)
-{
-    while (size--) {
-	*mem++ = val;
-    }
-}
-
-#if WITH_OBJC
 /* TODO optimize this */
 struct rb_objc_ary_struct {
     void *cptr;
@@ -71,24 +58,7 @@
     }
     return s;
 }
-#else
-#define ARY_SHARED_P(a) FL_TEST(a, ELTS_SHARED)
 
-#define ARY_SET_LEN(ary, n) do { \
-    RARRAY(ary)->len = (n);\
-} while (0) 
-
-#define ARY_CAPA(ary) RARRAY(ary)->aux.capa
-#define RESIZE_CAPA(ary,capacity) do {\
-    REALLOC_N(RARRAY(ary)->ptr, VALUE, (capacity));\
-    RARRAY(ary)->aux.capa = (capacity);\
-} while (0)
-#endif
-
-VALUE rb_ary_frozen_p(VALUE ary);
-
-#if WITH_OBJC
-
 static inline void
 rb_ary_modify_check(VALUE ary)
 {
@@ -106,32 +76,6 @@
 }
 #define rb_ary_modify rb_ary_modify_check
 
-#else
-
-static inline void
-rb_ary_modify_check(VALUE ary)
-{
-    if (OBJ_FROZEN(ary)) rb_error_frozen("array");
-    if (!OBJ_TAINTED(ary) && rb_safe_level() >= 4)
-	rb_raise(rb_eSecurityError, "Insecure: can't modify array");
-}
-
-static void
-rb_ary_modify(VALUE ary)
-{
-    VALUE *ptr;
-
-    rb_ary_modify_check(ary);
-    if (ARY_SHARED_P(ary)) {
-	ptr = ALLOC_N(VALUE, RARRAY_LEN(ary));
-	FL_UNSET(ary, ELTS_SHARED);
-	RARRAY(ary)->aux.capa = RARRAY_LEN(ary);
-	MEMCPY(ptr, RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
-	RARRAY(ary)->ptr = ptr;
-    }
-}
-#endif
-
 VALUE
 rb_ary_freeze(VALUE ary)
 {
@@ -153,14 +97,11 @@
     return Qfalse;
 }
 
-#if WITH_OBJC
 void rb_ary_insert(VALUE ary, long idx, VALUE val);
-#endif
 
 static VALUE
 ary_alloc(VALUE klass)
 {
-#if WITH_OBJC
     CFMutableArrayRef ary;
 
     ary = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
@@ -169,15 +110,7 @@
 
     CFMakeCollectable(ary);
     rb_gc_malloc_increase(sizeof(void *));
-#else
-    NEWOBJ(ary, struct RArray);
-    OBJSETUP(ary, klass, T_ARRAY);
 
-    ary->len = 0;
-    ary->ptr = 0;
-    ary->aux.capa = 0;
-#endif
-
     return (VALUE)ary;
 }
 
@@ -193,11 +126,6 @@
 	rb_raise(rb_eArgError, "array size too big");
     }
     ary = ary_alloc(klass);
-#if !WITH_OBJC
-    if (len == 0) len++;
-    GC_WB(&RARRAY(ary)->ptr, ALLOC_N(VALUE, len));
-    RARRAY(ary)->aux.capa = len;
-#endif
 
     return ary;
 }
@@ -205,11 +133,7 @@
 VALUE
 rb_ary_new2(long len)
 {
-#if WITH_OBJC
     return ary_new(0, len);
-#else
-    return ary_new(rb_cArray, len);
-#endif
 }
 
 
@@ -236,9 +160,6 @@
     }
     va_end(ar);
 
-#if !WITH_OBJC
-    RARRAY(ary)->len = n;
-#endif
     return ary;
 }
 
@@ -249,55 +170,16 @@
 
     ary = rb_ary_new2(n);
     if (n > 0 && elts) {
-#if WITH_OBJC
 	long i;
 	void **vals = (void **)alloca(n * sizeof(void *));
 	for (i = 0; i < n; i++)
 	    vals[i] = RB2OC(elts[i]);
 	CFArrayReplaceValues((CFMutableArrayRef)ary, CFRangeMake(0, 0), (const void **)vals, n);
-#else
-	MEMCPY(RARRAY_PTR(ary), elts, VALUE, n);
-	RARRAY(ary)->len = n;
-#endif
     }
 
     return ary;
 }
 
-void
-rb_ary_free(VALUE ary)
-{
-#if WITH_OBJC
-    rb_notimplement();
-#else
-    if (!ARY_SHARED_P(ary)) {
-	xfree(RARRAY(ary)->ptr);
-    }
-#endif
-}
-
-#if !WITH_OBJC
-static VALUE
-ary_make_shared(VALUE ary)
-{
-    if (ARY_SHARED_P(ary)) {
-	return RARRAY(ary)->aux.shared;
-    }
-    else {
-	NEWOBJ(shared, struct RArray);
-	OBJSETUP(shared, 0, T_ARRAY);
-
-	shared->len = RARRAY(ary)->len;
-	shared->ptr = RARRAY(ary)->ptr;
-	shared->aux.capa = RARRAY(ary)->aux.capa;
-	RARRAY(ary)->aux.shared = (VALUE)shared;
-	FL_SET(ary, ELTS_SHARED);
-	OBJ_FREEZE(shared);
-	return (VALUE)shared;
-    }
-}
-#endif
-
 VALUE
 rb_assoc_new(VALUE car, VALUE cdr)
 {
@@ -386,19 +268,9 @@
     long len;
     VALUE size, val;
 
-#if WITH_OBJC
     ary = (VALUE)objc_msgSend((id)ary, selInit);
-#else
-    rb_ary_modify(ary);
-#endif
 
     if (argc ==  0) {
-#if !WITH_OBJC
-	if (RARRAY_PTR(ary) && !ARY_SHARED_P(ary)) {
-	    free(RARRAY(ary)->ptr);
-	}
-	RARRAY(ary)->len = 0;
-#endif
 	if (rb_block_given_p()) {
 	    rb_warning("given block not used");
 	}
@@ -421,9 +293,6 @@
 	rb_raise(rb_eArgError, "array size too big");
     }
     rb_ary_modify(ary);
-#if !WITH_OBJC
-    RESIZE_CAPA(ary, len);
-#endif
     if (rb_block_given_p()) {
 	long i;
 
@@ -432,20 +301,12 @@
 	}
 	for (i=0; i<len; i++) {
 	    rb_ary_store(ary, i, rb_yield(LONG2NUM(i)));
-#if !WITH_OBJC
-	    RARRAY(ary)->len = i + 1;
-#endif
 	}
     }
     else {
-#if WITH_OBJC
 	long i;
 	for (i=0; i<len; i++)
 	    rb_ary_insert(ary, i, val);
-#else
-	memfill(RARRAY_PTR(ary), len, val);
-	RARRAY(ary)->len = len;
-#endif
     }
     return ary;
 }
@@ -462,27 +323,20 @@
 static VALUE
 rb_ary_s_create(int argc, VALUE *argv, VALUE klass)
 {
+    int i;
+
     VALUE ary = ary_alloc(klass);
 
     if (argc < 0) {
 	rb_raise(rb_eArgError, "negative array size");
     }
-#if WITH_OBJC
-    int i;
     for (i = 0; i < argc; i++) {
 	CFArrayAppendValue((CFMutableArrayRef)ary, RB2OC(argv[i]));
     }
-#else
-    RARRAY(ary)->ptr = ALLOC_N(VALUE, argc);
-    RARRAY(ary)->aux.capa = argc;
-    MEMCPY(RARRAY_PTR(ary), argv, VALUE, argc);
-    RARRAY(ary)->len = argc;
-#endif
     
     return ary;
 }
 
-#if WITH_OBJC
 void
 rb_ary_insert(VALUE ary, long idx, VALUE val)
 {
@@ -499,7 +353,6 @@
     CFArrayInsertValueAtIndex((CFMutableArrayRef)ary, idx, 
 	(const void *)RB2OC(val));
 }
-#endif
 
 void
 rb_ary_store(VALUE ary, long idx, VALUE val)
@@ -515,7 +368,6 @@
 
     rb_ary_modify(ary);
 
-#if WITH_OBJC
     if (idx > len) {
 	long i;
 	if ((idx - len) * (long)sizeof(VALUE) <= idx - len) {
@@ -529,50 +381,9 @@
     else {
         CFArraySetValueAtIndex((CFMutableArrayRef)ary, idx, (const void *)RB2OC(val));
     }
-#else
-    if (idx >= ARY_CAPA(ary)) {
-	long new_capa = ARY_CAPA(ary) / 2;
-
-	if (new_capa < ARY_DEFAULT_SIZE) {
-	    new_capa = ARY_DEFAULT_SIZE;
-	}
-	if (new_capa + idx < new_capa) {
-	    rb_raise(rb_eArgError, "index too big");
-	}
-	new_capa += idx;
-	if (new_capa * (long)sizeof(VALUE) <= new_capa) {
-	    rb_raise(rb_eArgError, "index too big");
-	}
-	RESIZE_CAPA(ary, new_capa);
-    }
-    if (idx > RARRAY_LEN(ary)) {
-	rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary),
-		     idx-RARRAY_LEN(ary) + 1);
-    }
-
-    if (idx >= RARRAY_LEN(ary)) {
-	RARRAY(ary)->len = idx + 1;
-    }
-    GC_WB(&RARRAY_PTR(ary)[idx], val);
-#endif
 }
 
-#if !WITH_OBJC
 static VALUE
-ary_shared_array(VALUE klass, VALUE ary)
-{
-    VALUE val = ary_alloc(klass);
-
-    ary_make_shared(ary);
-    RARRAY(val)->ptr = RARRAY(ary)->ptr;
-    RARRAY(val)->len = RARRAY(ary)->len;
-    RARRAY(val)->aux.shared = RARRAY(ary)->aux.shared;
-    FL_SET(val, ELTS_SHARED);
-    return val;
-}
-#endif
-
-static VALUE
 ary_shared_first(int argc, VALUE *argv, VALUE ary, int last, bool remove)
 {
     VALUE nv, result;
@@ -592,16 +403,11 @@
     if (last) {
 	offset = ary_len - n;
     }
-#if WITH_OBJC
     result = rb_ary_new();
     CFArrayAppendArray((CFMutableArrayRef)result, (CFArrayRef)ary, CFRangeMake(offset, n));
-    if (remove)
+    if (remove) {
 	CFArrayReplaceValues((CFMutableArrayRef)ary, CFRangeMake(offset, n), NULL, 0);
-#else
-    result = ary_shared_array(rb_cArray, ary);
-    RARRAY(result)->ptr += offset;
-    RARRAY(result)->len = n;
-#endif
+    }
 
     return result;
 }
@@ -622,12 +428,8 @@
 VALUE
 rb_ary_push(VALUE ary, VALUE item)
 {
-#if WITH_OBJC
     rb_ary_modify(ary);
     CFArrayAppendValue((CFMutableArrayRef)ary, (const void *)RB2OC(item));
-#else
-    rb_ary_store(ary, RARRAY_LEN(ary), item);
-#endif
     return ary;
 }
 
@@ -658,7 +460,6 @@
 {
     long n;
     rb_ary_modify_check(ary);
-#if WITH_OBJC
     n = RARRAY_LEN(ary);
     if (n == 0) {
 	return Qnil;
@@ -668,18 +469,6 @@
 	CFArrayRemoveValueAtIndex((CFMutableArrayRef)ary, n - 1);
 	return val;
     }
-#else
-    if (RARRAY_LEN(ary) == 0) return Qnil;
-    if (!ARY_SHARED_P(ary) &&
-	RARRAY_LEN(ary) * 3 < ARY_CAPA(ary) &&
-	ARY_CAPA(ary) > ARY_DEFAULT_SIZE)
-    {
-	RESIZE_CAPA(ary, RARRAY_LEN(ary) * 2);
-    }
-    n = RARRAY_LEN(ary)-1;
-    RARRAY(ary)->len = n;
-    return RARRAY_PTR(ary)[n];
-#endif
 }
 
 /*
@@ -710,9 +499,6 @@
 
     rb_ary_modify_check(ary);
     result = ary_shared_first(argc, argv, ary, Qtrue, true);
-#if !WITH_OBJC
-    RARRAY(ary)->len -= RARRAY_LEN(result);
-#endif
     return result;
 }
 
@@ -723,24 +509,8 @@
 
     rb_ary_modify_check(ary);
     if (RARRAY_LEN(ary) == 0) return Qnil;
-#if WITH_OBJC
     top = RARRAY_AT(ary, 0);
     CFArrayRemoveValueAtIndex((CFMutableArrayRef)ary, 0);
-#else
-    top = RARRAY_PTR(ary)[0];
-    if (!ARY_SHARED_P(ary)) {
-	if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
-	    MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1);
-	    RARRAY(ary)->len--;
-	    return top;
-	}
-	RARRAY_PTR(ary)[0] = Qnil;
-	ary_make_shared(ary);
-    }
-    RARRAY(ary)->ptr++;		/* shift ptr */
-    RARRAY(ary)->len--;
-
-#endif
     return top;
 }
 
@@ -776,17 +546,6 @@
 
     rb_ary_modify_check(ary);
     result = ary_shared_first(argc, argv, ary, Qfalse, true);
-#if !WITH_OBJC
-    n = RARRAY_LEN(result);
-    if (ARY_SHARED_P(ary)) {
-	RARRAY(ary)->ptr += n;
-	RARRAY(ary)->len -= n;
-	}
-    else {
-	MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+n, VALUE, RARRAY_LEN(ary)-n);
-	RARRAY(ary)->len -= n;
-    }
-#endif
 
     return result;
 }
@@ -806,26 +565,15 @@
 static VALUE
 rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
 {
-    if (argc == 0) return ary;
-    rb_ary_modify(ary);
-#if WITH_OBJC
-    {
-	long i;
-	for (i = argc - 1; i >= 0; i--)
-	    CFArrayInsertValueAtIndex((CFMutableArrayRef)ary,
-		0, (const void *)RB2OC(argv[i]));
+    int i;
+    if (argc == 0) {
+	return ary;
     }
-#else
-    if (RARRAY(ary)->aux.capa <= (len = RARRAY(ary)->len) + argc) {
-	RESIZE_CAPA(ary, len + argc + ARY_DEFAULT_SIZE);
-    }
+    rb_ary_modify(ary);
+    for (i = argc - 1; i >= 0; i--)
+	CFArrayInsertValueAtIndex((CFMutableArrayRef)ary,
+	    0, (const void *)RB2OC(argv[i]));
 
-    /* sliding items */
-    MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len);
-    MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
-    RARRAY(ary)->len += argc;
-#endif
-
     return ary;
 }
 
@@ -836,7 +584,6 @@
 }
 
 /* faster version - use this if you don't need to treat negative offset */
-#if WITH_OBJC
 VALUE
 rb_ary_elt(VALUE ary, long offset)
 {
@@ -847,22 +594,10 @@
 	return Qnil;
     return OC2RB(CFArrayGetValueAtIndex((CFArrayRef)ary, offset));
 }
-#else
-static inline VALUE
-rb_ary_elt(VALUE ary, long offset)
-{
-    if (RARRAY_LEN(ary) == 0) return Qnil;
-    if (offset < 0 || RARRAY_LEN(ary) <= offset) {
-	return Qnil;
-    }
-    return RARRAY_PTR(ary)[offset];
-}
-#endif
 
 const VALUE *
 rb_ary_ptr(VALUE ary)
 {
-#if WITH_OBJC
     /* FIXME we could inline __CFArrayGetBucketsPtr for non-store arrays,
      * for performance reasons.
      */
@@ -880,9 +615,6 @@
     GC_WB(&rb_objc_ary_get_struct2(ary)->cptr, values);
 
     return values;
-#else
-    return RARRAY_PTR(ary);
-#endif
 }
 
 VALUE
@@ -897,7 +629,6 @@
 VALUE
 rb_ary_subseq(VALUE ary, long beg, long len)
 {
-#if WITH_OBJC
     long n;
     VALUE newary;
     VALUE klass;
@@ -922,29 +653,6 @@
 	    values, len);
     }	
     return newary;
-#else
-    VALUE klass, ary2, shared;
-    VALUE *ptr;
-
-    if (beg > RARRAY_LEN(ary)) return Qnil;
-    if (beg < 0 || len < 0) return Qnil;
-
-    if (RARRAY_LEN(ary) < len || RARRAY_LEN(ary) < beg + len) {
-	len = RARRAY_LEN(ary) - beg;
-    }
-    klass = rb_obj_class(ary);
-    if (len == 0) return ary_new(klass, 0);
-
-    shared = ary_make_shared(ary);
-    ptr = RARRAY_PTR(ary);
-    ary2 = ary_alloc(klass);
-    RARRAY(ary2)->ptr = ptr + beg;
-    RARRAY(ary2)->len = len;
-    RARRAY(ary2)->aux.shared = shared;
-    FL_SET(ary2, ELTS_SHARED);
-
-    return ary2;
-#endif
 }
 
 /* 
@@ -1165,18 +873,11 @@
 	}
     }
     else {
-#if WITH_OBJC
 	CFIndex idx;
 	idx = CFArrayGetFirstIndexOfValue((CFArrayRef)ary, CFRangeMake(0, n), 
 	    (const void *)RB2OC(val));
 	if (idx != -1)
 	    return LONG2NUM(idx);
-#else
-	for (i=0; i<n; i++) {
-	    if (rb_equal(RARRAY_AT(ary, i), val))
-		return LONG2NUM(i);
-	}
-#endif
     }
     return Qnil;
 }
@@ -1216,20 +917,10 @@
     }
     else {
  	rb_scan_args(argc, argv, "01", &val);
-#if WITH_OBJC
 	i = CFArrayGetLastIndexOfValue((CFArrayRef)ary, CFRangeMake(0, n),
 	   (const void *)RB2OC(val));
 	if (i != -1)
 	    return LONG2NUM(i);
-#else
-	while (i--) {
-	    if (rb_equal(RARRAY_AT(ary, i), val))
-		return LONG2NUM(i);
-	    if (i > n) {
-		i = n;
-	    }
-	}
-#endif
     }
     return Qnil;
 }
@@ -1272,7 +963,6 @@
 	rlen = RARRAY_LEN(rpl);
     }
     rb_ary_modify(ary);
-#if WITH_OBJC
     if (beg >= n) {
 	long i;
 	for (i = n; i < beg - n; i++) {
@@ -1296,40 +986,6 @@
 		values,
 		rlen);
     }
-#else
-    if (beg >= RARRAY_LEN(ary)) {
-	len = beg + rlen;
-	if (len >= ARY_CAPA(ary)) {
-	    RESIZE_CAPA(ary, len);
-	}
-	rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), beg - RARRAY_LEN(ary));
-	if (rlen > 0) {
-	    MEMCPY(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen);
-	}
-	RARRAY(ary)->len = len;
-    }
-    else {
-	long alen;
-
-	if (beg + len > RARRAY_LEN(ary)) {
-	    len = RARRAY_LEN(ary) - beg;
-	}
-
-	alen = RARRAY_LEN(ary) + rlen - len;
-	if (alen >= ARY_CAPA(ary)) {
-	    RESIZE_CAPA(ary, alen);
-	}
-
-	if (len != rlen) {
-	    MEMMOVE(RARRAY_PTR(ary) + beg + rlen, RARRAY_PTR(ary) + beg + len,
-		    VALUE, RARRAY_LEN(ary) - (beg + len));
-	    RARRAY(ary)->len = alen;
-	}
-	if (rlen > 0) {
-	    MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen);
-	}
-    }
-#endif
 }
 
 /* 
@@ -1541,7 +1197,6 @@
 VALUE
 rb_ary_dup(VALUE ary)
 {
-#if WITH_OBJC
     VALUE dup;
 
     dup = (VALUE)CFArrayCreateMutableCopy(NULL, 0, (CFArrayRef)ary);
@@ -1549,12 +1204,6 @@
 	OBJ_TAINT(dup);
 
     CFMakeCollectable((CFTypeRef)dup);
-#else
-    VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
-
-    MEMCPY(RARRAY_PTR(dup), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
-    RARRAY(dup)->len = RARRAY_LEN(ary);
-#endif
     return dup;
 }
 
@@ -1588,19 +1237,7 @@
 
     if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
     if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue;
-#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_BYTELEN(tmp);
-    }
-    if (!NIL_P(sep)) {
-	StringValue(sep);
-	len += RSTRING_BYTELEN(sep) * (RARRAY_LEN(ary) - 1);
-    }
-    result = rb_str_buf_new(len);
-#endif
 
     for (i=0, count=RARRAY_LEN(ary); i<count; i++) {
 	tmp = RARRAY_AT(ary, i);
@@ -1703,11 +1340,7 @@
 static VALUE
 rb_ary_to_a(VALUE ary)
 {
-#if WITH_OBJC
     if (!rb_objc_ary_is_pure(ary)) {
-#else
-    if (rb_obj_class(ary) != rb_cArray) {
-#endif
 	VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
 	rb_ary_replace(dup, ary);
 	return dup;
@@ -1731,7 +1364,6 @@
 VALUE
 rb_ary_reverse(VALUE ary)
 {
-#if WITH_OBJC
     long n;
 
     rb_ary_modify(ary);
@@ -1751,22 +1383,6 @@
 	}
 	CFArrayReplaceValues((CFMutableArrayRef)ary, range, (const void **)values, n);
     }
-#else
-    VALUE *p1, *p2;
-    VALUE tmp;
-
-    rb_ary_modify(ary);
-    if (RARRAY_LEN(ary) > 1) {
-	p1 = RARRAY_PTR(ary);
-	p2 = p1 + RARRAY_LEN(ary) - 1;	/* points last item */
-
-	while (p1 < p2) {
-	    tmp = *p1;
-	    *p1++ = *p2;
-	    *p2-- = tmp;
-	}
-    }
-#endif
     return ary;
 }
 
@@ -1806,11 +1422,7 @@
 static int
 sort_1(const void *ap, const void *bp, void *dummy)
 {
-#if WITH_OBJC
     VALUE a = (VALUE)ap, b = (VALUE)bp;
-#else
-    VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
-#endif
     VALUE retval = rb_yield_values(2, a, b);
     int n;
 
@@ -1822,20 +1434,10 @@
 sort_2(const void *ap, const void *bp, void *dummy)
 {
     VALUE retval;
-#if WITH_OBJC
     VALUE a = (VALUE)ap, b = (VALUE)bp;
-#else
-    VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
-#endif
     int n;
 
-#if !WITH_OBJC
-    if (FIXNUM_P(a) && FIXNUM_P(b)) {
-	if ((long)a > (long)b) return 1;
-	if ((long)a < (long)b) return -1;
-	return 0;
-    }
-#endif
+    /* FIXME optimize!!! */
     if (TYPE(a) == T_STRING) {
 	if (TYPE(b) == T_STRING) return rb_str_cmp(a, b);
     }
@@ -1862,7 +1464,6 @@
  *     a.sort {|x,y| y <=> x }   #=> ["e", "d", "c", "b", "a"]
  */
 
-#if WITH_OBJC
 static void
 rb_ary_sort_bang1(VALUE ary, bool is_dup)
 {
@@ -1885,34 +1486,12 @@
 	}
     }
 }
-#endif
 
 VALUE
 rb_ary_sort_bang(VALUE ary)
 {
     rb_ary_modify(ary);
-#if WITH_OBJC
     rb_ary_sort_bang1(ary, false);
-#else
-    if (RARRAY_LEN(ary) > 1) {
-	VALUE tmp = ary_make_shared(ary);
-
-	RBASIC(tmp)->klass = 0;
-	ruby_qsort(RARRAY_PTR(tmp), RARRAY_LEN(tmp), sizeof(VALUE),
-		   rb_block_given_p()?sort_1:sort_2, &RBASIC(tmp)->klass);
-	if (RARRAY(ary)->ptr != RARRAY(tmp)->ptr) {
-	    xfree(RARRAY(ary)->ptr);
-	    RARRAY(ary)->ptr = RARRAY(tmp)->ptr;
-	    RARRAY(ary)->len = RARRAY(tmp)->len;
-	    RARRAY(ary)->aux.capa = RARRAY(tmp)->aux.capa;
-	};
-	FL_UNSET(ary, ELTS_SHARED);
-	RARRAY(tmp)->ptr = 0;
-	RARRAY(tmp)->len = 0;
-	RARRAY(tmp)->aux.capa = 0;
-	RBASIC(tmp)->klass = RBASIC(ary)->klass;
-    }
-#endif
     return ary;
 }
 
@@ -2098,7 +1677,6 @@
 VALUE
 rb_ary_delete(VALUE ary, VALUE item)
 {
-#if WITH_OBJC
     long k, n, i;
     CFRange r;
     const void *ocitem;
@@ -2122,36 +1700,6 @@
 	return Qnil;
     }
     return item;
-#else
-    long i1, i2;
-
-    for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
-	VALUE e = RARRAY_PTR(ary)[i1];
-
-	if (rb_equal(e, item)) continue;
-	if (i1 != i2) {
-	    rb_ary_store(ary, i2, e);
-	}
-	i2++;
-    }
-    if (RARRAY_LEN(ary) == i2) {
-	if (rb_block_given_p()) {
-	    return rb_yield(item);
-	}
-	return Qnil;
-    }
-
-    rb_ary_modify(ary);
-    if (RARRAY_LEN(ary) > i2) {
-	RARRAY(ary)->len = i2;
-	if (i2 * 2 < ARY_CAPA(ary) &&
-	    ARY_CAPA(ary) > ARY_DEFAULT_SIZE) {
-	    RESIZE_CAPA(ary, i2*2);
-	}
-    }
-
-    return item;
-#endif
 }
 
 VALUE
@@ -2168,13 +1716,7 @@
 
     rb_ary_modify(ary);
     del = RARRAY_AT(ary, pos);
-#if WITH_OBJC
     CFArrayRemoveValueAtIndex((CFMutableArrayRef)ary, pos);
-#else
-    MEMMOVE(RARRAY_PTR(ary)+pos, RARRAY_PTR(ary)+pos+1, VALUE,
-	    RARRAY_LEN(ary)-pos-1);
-    RARRAY(ary)->len--;
-#endif
 
     return del;
 }
@@ -2238,12 +1780,7 @@
 	if (alen < len || alen < pos + len) {
 	    len = alen - pos;
 	}
-#if WITH_OBJC
 	arg2 = rb_ary_subseq(ary, pos, len);
-#else
-	arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
-	RBASIC(arg2)->klass = rb_obj_class(ary);
-#endif
 	rb_ary_splice(ary, pos, len, Qundef);	/* Qnil/rb_ary_new2(0) */
 	return arg2;
     }
@@ -2285,30 +1822,16 @@
     orign = n = RARRAY_LEN(ary);
     for (i1 = i2 = 0; i1 < n; i1++) {
 	VALUE v = RARRAY_AT(ary, i1);
-#if WITH_OBJC
 	if (!RTEST(rb_yield(v))) {
 	    continue;
 	}
 	CFArrayRemoveValueAtIndex((CFMutableArrayRef)ary, i1);
 	n--;
 	i1--;
-#else
-	if (RTEST(rb_yield(v))) continue;
-	if (i1 != i2) {
-	    rb_ary_store(ary, i2, v);
-	}
-	i2++;
-#endif
     }
 
-#if WITH_OBJC
     if (n == orign) 
 	return Qnil;
-#else
-    if (n == i2) return Qnil;
-    if (i2 < RARRAY_LEN(ary))
-	RARRAY(ary)->len = i2;
-#endif
     return ary;
 }
 
@@ -2482,22 +2005,10 @@
     orig = to_ary(orig);
     rb_ary_modify_check(copy);
     if (copy == orig) return copy;
-#if WITH_OBJC
     CFArrayRemoveAllValues((CFMutableArrayRef)copy);
     CFArrayAppendArray((CFMutableArrayRef)copy,
 	(CFArrayRef)orig,
 	CFRangeMake(0, RARRAY_LEN(orig)));
-#else
-    shared = ary_make_shared(orig);
-    if (!ARY_SHARED_P(copy)) {
-	ptr = RARRAY(copy)->ptr;
-	xfree(ptr);
-    }
-    RARRAY(copy)->ptr = RARRAY(orig)->ptr;
-    RARRAY(copy)->len = RARRAY(orig)->len;
-    RARRAY(copy)->aux.shared = shared;
-    FL_SET(copy, ELTS_SHARED);
-#endif
 
     return copy;
 }
@@ -2516,14 +2027,7 @@
 rb_ary_clear(VALUE ary)
 {
     rb_ary_modify(ary);
-#if WITH_OBJC
     CFArrayRemoveAllValues((CFMutableArrayRef)ary);
-#else
-    RARRAY(ary)->len = 0;
-    if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
-	RESIZE_CAPA(ary, ARY_DEFAULT_SIZE * 2);
-    }
-#endif
     return ary;
 }
 
@@ -2593,15 +2097,6 @@
     if (end < 0) {
 	rb_raise(rb_eArgError, "argument too big");
     }
-#if !WITH_OBJC
-    if (n < end) {
-	if (end >= ARY_CAPA(ary)) {
-	    RESIZE_CAPA(ary, end);
-	}
-	rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), end - RARRAY_LEN(ary));
-	RARRAY(ary)->len = end;
-    }
-#endif
 
     if (block_p) {
 	VALUE v;
@@ -2609,25 +2104,14 @@
 
 	for (i=beg; i<end; i++) {
 	    v = rb_yield(LONG2NUM(i));
-#if !WITH_OBJC
-	    if (i>=RARRAY_LEN(ary)) break;
-#endif
 	    rb_ary_store(ary, i, v);
 	}
     }
     else {
-#if WITH_OBJC
 	long i;
 	for (i=beg; i<end; i++) {
 	    rb_ary_store(ary, i, item);
 	}
-#else
-	p = RARRAY_PTR(ary) + beg;
-	pend = p + len;
-	while (p < pend) {
-	    *p++ = item;
-	}
-#endif
     }
     return ary;
 }
@@ -2647,21 +2131,12 @@
 {
     VALUE z;
 
-#if WITH_OBJC
     y = to_ary(y);
     z = rb_ary_new2(0);
     CFArrayAppendArray((CFMutableArrayRef)z, 
 	(CFArrayRef)x, CFRangeMake(0, RARRAY_LEN(x)));    
     CFArrayAppendArray((CFMutableArrayRef)z, 
 	(CFArrayRef)y, CFRangeMake(0, RARRAY_LEN(y)));    
-#else
-    y = to_ary(y);
-    len = RARRAY_LEN(x) + RARRAY_LEN(y);
-    z = rb_ary_new2(len);
-    MEMCPY(RARRAY_PTR(z), RARRAY_PTR(x), VALUE, RARRAY_LEN(x));
-    MEMCPY(RARRAY_PTR(z) + RARRAY_LEN(x), RARRAY_PTR(y), VALUE, RARRAY_LEN(y));
-    RARRAY(z)->len = len;
-#endif
     return z;
 }
 
@@ -2721,25 +2196,13 @@
     if (LONG_MAX/len < n) {
 	rb_raise(rb_eArgError, "argument too big");
     }
-#if WITH_OBJC
     ary2 = ary_new(rb_obj_class(ary), 0);
     for (i = 0; i < len; i++) {
 	CFArrayAppendArray((CFMutableArrayRef)ary2,
 		(CFArrayRef)ary,
 		CFRangeMake(0, n));
     }
-#else
-    len *= RARRAY_LEN(ary);
 
-    ary2 = ary_new(rb_obj_class(ary), len);
-    RARRAY(ary2)->len = len;
-
-    for (i=0; i<len; i+=RARRAY_LEN(ary)) {
-	MEMCPY(RARRAY_PTR(ary2)+i, RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
-    }
-    OBJ_INFECT(ary2, ary);
-#endif
-
     return ary2;
 }
 
@@ -2808,21 +2271,6 @@
     return Qnil;
 }
 
-#if !WITH_OBJC
-static VALUE
-recursive_equal(VALUE ary1, VALUE ary2, int recur)
-{
-    long i;
-
-    if (recur) return Qfalse;
-    for (i=0; i<RARRAY_LEN(ary1); i++) {
-	if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
-	    return Qfalse;
-    }
-    return Qtrue;
-}
-#endif
-
 /* 
  *  call-seq:
  *     array == other_array   ->   bool
@@ -2847,12 +2295,7 @@
 	}
 	return rb_equal(ary2, ary1);
     }
-#if WITH_OBJC
     return CFEqual((CFTypeRef)ary1, (CFTypeRef)ary2) ? Qtrue : Qfalse;
-#else
-    if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
-    return rb_exec_recursive(recursive_equal, ary1, ary2);
-#endif
 }
 
 static VALUE
@@ -2885,44 +2328,8 @@
     return rb_exec_recursive(recursive_eql, ary1, ary2);
 }
 
-#if !WITH_OBJC
-static VALUE
-recursive_hash(VALUE ary, VALUE dummy, int recur)
-{
-    long i, h;
-    VALUE n;
-
-    if (recur) {
-	return LONG2FIX(0);
-    }
-    h = RARRAY_LEN(ary);
-    for (i=0; i<RARRAY_LEN(ary); i++) {
-	h = (h << 1) | (h<0 ? 1 : 0);
-	n = rb_hash(RARRAY_AT(ary, i));
-	h ^= NUM2LONG(n);
-    }
-    return LONG2FIX(h);
-}
-#endif
-
 /*
  *  call-seq:
- *     array.hash   -> fixnum
- *
- *  Compute a hash-code for this array. Two arrays with the same content
- *  will have the same hash code (and will compare using <code>eql?</code>).
- */
-
-#if !WITH_OBJC
-static VALUE
-rb_ary_hash(VALUE ary)
-{
-    return rb_exec_recursive(recursive_hash, ary, 0);
-}
-#endif
-
-/*
- *  call-seq:
  *     array.include?(obj)   -> true or false
  *  
  *  Returns <code>true</code> if the given object is present in
@@ -2937,19 +2344,8 @@
 VALUE
 rb_ary_includes(VALUE ary, VALUE item)
 {
-#if WITH_OBJC
     return CFArrayContainsValue((CFArrayRef)ary, 
 	CFRangeMake(0, RARRAY_LEN(ary)), (const void *)RB2OC(item)) ? Qtrue : Qfalse;
-#else
-    long i;
-    
-    for (i=0; i<RARRAY_LEN(ary); i++) {
-	if (rb_equal(RARRAY_PTR(ary)[i], item)) {
-	    return Qtrue;
-	}
-    }
-    return Qfalse;
-#endif
 }
 
 
@@ -3048,13 +2444,9 @@
     ary3 = rb_ary_new();
 
     for (i=0; i<RARRAY_LEN(ary1); i++) {
-#if WITH_OBJC
 	const void *v = CFArrayGetValueAtIndex((CFArrayRef)ary1, i);
 	if (CFDictionaryGetValueIfPresent((CFDictionaryRef)hash, (const void *)v, NULL)) 
 	    continue;
-#else
-	if (st_lookup(RHASH_TBL(hash), RARRAY_PTR(ary1)[i], 0)) continue;
-#endif
 	rb_ary_push(ary3, rb_ary_elt(ary1, i));
     }
     return ary3;
@@ -3087,14 +2479,10 @@
 
     for (i=0; i<RARRAY_LEN(ary1); i++) {
 	v = vv = rb_ary_elt(ary1, i);
-#if WITH_OBJC
 	id ocvv = RB2OC(vv);
 	if (CFDictionaryContainsKey((CFDictionaryRef)hash, (const void *)ocvv)) {
 	    CFDictionaryRemoveValue((CFMutableDictionaryRef)hash,
 		(const void *)ocvv);
-#else
-	if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
-#endif
 	    rb_ary_push(ary3, v);
 	}
     }
@@ -3126,27 +2514,19 @@
 
     for (i=0; i<RARRAY_LEN(ary1); i++) {
 	v = vv = rb_ary_elt(ary1, i);
-#if WITH_OBJC
 	id ocvv = RB2OC(vv);
 	if (CFDictionaryContainsKey((CFDictionaryRef)hash, (const void *)ocvv)) {
 	    CFDictionaryRemoveValue((CFMutableDictionaryRef)hash,
 		(const void *)ocvv);
-#else
-	if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
-#endif
 	    rb_ary_push(ary3, v);
 	}
     }
     for (i=0; i<RARRAY_LEN(ary2); i++) {
 	v = vv = rb_ary_elt(ary2, i);
-#if WITH_OBJC
 	id ocvv = RB2OC(vv);
 	if (CFDictionaryContainsKey((CFDictionaryRef)hash, (const void *)ocvv)) {
 	    CFDictionaryRemoveValue((CFMutableDictionaryRef)hash,
 		(const void *)ocvv);
-#else
-	if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
-#endif
 	    rb_ary_push(ary3, v);
 	}
     }
@@ -3170,7 +2550,6 @@
 static VALUE
 rb_ary_uniq_bang(VALUE ary)
 {
-#if WITH_OBJC
     long i, n;
     bool changed;
 
@@ -3195,31 +2574,7 @@
     }
     if (!changed)
 	return Qnil;
-#else
-    VALUE hash, v, vv;
-    long i, j;
 
-    hash = ary_make_hash(ary, 0);
-
-    if (RARRAY_LEN(ary) == RHASH_SIZE(hash)) {
-	return Qnil;
-    }
-    for (i=j=0; i<RARRAY_LEN(ary); i++) {
-	v = vv = rb_ary_elt(ary, i);
-#if WITH_OBJC
-	id ocvv = RB2OC(vv);
-	if (CFDictionaryContainsKey((CFDictionaryRef)hash, (const void *)ocvv)) {
-	    CFDictionaryRemoveValue((CFMutableDictionaryRef)hash,
-		(const void *)ocvv);
-#else
-	if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
-#endif
-	    rb_ary_store(ary, j++, v);
-	}
-    }
-    RARRAY(ary)->len = j;
-#endif
-
     return ary;
 }
 
@@ -3255,7 +2610,6 @@
 static VALUE
 rb_ary_compact_bang(VALUE ary)
 {
-#if WITH_OBJC
     long i, n, k;
     CFRange r;
 
@@ -3274,26 +2628,7 @@
     }
     if (k == 0)
 	return Qnil;
-#else
-    VALUE *p, *t, *end;
-    long n;
 
-    rb_ary_modify(ary);
-    p = t = RARRAY_PTR(ary);
-    end = p + RARRAY_LEN(ary);
-    
-    while (t < end) {
-	if (NIL_P(*t)) t++;
-	else *p++ = *t++;
-    }
-    if (RARRAY_LEN(ary) == (p - RARRAY_PTR(ary))) {
-	return Qnil;
-    }
-    n = p - RARRAY_PTR(ary);
-    RESIZE_CAPA(ary, n);
-    RARRAY(ary)->len = n;
-#endif
-
     return ary;
 }
 
@@ -3343,16 +2678,10 @@
 	if (!rb_block_given_p())
 	    return LONG2NUM(count);
 
-#if WITH_OBJC
 	for (i = 0; i < count; i++) {
 	    if (RTEST(rb_yield(RARRAY_AT(ary, i)))) 
 		n++;
 	}
-#else
-	for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
-	    if (RTEST(rb_yield(*p))) n++;
-	}
-#endif
     }
     else {
 	VALUE obj;
@@ -3362,13 +2691,7 @@
 	if (rb_block_given_p()) {
 	    rb_warn("given block not used");
 	}
-#if WITH_OBJC
 	n = CFArrayGetCountOfValue((CFArrayRef)ary, CFRangeMake(0, count), RB2OC(obj));
-#else
-	for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
-	    if (rb_equal(*p, obj)) n++;
-	}
-#endif
     }
 
     return LONG2NUM(n);
@@ -3392,11 +2715,6 @@
 	while (i < RARRAY_LEN(ary)) {
 	    elt = RARRAY_AT(ary, i++);
 	    tmp = rb_check_array_type(elt);
-#if !WITH_OBJC
-	    if (RBASIC(result)->klass) {
-		rb_raise(rb_eRuntimeError, "flatten reentered");
-	    }
-#endif
 	    if (NIL_P(tmp) || (level >= 0 && RARRAY_LEN(stack) / 2 >= level)) {
 		rb_ary_push(result, elt);
 	    }
@@ -3426,9 +2744,6 @@
 
     st_free_table(memo);
 
-#if !WITH_OBJC
-    RBASIC(result)->klass = rb_class_of(ary);
-#endif
     return result;
 }
 
@@ -3517,13 +2832,7 @@
     rb_ary_modify(ary);
     while (i) {
 	long j = rb_genrand_real()*i;
-#if WITH_OBJC
 	CFArrayExchangeValuesAtIndices((CFMutableArrayRef)ary, --i, j);
-#else
-	VALUE tmp = RARRAY_AT(ary, --i);
-	RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j];
-	RARRAY_PTR(ary)[j] = tmp;
-#endif
     }
     return ary;
 }
@@ -3641,16 +2950,8 @@
 		/* Build a ruby array of the corresponding values */
 		/* And yield it to the associated block */
 		VALUE result = rb_ary_new2(r);
-#if WITH_OBJC
 		for (j = 0; j < r; j++) 
 		    rb_ary_store(result, j, RARRAY_AT(values, p[j]));
-#else
-		VALUE *result_array = RARRAY_PTR(result);
-		const VALUE *values_array = RARRAY_PTR(values);
-
-		for (j = 0; j < r; j++) result_array[j] = values_array[p[j]];
-		RARRAY(result)->len = r;
-#endif
 		rb_yield(result);
 	    }
 	}
@@ -3710,19 +3011,11 @@
 	long *p = (long*)RSTRING_BYTEPTR(t0);
 	volatile VALUE t1 = tmpbuf(n,sizeof(int));
 	int *used = (int*)RSTRING_BYTEPTR(t1);
-#if WITH_OBJC
 	VALUE ary0 = rb_ary_dup(ary);
-#else
-	VALUE ary0 = ary_make_shared(ary); /* private defensive copy of ary */
-#endif
 
 	for (i = 0; i < n; i++) used[i] = 0; /* initialize array */
 
 	permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
-#if !WITH_OBJC
-	RB_GC_GUARD(t0);
-	RB_GC_GUARD(t1);
-#endif
     }
     return ary;
 }
@@ -3797,9 +3090,6 @@
 	volatile VALUE cc = rb_ary_new2(n);
 	long lev = 0;
 
-#if !WITH_OBJC
-	RBASIC(cc)->klass = 0;
-#endif
 	MEMZERO(stack, long, n);
 	stack[0] = -1;
 	for (i = 0; i < nlen; i++) {
@@ -3808,11 +3098,7 @@
 		stack[lev+1] = stack[lev]+1;
 		rb_ary_store(cc, lev, RARRAY_AT(ary, stack[lev+1]));
 	    }
-#if WITH_OBJC
 	    rb_yield(rb_ary_dup(cc));
-#else
-	    rb_yield(cc);
-#endif
 	    do {
 		stack[lev--]++;
 	    } while (lev && (stack[lev+1]+n == len+lev+1));
@@ -3994,8 +3280,6 @@
     return rb_ary_drop(ary, LONG2FIX(i));
 }
 
-#if WITH_OBJC
-
 #define PREPARE_RCV(x) \
     Class old = *(Class *)x; \
     *(Class *)x = (Class)rb_cCFArray;
@@ -4122,8 +3406,6 @@
 #undef INSTALL_METHOD
 }
 
-#endif
-
 /* Arrays are ordered, integer-indexed collections of any object. 
  * Array indexing starts at 0, as in C or Java.  A negative index is 
  * assumed to be relative to the end of the array---that is, an index of -1 
@@ -4134,20 +3416,14 @@
 void
 Init_Array(void)
 {
-#if WITH_OBJC
     rb_cCFArray = (VALUE)objc_getClass("NSCFArray");
     rb_cArray = rb_cNSArray = (VALUE)objc_getClass("NSArray");
     rb_cNSMutableArray = (VALUE)objc_getClass("NSMutableArray");
     rb_set_class_path(rb_cNSMutableArray, rb_cObject, "NSMutableArray");
     rb_const_set(rb_cObject, rb_intern("Array"), rb_cNSMutableArray);
-#else
-    rb_cArray  = rb_define_class("Array", rb_cObject);
-#endif
+
     rb_include_module(rb_cArray, rb_mEnumerable);
 
-#if !WITH_OBJC
-    rb_define_alloc_func(rb_cArray, ary_alloc);
-#endif
     rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1);
     rb_define_singleton_method(rb_cArray, "try_convert", rb_ary_s_try_convert, 1);
     rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1);
@@ -4161,9 +3437,6 @@
 
     rb_define_method(rb_cArray, "==", rb_ary_equal, 1);
     rb_define_method(rb_cArray, "eql?", rb_ary_eql, 1);
-#if !WITH_OBJC
-    rb_define_method(rb_cArray, "hash", rb_ary_hash, 0);
-#endif
 
     rb_define_method(rb_cArray, "[]", rb_ary_aref, -1);
     rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1);
@@ -4231,10 +3504,12 @@
     rb_define_method(rb_cArray, "flatten", rb_ary_flatten, -1);
     rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, -1);
     rb_define_method(rb_cArray, "_count", rb_ary_count, -1);
-#if WITH_OBJC
-    /* to maintain backwards compatibility with our /etc/irbrc file */
+
+    /* to maintain backwards compatibility with our /etc/irbrc file
+     * TODO: fix /etc/irbrc to use #count, and remove this method.
+     */
     rb_define_method(rb_cArray, "nitems", rb_ary_count, -1);
-#endif
+
     rb_define_method(rb_cArray, "shuffle!", rb_ary_shuffle_bang, 0);
     rb_define_method(rb_cArray, "shuffle", rb_ary_shuffle, 0);
     rb_define_method(rb_cArray, "choice", rb_ary_choice, 0);
@@ -4248,11 +3523,9 @@
     rb_define_method(rb_cArray, "drop", rb_ary_drop, 1);
     rb_define_method(rb_cArray, "drop_while", rb_ary_drop_while, 0);
 
-#if WITH_OBJC
     /* to return mutable copies */
     rb_define_method(rb_cArray, "dup", rb_ary_dup, 0);
     rb_define_method(rb_cArray, "clone", rb_ary_clone, 0);
-#endif
 
     id_cmp = rb_intern("<=>");
 }

Modified: MacRuby/branches/lrz_unstable/compile.c
===================================================================
--- MacRuby/branches/lrz_unstable/compile.c	2008-08-15 06:08:01 UTC (rev 447)
+++ MacRuby/branches/lrz_unstable/compile.c	2008-08-16 02:25:22 UTC (rev 448)
@@ -707,14 +707,11 @@
 	id_str = (char *)rb_sym2name(id);
 	id_str_len = strlen(id_str);
 
-	if (id_str[id_str_len - 1] == '=' && isalpha(id_str[id_str_len - 2]) && FIX2INT(argc) == 1) {
-	    buf[0] = 's';
-	    buf[1] = 'e';
-	    buf[2] = 't';
+	if (id_str[id_str_len - 1] == '=' && isalpha(id_str[id_str_len - 2]) 
+	    && FIX2INT(argc) == 1) {
+	    snprintf(buf, sizeof buf, "set%s", id_str);
 	    buf[3] = toupper(id_str[0]);
-	    strncpy(&buf[4], &id_str[1], id_str_len - 2);
 	    buf[id_str_len + 2] = ':';
-	    buf[id_str_len + 3] = '\0';
 	    id_str = buf;
 	}
 	else if (id_str[id_str_len - 1] != ':') {

Modified: MacRuby/branches/lrz_unstable/gc.c
===================================================================
--- MacRuby/branches/lrz_unstable/gc.c	2008-08-15 06:08:01 UTC (rev 447)
+++ MacRuby/branches/lrz_unstable/gc.c	2008-08-16 02:25:22 UTC (rev 448)
@@ -1,16 +1,14 @@
-/**********************************************************************
+/* 
+ * MacRuby implementation of Ruby 1.9's gc.c.
+ *
+ * This file is covered by the Ruby license. See COPYING for more details.
+ * 
+ * Copyright (C) 2007-2008, Apple Inc. All rights reserved.
+ * Copyright (C) 1993-2007 Yukihiro Matsumoto
+ * Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ * Copyright (C) 2000 Information-technology Promotion Agency, Japan
+ */
 
-  gc.c -
-
-  $Author: akr $
-  created at: Tue Oct  5 09:44:46 JST 1993
-
-  Copyright (C) 1993-2007 Yukihiro Matsumoto
-  Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
-  Copyright (C) 2000  Information-technology Promotion Agency, Japan
-
-**********************************************************************/
-
 #include "ruby/ruby.h"
 #include "ruby/signal.h"
 #include "ruby/st.h"
@@ -33,16 +31,11 @@
 #include <sys/resource.h>
 #endif
 
-#if defined _WIN32 || defined __CYGWIN__
-#include <windows.h>
-#endif
-
-#if WITH_OBJC
-# include <mach/mach.h>
-# if HAVE_AUTO_ZONE_H
-#  include <auto_zone.h>
-# else
-#  include <malloc/malloc.h>
+#include <mach/mach.h>
+#if HAVE_AUTO_ZONE_H
+# include <auto_zone.h>
+#else
+# include <malloc/malloc.h>
 typedef malloc_zone_t auto_zone_t;
 #define AUTO_MEMORY_SCANNED   0
 #define AUTO_MEMORY_UNSCANNED 1
@@ -110,57 +103,17 @@
     size_t              bytes_freed_during_last_collection[2];
     // durations not included
 } auto_statistics_t;
-# endif
+#endif
 static auto_zone_t *__auto_zone = NULL;
 static long xmalloc_count = 0;
-#endif
 
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-# include <valgrind/memcheck.h>
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-#  define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE(p, n)
-# endif
-# ifndef VALGRIND_MAKE_MEM_UNDEFINED
-#  define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE(p, n)
-# endif
-#else
-# define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */
-# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) /* empty */
-#endif
-
 int rb_io_fptr_finalize(struct rb_io_t*);
 
-#define rb_setjmp(env) RUBY_SETJMP(env)
 #define rb_jmp_buf rb_jmpbuf_t
 
-/* Make alloca work the best possible way.  */
-#ifdef __GNUC__
-# ifndef atarist
-#  ifndef alloca
-#   define alloca __builtin_alloca
-#  endif
-# endif /* atarist */
-#else
-# ifdef HAVE_ALLOCA_H
-#  include <alloca.h>
-# else
-#  ifdef _AIX
- #pragma alloca
-#  else
-#   ifndef alloca /* predefined by HP cc +Olibcalls */
-void *alloca ();
-#   endif
-#  endif /* AIX */
-# endif /* HAVE_ALLOCA_H */
-#endif /* __GNUC__ */
-
 #ifndef GC_MALLOC_LIMIT
-#if defined(MSDOS) || defined(__human68k__)
-#define GC_MALLOC_LIMIT 200000
-#else
-#define GC_MALLOC_LIMIT 8000000
+# define GC_MALLOC_LIMIT 8000000
 #endif
-#endif
 
 static VALUE nomem_error;
 
@@ -170,169 +123,6 @@
 
 #undef GC_DEBUG
 
-#if !WITH_OBJC
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
-#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
-#endif
-
-typedef struct RVALUE {
-    union {
-	struct {
-	    VALUE flags;		/* always 0 for freed obj */
-	    struct RVALUE *next;
-	} free;
-	struct RBasic  basic;
-	struct RObject object;
-	struct RClass  klass;
-	struct RFloat  flonum;
-	struct RString string;
-	struct RArray  array;
-	struct RRegexp regexp;
-	struct RHash   hash;
-	struct RData   data;
-	struct RStruct rstruct;
-	struct RBignum bignum;
-	struct RFile   file;
-	struct RNode   node;
-	struct RMatch  match;
-	struct RRational rational;
-	struct RComplex complex;
-    } as;
-#ifdef GC_DEBUG
-    char *file;
-    int   line;
-#endif
-} RVALUE;
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
-#pragma pack(pop)
-#endif
-
-struct heaps_slot {
-    void *membase;
-    RVALUE *slot;
-    int limit;
-};
-
-#define HEAP_MIN_SLOTS 10000
-#define FREE_MIN  4096
-
-struct gc_list {
-    VALUE *varptr;
-    struct gc_list *next;
-};
-
-typedef struct rb_objspace {
-    struct {
-	size_t limit;
-	size_t increase;
-    } params;
-    struct {
-	size_t increment;
-	struct heaps_slot *ptr;
-	size_t length;
-	size_t used;
-	RVALUE *freelist;
-	RVALUE *range[2];
-	RVALUE *freed;
-    } heap;
-    struct {
-	int dont_gc;
-	int during_gc;
-    } flags;
-    struct {
-	int need_call;
-	st_table *table;
-	RVALUE *deferred;
-    } final;
-    struct {
-	VALUE buffer[MARK_STACK_MAX];
-	VALUE *ptr;
-	int overflow;
-    } markstack;
-    struct gc_list *global_list;
-    unsigned int count;
-} rb_objspace_t;
-
-#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
-#define rb_objspace (*GET_VM()->objspace)
-#else
-static rb_objspace_t rb_objspace = {{GC_MALLOC_LIMIT}, {HEAP_MIN_SLOTS}};
-#endif
-#define malloc_limit		objspace->params.limit
-#define malloc_increase 	objspace->params.increase
-#define heap_slots		objspace->heap.slots
-#define heaps			objspace->heap.ptr
-#define heaps_length		objspace->heap.length
-#define heaps_used		objspace->heap.used
-#define freelist		objspace->heap.freelist
-#define lomem			objspace->heap.range[0]
-#define himem			objspace->heap.range[1]
-#define heaps_inc		objspace->heap.increment
-#define heaps_freed		objspace->heap.freed
-#define dont_gc 		objspace->flags.dont_gc
-#define during_gc		objspace->flags.during_gc
-#define need_call_final 	objspace->final.need_call
-#define finalizer_table 	objspace->final.table
-#define deferred_final_list	objspace->final.deferred
-#define mark_stack		objspace->markstack.buffer
-#define mark_stack_ptr		objspace->markstack.ptr
-#define mark_stack_overflow	objspace->markstack.overflow
-#define global_List		objspace->global_list
-
-rb_objspace_t *
-rb_objspace_alloc(void)
-{
-    rb_objspace_t *objspace = malloc(sizeof(rb_objspace_t));
-    memset(objspace, 0, sizeof(*objspace));
-    malloc_limit = GC_MALLOC_LIMIT;
-
-    return objspace;
-}
-
-/* tiny heap size */
-/* 32KB */
-/*#define HEAP_SIZE 0x8000 */
-/* 128KB */
-/*#define HEAP_SIZE 0x20000 */
-/* 64KB */
-/*#define HEAP_SIZE 0x10000 */
-/* 16KB */
-#define HEAP_SIZE 0x4000
-/* 8KB */
-/*#define HEAP_SIZE 0x2000 */
-/* 4KB */
-/*#define HEAP_SIZE 0x1000 */
-/* 2KB */
-/*#define HEAP_SIZE 0x800 */
-
-#define HEAP_OBJ_LIMIT (HEAP_SIZE / sizeof(struct RVALUE))
-#define FREE_MIN  4096
-
-extern st_table *rb_class_tbl;
-VALUE *rb_gc_stack_start = 0;
-#ifdef __ia64
-VALUE *rb_gc_register_stack_start = 0;
-#endif
-
-
-#ifdef DJGPP
-/* set stack size (http://www.delorie.com/djgpp/v2faq/faq15_9.html) */
-unsigned int _stklen = 0x180000; /* 1.5 kB */
-#endif
-
-#if defined(DJGPP) || defined(_WIN32_WCE)
-size_t rb_gc_stack_maxsize = 65535*sizeof(VALUE);
-#else
-size_t rb_gc_stack_maxsize = 655300*sizeof(VALUE);
-#endif
-
-static void run_final(rb_objspace_t *objspace, VALUE obj);
-static int garbage_collect(rb_objspace_t *objspace);
-
-#else
-
 int ruby_gc_stress = 0;
 static long malloc_increase = 0;
 bool dont_gc = false;
@@ -343,8 +133,6 @@
 #endif
 size_t rb_gc_stack_maxsize = 655300*sizeof(VALUE);
 
-#endif
-
 void
 rb_global_variable(VALUE *var)
 {
@@ -407,8 +195,6 @@
 	garbage_collect();
 }
 
-#if WITH_OBJC
-
 static void
 rb_objc_no_gc_error(void)
 { 
@@ -498,131 +284,13 @@
     return ruby_xrealloc(ptr, len);
 }
 
-#else
-
-void *
-ruby_vm_xmalloc(rb_objspace_t *objspace, size_t size)
-{
-    void *mem;
-
-    if (size < 0) {
-	rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
-    }
-    if (size == 0) size = 1;
-    rb_gc_malloc_increase(size);
-    RUBY_CRITICAL(mem = malloc(size));
-    if (!mem) {
-	if (garbage_collect(objspace)) {
-	    RUBY_CRITICAL(mem = malloc(size));
-	}
-	if (!mem) {
-	    rb_memerror();
-	}
-    }
-
-    return mem;
-}
-
-void *
-ruby_xmalloc(size_t size)
-{
-    return ruby_vm_xmalloc(&rb_objspace, size);
-}
-
-void *
-ruby_vm_xmalloc2(rb_objspace_t *objspace, size_t n, size_t size)
-{
-    size_t len = size * n;
-    if (n != 0 && size != len / n) {
-	rb_raise(rb_eArgError, "malloc: possible integer overflow");
-    }
-    return ruby_vm_xmalloc(objspace, len);
-}
-
-void *
-ruby_xmalloc2(size_t n, size_t size)
-{
-    return ruby_vm_xmalloc2(&rb_objspace, n, size);
-}
-
-void *
-ruby_vm_xcalloc(rb_objspace_t *objspace, size_t n, size_t size)
-{
-    void *mem;
-
-    mem = ruby_vm_xmalloc2(objspace, n, size);
-    memset(mem, 0, n * size);
-
-    return mem;
-}
-
-void *
-ruby_xcalloc(size_t n, size_t size)
-{
-    return ruby_vm_xcalloc(&rb_objspace, n, size);
-}
-
-void *
-ruby_vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
-{
-    void *mem;
-
-    if (size < 0) {
-	rb_raise(rb_eArgError, "negative re-allocation size");
-    }
-    if (!ptr) return ruby_xmalloc(size);
-    if (size == 0) size = 1;
-    malloc_increase += size;
-    if (ruby_gc_stress) garbage_collect();
-    RUBY_CRITICAL(mem = realloc(ptr, size));
-    if (!mem) {
-	if (garbage_collect(objspace)) {
-	    RUBY_CRITICAL(mem = realloc(ptr, size));
-	}
-	if (!mem) {
-	    rb_memerror();
-        }
-    }
-
-    return mem;
-}
-
-void *
-ruby_xrealloc(void *ptr, size_t size)
-{
-    return ruby_vm_xrealloc(&rb_objspace, ptr, size);
-}
-
-void *
-ruby_vm_xrealloc2(rb_objspace_t *objspace, void *ptr, size_t n, size_t size)
-{
-    size_t len = size * n;
-    if (n != 0 && size != len / n) {
-	rb_raise(rb_eArgError, "realloc: possible integer overflow");
-    }
-    return ruby_vm_xrealloc(objspace, ptr, len);
-}
-
-void *
-ruby_xrealloc2(void *ptr, size_t n, size_t size)
-{
-    return ruby_vm_xrealloc2(&rb_objspace, ptr, n, size);
-}
-
-#endif
-
 void
 ruby_xfree(void *x)
 {
-#if WITH_OBJC
     if (x != NULL) {
 	auto_zone_retain(__auto_zone, x);
 	malloc_zone_free(__auto_zone, x);
     }
-#else
-    if (x)
-	RUBY_CRITICAL(free(x));
-#endif
 }
 
 
@@ -644,9 +312,7 @@
 {
     int old = dont_gc;
 
-#if WITH_OBJC
     auto_collector_reenable(__auto_zone);
-#endif
     dont_gc = Qfalse;
     return old;
 }
@@ -668,257 +334,14 @@
 {
     int old = dont_gc;
 
-#if WITH_OBJC
     auto_collector_disable(__auto_zone);
-#endif
     dont_gc = Qtrue;
     return old;
 }
 
 VALUE rb_mGC;
 
-#if !WITH_OBJC
-
 void
-rb_gc_register_address(VALUE *addr)
-{
-    rb_objspace_t *objspace = &rb_objspace;
-    struct gc_list *tmp;
-
-    tmp = ALLOC(struct gc_list);
-    tmp->next = global_List;
-    tmp->varptr = addr;
-    global_List = tmp;
-}
-
-void
-rb_register_mark_object(VALUE obj)
-{
-    VALUE ary = GET_THREAD()->vm->mark_object_ary;
-    rb_ary_push(ary, obj);
-}
-
-void
-rb_gc_unregister_address(VALUE *addr)
-{
-    rb_objspace_t *objspace = &rb_objspace;
-    struct gc_list *tmp = global_List;
-
-    if (tmp->varptr == addr) {
-	global_List = tmp->next;
-	RUBY_CRITICAL(free(tmp));
-	return;
-    }
-    while (tmp->next) {
-	if (tmp->next->varptr == addr) {
-	    struct gc_list *t = tmp->next;
-
-	    tmp->next = tmp->next->next;
-	    RUBY_CRITICAL(free(t));
-	    break;
-	}
-	tmp = tmp->next;
-    }
-}
-
-
-static void
-allocate_heaps(rb_objspace_t *objspace, size_t next_heaps_length)
-{
-    struct heaps_slot *p;
-    size_t size;
-
-    size = next_heaps_length*sizeof(struct heaps_slot);
-    RUBY_CRITICAL(
-		  if (heaps_used > 0) {
-		      p = (struct heaps_slot *)realloc(heaps, size);
-		      if (p) heaps = p;
-		  }
-		  else {
-		      p = heaps = (struct heaps_slot *)malloc(size);
-		  }
-		  );
-    if (p == 0) rb_memerror();
-    heaps_length = next_heaps_length;
-}
-
-static void
-assign_heap_slot(rb_objspace_t *objspace)
-{
-    RVALUE *p, *pend, *membase;
-    size_t hi, lo, mid;
-    int objs;
-	
-    objs = HEAP_OBJ_LIMIT;
-    RUBY_CRITICAL(p = (RVALUE*)malloc(HEAP_SIZE));
-    if (p == 0)
-	rb_memerror();
-
-    membase = p;
-    if ((VALUE)p % sizeof(RVALUE) != 0) {
-	p = (RVALUE*)((VALUE)p + sizeof(RVALUE) - ((VALUE)p % sizeof(RVALUE)));
-	if ((HEAP_SIZE - HEAP_OBJ_LIMIT * sizeof(RVALUE)) < ((char*)p - (char*)membase)) {
-	    objs--;
-	}
-    }
-    	
-
-    lo = 0;
-    hi = heaps_used;
-    while (lo < hi) {
-	register RVALUE *mid_membase;
-	mid = (lo + hi) / 2;
-	mid_membase = heaps[mid].membase;
-	if (mid_membase < membase) {
-	    lo = mid + 1;
-	}
-	else if (mid_membase > membase) {
-	    hi = mid;
-	}
-	else {
-	    rb_bug("same heap slot is allocated: %p at %ld", membase, mid);
-	}
-    }
-    if (hi < heaps_used) {
-	MEMMOVE(&heaps[hi+1], &heaps[hi], struct heaps_slot, heaps_used - hi);
-    }
-    heaps[hi].membase = membase;
-    heaps[hi].slot = p;
-    heaps[hi].limit = objs;
-    pend = p + objs;
-    if (lomem == 0 || lomem > p) lomem = p;
-    if (himem < pend) himem = pend;
-    heaps_used++;
-
-    while (p < pend) {
-	p->as.free.flags = 0;
-	p->as.free.next = freelist;
-	freelist = p;
-	p++;
-    }
-}
-
-static void
-init_heap(rb_objspace_t *objspace)
-{
-    size_t add, i;
-
-    add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
-
-    if ((heaps_used + add) > heaps_length) {
-    	allocate_heaps(objspace, heaps_used + add);
-    }
-
-    for (i = 0; i < add; i++) {
-    	assign_heap_slot(objspace);
-    }
-    heaps_inc = 0;
-}
-
-
-static void
-set_heaps_increment(rb_objspace_t *objspace)
-{
-    size_t next_heaps_length = heaps_used * 1.8;
-    heaps_inc = next_heaps_length - heaps_used;
-
-    if (next_heaps_length > heaps_length) {
-	allocate_heaps(objspace, next_heaps_length);
-    }
-}
-
-static int
-heaps_increment(rb_objspace_t *objspace)
-{
-    if (heaps_inc > 0) {
-	assign_heap_slot(objspace);
-	heaps_inc--;
-	return Qtrue;
-    }
-    return Qfalse;
-}
-
-#define RANY(o) ((RVALUE*)(o))
-
-static VALUE
-rb_newobj_from_heap(rb_objspace_t *objspace)
-{
-    VALUE obj;
-	
-    if (ruby_gc_stress || !freelist) {
-    	if (!heaps_increment(objspace) && !garbage_collect(objspace)) {
-	    rb_memerror();
-	}
-    }
-
-    obj = (VALUE)freelist;
-    freelist = freelist->as.free.next;
-
-    MEMZERO((void*)obj, RVALUE, 1);
-#ifdef GC_DEBUG
-    RANY(obj)->file = rb_sourcefile();
-    RANY(obj)->line = rb_sourceline();
-#endif
-
-    return obj;
-}
-
-#if USE_VALUE_CACHE
-static VALUE
-rb_fill_value_cache(rb_thread_t *th)
-{
-    rb_objspace_t *objspace = &rb_objspace;
-    int i;
-    VALUE rv;
-
-    /* LOCK */
-    for (i=0; i<RUBY_VM_VALUE_CACHE_SIZE; i++) {
-	VALUE v = rb_newobj_from_heap(objspace);
-
-	th->value_cache[i] = v;
-	RBASIC(v)->flags = FL_MARK;
-    }
-    th->value_cache_ptr = &th->value_cache[0];
-    rv = rb_newobj_from_heap(objspace);
-    /* UNLOCK */
-    return rv;
-}
-#endif
-
-VALUE
-rb_newobj(void)
-{
-#if USE_VALUE_CACHE
-    rb_thread_t *th = GET_THREAD();
-    VALUE v = *th->value_cache_ptr;
-#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
-    rb_objspace_t *objspace = th->vm->objspace;
-#else
-    rb_objspace_t *objspace = &rb_objspace;
-#endif
-
-    if (v) {
-	RBASIC(v)->flags = 0;
-	th->value_cache_ptr++;
-    }
-    else {
-	v = rb_fill_value_cache(th);
-    }
-
-#if defined(GC_DEBUG)
-    printf("cache index: %d, v: %p, th: %p\n",
-	   th->value_cache_ptr - th->value_cache, v, th);
-#endif
-    return v;
-#else
-    rb_objspace_t *objspace = &rb_objspace;
-    return rb_newobj_from_heap(objspace);
-#endif
-}
-
-#else /* !WITH_OBJC */
-
-void
 rb_objc_wb(void *dst, void *newval)
 {
     if (!SPECIAL_CONST_P(newval)) {
@@ -1053,8 +476,6 @@
     //(*scanner)(context, th->stack, th->stack + th->stack_size);
 } 
 
-#endif /* WITH_OBJC */
-
 NODE*
 rb_node_newnode(enum node_type type, VALUE a0, VALUE a1, VALUE a2)
 {
@@ -1148,960 +569,13 @@
     return ret;
 }
 
-#if !WITH_OBJC
-static void
-init_mark_stack(rb_objspace_t *objspace)
-{
-    mark_stack_overflow = 0;
-    mark_stack_ptr = mark_stack;
-}
-
-#define MARK_STACK_EMPTY (mark_stack_ptr == mark_stack)
-
-
-static void gc_mark(rb_objspace_t *objspace, VALUE ptr, int lev);
-static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev);
-
-static void
-gc_mark_all(rb_objspace_t *objspace)
-{
-    RVALUE *p, *pend;
-    size_t i;
-
-    init_mark_stack(objspace);
-    for (i = 0; i < heaps_used; i++) {
-	p = heaps[i].slot; pend = p + heaps[i].limit;
-	while (p < pend) {
-	    if ((p->as.basic.flags & FL_MARK) &&
-		(p->as.basic.flags != FL_MARK)) {
-		gc_mark_children(objspace, (VALUE)p, 0);
-	    }
-	    p++;
-	}
-    }
-}
-
-static void
-gc_mark_rest(rb_objspace_t *objspace)
-{
-    VALUE tmp_arry[MARK_STACK_MAX];
-    VALUE *p;
-
-    p = (mark_stack_ptr - mark_stack) + tmp_arry;
-    MEMCPY(tmp_arry, mark_stack, VALUE, p - tmp_arry);
-
-    init_mark_stack(objspace);
-    while (p != tmp_arry) {
-	p--;
-	gc_mark_children(objspace, *p, 0);
-    }
-}
-
-static inline int
-is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
-{
-    register RVALUE *p = RANY(ptr);
-    register struct heaps_slot *heap;
-    register size_t hi, lo, mid;
-
-    if (p < lomem || p > himem) return Qfalse;
-    if ((VALUE)p % sizeof(RVALUE) != 0) return Qfalse;
-
-    /* check if p looks like a pointer using bsearch*/
-    lo = 0;
-    hi = heaps_used;
-    while (lo < hi) {
-	mid = (lo + hi) / 2;
-	heap = &heaps[mid];
-	if (heap->slot <= p) {
-	    if (p < heap->slot + heap->limit)
-		return Qtrue;
-	    lo = mid + 1;
-	}
-	else {
-	    hi = mid;
-	}
-    }
-    return Qfalse;
-}
-
-static void
-mark_locations_array(rb_objspace_t *objspace, register VALUE *x, register long n)
-{
-    VALUE v;
-    while (n--) {
-        v = *x;
-        VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v));
-	if (is_pointer_to_heap(objspace, (void *)v)) {
-	    gc_mark(objspace, v, 0);
-	}
-	x++;
-    }
-}
-
-static void
-gc_mark_locations(rb_objspace_t *objspace, VALUE *start, VALUE *end)
-{
-    long n;
-
-    if (end <= start) return;
-    n = end - start;
-    mark_locations_array(&rb_objspace, start,n);
-}
-
 void
-rb_gc_mark_locations(VALUE *start, VALUE *end)
-{
-    gc_mark_locations(&rb_objspace, start, end);
-}
-
-#define rb_gc_mark_locations(start, end) gc_mark_locations(objspace, start, end)
-
-struct mark_tbl_arg {
-    rb_objspace_t *objspace;
-    int lev;
-};
-
-static int
-mark_entry(ID key, VALUE value, st_data_t data)
-{
-    struct mark_tbl_arg *arg = (void*)data;
-    gc_mark(arg->objspace, value, arg->lev);
-    return ST_CONTINUE;
-}
-
-static void
-mark_tbl(rb_objspace_t *objspace, st_table *tbl, int lev)
-{
-    struct mark_tbl_arg arg;
-    if (!tbl) return;
-    arg.objspace = objspace;
-    arg.lev = lev;
-    st_foreach(tbl, mark_entry, (st_data_t)&arg);
-}
-
-void
-rb_mark_tbl(st_table *tbl)
-{
-    mark_tbl(&rb_objspace, tbl, 0);
-}
-
-static int
-mark_key(VALUE key, VALUE value, st_data_t data)
-{
-    struct mark_tbl_arg *arg = (void*)data;
-    gc_mark(arg->objspace, key, arg->lev);
-    return ST_CONTINUE;
-}
-
-static void
-mark_set(rb_objspace_t *objspace, st_table *tbl, int lev)
-{
-    struct mark_tbl_arg arg;
-    if (!tbl) return;
-    arg.objspace = objspace;
-    arg.lev = lev;
-    st_foreach(tbl, mark_key, (st_data_t)&arg);
-}
-
-void
-rb_mark_set(st_table *tbl)
-{
-    mark_set(&rb_objspace, tbl, 0);
-}
-
-static int
-mark_keyvalue(VALUE key, VALUE value, st_data_t data)
-{
-    struct mark_tbl_arg *arg = (void*)data;
-    gc_mark(arg->objspace, key, arg->lev);
-    gc_mark(arg->objspace, value, arg->lev);
-    return ST_CONTINUE;
-}
-
-static void
-mark_hash(rb_objspace_t *objspace, st_table *tbl, int lev)
-{
-    struct mark_tbl_arg arg;
-    if (!tbl) return;
-    arg.objspace = objspace;
-    arg.lev = lev;
-    st_foreach(tbl, mark_keyvalue, (st_data_t)&arg);
-}
-
-void
-rb_mark_hash(st_table *tbl)
-{
-    mark_hash(&rb_objspace, tbl, 0);
-}
-
-void
-rb_gc_mark_maybe(VALUE obj)
-{
-    if (is_pointer_to_heap(&rb_objspace, (void *)obj)) {
-	gc_mark(&rb_objspace, obj, 0);
-    }
-}
-
-#define GC_LEVEL_MAX 250
-
-static void
-gc_mark(rb_objspace_t *objspace, VALUE ptr, int lev)
-{
-    register RVALUE *obj;
-
-    obj = RANY(ptr);
-    if (rb_special_const_p(ptr)) return; /* special const not marked */
-    if (obj->as.basic.flags == 0) return;       /* free cell */
-    if (obj->as.basic.flags & FL_MARK) return;  /* already marked */
-    obj->as.basic.flags |= FL_MARK;
-
-    if (lev > GC_LEVEL_MAX || (lev == 0 && ruby_stack_check())) {
-	if (!mark_stack_overflow) {
-	    if (mark_stack_ptr - mark_stack < MARK_STACK_MAX) {
-		*mark_stack_ptr = ptr;
-		mark_stack_ptr++;
-	    }
-	    else {
-		mark_stack_overflow = 1;
-	    }
-	}
-	return;
-    }
-    gc_mark_children(objspace, ptr, lev+1);
-}
-
-void
-rb_gc_mark(VALUE ptr)
-{
-    gc_mark(&rb_objspace, ptr, 0);
-}
-
-static void
-gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev)
-{
-    register RVALUE *obj = RANY(ptr);
-
-    goto marking;		/* skip */
-
-  again:
-    obj = RANY(ptr);
-    if (rb_special_const_p(ptr)) return; /* special const not marked */
-    if (obj->as.basic.flags == 0) return;       /* free cell */
-    if (obj->as.basic.flags & FL_MARK) return;  /* already marked */
-    obj->as.basic.flags |= FL_MARK;
-
-  marking:
-    if (FL_TEST(obj, FL_EXIVAR)) {
-	rb_mark_generic_ivar(ptr);
-    }
-
-    switch (obj->as.basic.flags & T_MASK) {
-      case T_NIL:
-      case T_FIXNUM:
-	rb_bug("rb_gc_mark() called for broken object");
-	break;
-
-      case T_NODE:
-	switch (nd_type(obj)) {
-	  case NODE_IF:		/* 1,2,3 */
-	  case NODE_FOR:
-	  case NODE_ITER:
-	  case NODE_WHEN:
-	  case NODE_MASGN:
-	  case NODE_RESCUE:
-	  case NODE_RESBODY:
-	  case NODE_CLASS:
-	  case NODE_BLOCK_PASS:
-	    gc_mark(objspace, (VALUE)obj->as.node.u2.node, lev);
-	    /* fall through */
-	  case NODE_BLOCK:	/* 1,3 */
-	  case NODE_OPTBLOCK:
-	  case NODE_ARRAY:
-	  case NODE_DSTR:
-	  case NODE_DXSTR:
-	  case NODE_DREGX:
-	  case NODE_DREGX_ONCE:
-	  case NODE_ENSURE:
-	  case NODE_CALL:
-	  case NODE_DEFS:
-	  case NODE_OP_ASGN1:
-	  case NODE_ARGS:
-	    gc_mark(objspace, (VALUE)obj->as.node.u1.node, lev);
-	    /* fall through */
-	  case NODE_SUPER:	/* 3 */
-	  case NODE_FCALL:
-	  case NODE_DEFN:
-	  case NODE_ARGS_AUX:
-	    ptr = (VALUE)obj->as.node.u3.node;
-	    goto again;
-
-	  case NODE_METHOD:	/* 1,2 */
-	  case NODE_WHILE:
-	  case NODE_UNTIL:
-	  case NODE_AND:
-	  case NODE_OR:
-	  case NODE_CASE:
-	  case NODE_SCLASS:
-	  case NODE_DOT2:
-	  case NODE_DOT3:
-	  case NODE_FLIP2:
-	  case NODE_FLIP3:
-	  case NODE_MATCH2:
-	  case NODE_MATCH3:
-	  case NODE_OP_ASGN_OR:
-	  case NODE_OP_ASGN_AND:
-	  case NODE_MODULE:
-	  case NODE_ALIAS:
-	  case NODE_VALIAS:
-	  case NODE_ARGSCAT:
-	    gc_mark(objspace, (VALUE)obj->as.node.u1.node, lev);
-	    /* fall through */
-	  case NODE_FBODY:	/* 2 */
-	  case NODE_GASGN:
-	  case NODE_LASGN:
-	  case NODE_DASGN:
-	  case NODE_DASGN_CURR:
-	  case NODE_IASGN:
-	  case NODE_IASGN2:
-	  case NODE_CVASGN:
-	  case NODE_COLON3:
-	  case NODE_OPT_N:
-	  case NODE_EVSTR:
-	  case NODE_UNDEF:
-	  case NODE_POSTEXE:
-	    ptr = (VALUE)obj->as.node.u2.node;
-	    goto again;
-
-	  case NODE_HASH:	/* 1 */
-	  case NODE_LIT:
-	  case NODE_STR:
-	  case NODE_XSTR:
-	  case NODE_DEFINED:
-	  case NODE_MATCH:
-	  case NODE_RETURN:
-	  case NODE_BREAK:
-	  case NODE_NEXT:
-	  case NODE_YIELD:
-	  case NODE_COLON2:
-	  case NODE_SPLAT:
-	  case NODE_TO_ARY:
-	    ptr = (VALUE)obj->as.node.u1.node;
-	    goto again;
-
-	  case NODE_SCOPE:	/* 2,3 */
-	  case NODE_CDECL:
-	  case NODE_OPT_ARG:
-	    gc_mark(objspace, (VALUE)obj->as.node.u3.node, lev);
-	    ptr = (VALUE)obj->as.node.u2.node;
-	    goto again;
-
-	  case NODE_ZARRAY:	/* - */
-	  case NODE_ZSUPER:
-	  case NODE_CFUNC:
-	  case NODE_VCALL:
-	  case NODE_GVAR:
-	  case NODE_LVAR:
-	  case NODE_DVAR:
-	  case NODE_IVAR:
-	  case NODE_CVAR:
-	  case NODE_NTH_REF:
-	  case NODE_BACK_REF:
-	  case NODE_REDO:
-	  case NODE_RETRY:
-	  case NODE_SELF:
-	  case NODE_NIL:
-	  case NODE_TRUE:
-	  case NODE_FALSE:
-	  case NODE_ERRINFO:
-	  case NODE_ATTRSET:
-	  case NODE_BLOCK_ARG:
-	    break;
-	  case NODE_ALLOCA:
-	    mark_locations_array(objspace,
-				 (VALUE*)obj->as.node.u1.value,
-				 obj->as.node.u3.cnt);
-	    ptr = (VALUE)obj->as.node.u2.node;
-	    goto again;
-
-	  default:		/* unlisted NODE */
-	    if (is_pointer_to_heap(objspace, obj->as.node.u1.node)) {
-		gc_mark(objspace, (VALUE)obj->as.node.u1.node, lev);
-	    }
-	    if (is_pointer_to_heap(objspace, obj->as.node.u2.node)) {
-		gc_mark(objspace, (VALUE)obj->as.node.u2.node, lev);
-	    }
-	    if (is_pointer_to_heap(objspace, obj->as.node.u3.node)) {
-		gc_mark(objspace, (VALUE)obj->as.node.u3.node, lev);
-	    }
-	}
-	return;			/* no need to mark class. */
-    }
-
-    gc_mark(objspace, obj->as.basic.klass, lev);
-    switch (obj->as.basic.flags & T_MASK) {
-      case T_ICLASS:
-      case T_CLASS:
-      case T_MODULE:
-	mark_tbl(objspace, RCLASS_M_TBL(obj), lev);
-	mark_tbl(objspace, RCLASS_IV_TBL(obj), lev);
-	ptr = RCLASS_SUPER(obj);
-	goto again;
-
-      case T_ARRAY:
-	if (FL_TEST(obj, ELTS_SHARED)) {
-	    ptr = obj->as.array.aux.shared;
-	    goto again;
-	}
-	else {
-	    long i, len = RARRAY_LEN(obj);
-	    VALUE *ptr = RARRAY_PTR(obj);
-	    for (i=0; i < len; i++) {
-		gc_mark(objspace, *ptr++, lev);
-	    }
-	}
-	break;
-
-      case T_HASH:
-	mark_hash(objspace, obj->as.hash.ntbl, lev);
-	ptr = obj->as.hash.ifnone;
-	goto again;
-
-      case T_STRING:
-#define STR_ASSOC FL_USER3   /* copied from string.c */
-	if (FL_TEST(obj, RSTRING_NOEMBED) && FL_ANY(obj, ELTS_SHARED|STR_ASSOC)) {
-	    ptr = obj->as.string.as.heap.aux.shared;
-	    goto again;
-	}
-	break;
-
-      case T_DATA:
-	if (obj->as.data.dmark) (*obj->as.data.dmark)(DATA_PTR(obj));
-	break;
-
-      case T_OBJECT:
-        {
-            long i, len = ROBJECT_NUMIV(obj);
-	    VALUE *ptr = ROBJECT_IVPTR(obj);
-            for (i  = 0; i < len; i++) {
-		gc_mark(objspace, *ptr++, lev);
-            }
-        }
-	break;
-
-      case T_FILE:
-        if (obj->as.file.fptr)
-            gc_mark(objspace, obj->as.file.fptr->tied_io_for_writing, lev);
-        break;
-
-      case T_REGEXP:
-      case T_FLOAT:
-      case T_BIGNUM:
-	break;
-
-      case T_MATCH:
-	gc_mark(objspace, obj->as.match.regexp, lev);
-	if (obj->as.match.str) {
-	    ptr = obj->as.match.str;
-	    goto again;
-	}
-	break;
-
-      case T_RATIONAL:
-	gc_mark(objspace, obj->as.rational.num, lev);
-	gc_mark(objspace, obj->as.rational.den, lev);
-	break;
-
-      case T_COMPLEX:
-	gc_mark(objspace, obj->as.complex.real, lev);
-	gc_mark(objspace, obj->as.complex.image, lev);
-	break;
-
-      case T_STRUCT:
-	{
-	    long len = RSTRUCT_LEN(obj);
-	    VALUE *ptr = RSTRUCT_PTR(obj);
-
-	    while (len--) {
-		gc_mark(objspace, *ptr++, lev);
-	    }
-	}
-	break;
-
-      case T_VALUES:
-	{
-            rb_gc_mark(RVALUES(obj)->v1);
-            rb_gc_mark(RVALUES(obj)->v2);
-            ptr = RVALUES(obj)->v3;
-            goto again;
-	}
-	break;
-
-      default:
-	rb_bug("rb_gc_mark(): unknown data type 0x%lx(%p) %s",
-	       obj->as.basic.flags & T_MASK, obj,
-	       is_pointer_to_heap(objspace, obj) ? "corrupted object" : "non object");
-    }
-}
-
-static void obj_free(rb_objspace_t *, VALUE);
-
-static void
-finalize_list(rb_objspace_t *objspace, RVALUE *p)
-{
-    while (p) {
-	RVALUE *tmp = p->as.free.next;
-	run_final(objspace, (VALUE)p);
-	if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
-            VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
-	    p->as.free.flags = 0;
-	    p->as.free.next = freelist;
-	    freelist = p;
-	}
-	p = tmp;
-    }
-}
-
-static void
-free_unused_heaps(rb_objspace_t *objspace)
-{
-    size_t i, j;
-    RVALUE *last = 0;
-
-    for (i = j = 1; j < heaps_used; i++) {
-	if (heaps[i].limit == 0) {
-	    if (!last) {
-		last = heaps[i].membase;
-	    }
-	    else {
-		free(heaps[i].membase);
-	    }
-	    heaps_used--;
-	}
-	else {
-	    if (i != j) {
-		heaps[j] = heaps[i];
-	    }
-	    j++;
-	}
-    }
-    if (last) {
-	if (last < heaps_freed) {
-	    free(heaps_freed);
-	    heaps_freed = last;
-	}
-	else {
-	    free(last);
-	}
-    }
-}
-
-void rb_gc_abort_threads(void);
-
-static void
-gc_sweep(rb_objspace_t *objspace)
-{
-    RVALUE *p, *pend, *final_list;
-    size_t freed = 0;
-    size_t i;
-    size_t live = 0, free_min = 0, do_heap_free = 0;
-
-    do_heap_free = (heaps_used * HEAP_OBJ_LIMIT) * 0.65;
-    free_min = (heaps_used * HEAP_OBJ_LIMIT)  * 0.2;
-    if (free_min < FREE_MIN) {
-	do_heap_free = heaps_used * HEAP_OBJ_LIMIT;
-        free_min = FREE_MIN;
-    }
-
-    freelist = 0;
-    final_list = deferred_final_list;
-    deferred_final_list = 0;
-    for (i = 0; i < heaps_used; i++) {
-	int n = 0;
-	RVALUE *free = freelist;
-	RVALUE *final = final_list;
-
-	p = heaps[i].slot; pend = p + heaps[i].limit;
-	while (p < pend) {
-	    if (!(p->as.basic.flags & FL_MARK)) {
-		if (p->as.basic.flags) {
-		    obj_free(objspace, (VALUE)p);
-		}
-		if (need_call_final && FL_TEST(p, FL_FINALIZE)) {
-		    p->as.free.flags = FL_MARK; /* remain marked */
-		    p->as.free.next = final_list;
-		    final_list = p;
-		}
-		else {
-                    VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
-		    p->as.free.flags = 0;
-		    p->as.free.next = freelist;
-		    freelist = p;
-		}
-		n++;
-	    }
-	    else if (RBASIC(p)->flags == FL_MARK) {
-		/* objects to be finalized */
-		/* do nothing remain marked */
-	    }
-	    else {
-		RBASIC(p)->flags &= ~FL_MARK;
-		live++;
-	    }
-	    p++;
-	}
-	if (n == heaps[i].limit && freed > do_heap_free) {
-	    RVALUE *pp;
-
-	    heaps[i].limit = 0;
-	    for (pp = final_list; pp != final; pp = pp->as.free.next) {
-		p->as.free.flags |= FL_SINGLETON; /* freeing page mark */
-	    }
-	    freelist = free;	/* cancel this page from freelist */
-	}
-	else {
-	    freed += n;
-	}
-    }
-    if (malloc_increase > malloc_limit) {
-	malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed);
-	if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
-    }
-    malloc_increase = 0;
-    if (freed < free_min) {
-    	set_heaps_increment(objspace);
-	heaps_increment(objspace);
-    }
-    during_gc = 0;
-
-    /* clear finalization list */
-    if (final_list) {
-	deferred_final_list = final_list;
-	return;
-    }
-    free_unused_heaps(objspace);
-}
-
-#endif /* !WITH_OBJC */
-
-void
 rb_gc_force_recycle(VALUE p)
 {
-#if WITH_OBJC
     xfree((void *)p);
-#else
-    VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
-    RANY(p)->as.free.flags = 0;
-    RANY(p)->as.free.next = freelist;
-    freelist = RANY(p);
-#endif
 }
 
-#if !WITH_OBJC
-static void
-obj_free(rb_objspace_t *objspace, VALUE obj)
-{
-    switch (RANY(obj)->as.basic.flags & T_MASK) {
-      case T_NIL:
-      case T_FIXNUM:
-      case T_TRUE:
-      case T_FALSE:
-	rb_bug("obj_free() called for broken object");
-	break;
-    }
-
-    if (FL_TEST(obj, FL_EXIVAR)) {
-	rb_free_generic_ivar((VALUE)obj);
-    }
-
-    switch (RANY(obj)->as.basic.flags & T_MASK) {
-      case T_OBJECT:
-	if (!(RANY(obj)->as.basic.flags & ROBJECT_EMBED) &&
-            RANY(obj)->as.object.as.heap.ivptr) {
-	    RUBY_CRITICAL(free(RANY(obj)->as.object.as.heap.ivptr));
-	}
-	break;
-      case T_MODULE:
-      case T_CLASS:
-	rb_clear_cache_by_class((VALUE)obj);
-	st_free_table(RCLASS_M_TBL(obj));
-	if (RCLASS_IV_TBL(obj)) {
-	    st_free_table(RCLASS_IV_TBL(obj));
-	}
-	if (RCLASS_IV_INDEX_TBL(obj)) {
-	    st_free_table(RCLASS_IV_INDEX_TBL(obj));
-	}
-        RUBY_CRITICAL(free(RANY(obj)->as.klass.ptr));
-	break;
-      case T_STRING:
-	rb_str_free(obj);
-	break;
-      case T_ARRAY:
-	rb_ary_free(obj);
-	break;
-      case T_HASH:
-	if (RANY(obj)->as.hash.ntbl) {
-	    st_free_table(RANY(obj)->as.hash.ntbl);
-	}
-	break;
-      case T_REGEXP:
-	if (RANY(obj)->as.regexp.ptr) {
-	    onig_free(RANY(obj)->as.regexp.ptr);
-	}
-	if (RANY(obj)->as.regexp.str) {
-	    RUBY_CRITICAL(free(RANY(obj)->as.regexp.str));
-	}
-	break;
-      case T_DATA:
-	if (DATA_PTR(obj)) {
-	    if ((long)RANY(obj)->as.data.dfree == -1) {
-		RUBY_CRITICAL(free(DATA_PTR(obj)));
-	    }
-	    else if (RANY(obj)->as.data.dfree) {
-		(*RANY(obj)->as.data.dfree)(DATA_PTR(obj));
-	    }
-	}
-	break;
-      case T_MATCH:
-	if (RANY(obj)->as.match.rmatch) {
-            struct rmatch *rm = RANY(obj)->as.match.rmatch;
-	    onig_region_free(&rm->regs, 0);
-            if (rm->char_offset)
-                RUBY_CRITICAL(free(rm->char_offset));
-	    RUBY_CRITICAL(free(rm));
-	}
-	break;
-      case T_FILE:
-	if (RANY(obj)->as.file.fptr) {
-	    rb_io_fptr_finalize(RANY(obj)->as.file.fptr);
-	}
-	break;
-      case T_RATIONAL:
-      case T_COMPLEX:
-	break;
-      case T_ICLASS:
-	/* iClass shares table with the module */
-	break;
-
-      case T_FLOAT:
-	break;
-      case T_VALUES:
-	break;
-
-      case T_BIGNUM:
-	if (!(RBASIC(obj)->flags & RBIGNUM_EMBED_FLAG) && RBIGNUM_DIGITS(obj)) {
-	    RUBY_CRITICAL(free(RBIGNUM_DIGITS(obj)));
-	}
-	break;
-      case T_NODE:
-	switch (nd_type(obj)) {
-	  case NODE_SCOPE:
-	    if (RANY(obj)->as.node.u1.tbl) {
-		RUBY_CRITICAL(free(RANY(obj)->as.node.u1.tbl));
-	    }
-	    break;
-	  case NODE_ALLOCA:
-	    RUBY_CRITICAL(free(RANY(obj)->as.node.u1.node));
-	    break;
-	}
-	return;			/* no need to free iv_tbl */
-
-      case T_STRUCT:
-	if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 &&
-	    RANY(obj)->as.rstruct.as.heap.ptr) {
-	    RUBY_CRITICAL(free(RANY(obj)->as.rstruct.as.heap.ptr));
-	}
-	break;
-
-      default:
-	rb_bug("gc_sweep(): unknown data type 0x%lx(%p)",
-	       RANY(obj)->as.basic.flags & T_MASK, (void*)obj);
-    }
-}
-
-#ifdef __GNUC__
-#if defined(__human68k__) || defined(DJGPP)
-#undef rb_setjmp
-#undef rb_jmp_buf
-#if defined(__human68k__)
-typedef unsigned long rb_jmp_buf[8];
-__asm__ (".even\n\
-_rb_setjmp:\n\
-	move.l	4(sp),a0\n\
-	movem.l	d3-d7/a3-a5,(a0)\n\
-	moveq.l	#0,d0\n\
-	rts");
-#else
-#if defined(DJGPP)
-typedef unsigned long rb_jmp_buf[6];
-__asm__ (".align 4\n\
-_rb_setjmp:\n\
-	pushl	%ebp\n\
-	movl	%esp,%ebp\n\
-	movl	8(%ebp),%ebp\n\
-	movl	%eax,(%ebp)\n\
-	movl	%ebx,4(%ebp)\n\
-	movl	%ecx,8(%ebp)\n\
-	movl	%edx,12(%ebp)\n\
-	movl	%esi,16(%ebp)\n\
-	movl	%edi,20(%ebp)\n\
-	popl	%ebp\n\
-	xorl	%eax,%eax\n\
-	ret");
-#endif
-#endif
-int rb_setjmp (rb_jmp_buf);
-#endif /* __human68k__ or DJGPP */
-#endif /* __GNUC__ */
-
-#define GC_NOTIFY 0
-
-void rb_vm_mark(void *ptr);
-
-static void
-mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th)
-{
-    rb_jmp_buf save_regs_gc_mark;
-    VALUE *stack_start, *stack_end;
-
-    SET_STACK_END;
-#if STACK_GROW_DIRECTION < 0
-    stack_start = th->machine_stack_end;
-    stack_end = th->machine_stack_start;
-#elif STACK_GROW_DIRECTION > 0
-    stack_start = th->machine_stack_start;
-    stack_end = th->machine_stack_end + 1;
-#else
-    if (th->machine_stack_end < th->machine_stack_start) {
-        stack_start = th->machine_stack_end;
-        stack_end = th->machine_stack_start;
-    }
-    else {
-        stack_start = th->machine_stack_start;
-        stack_end = th->machine_stack_end + 1;
-    }
-#endif
-
-    FLUSH_REGISTER_WINDOWS;
-    /* This assumes that all registers are saved into the jmp_buf (and stack) */
-    rb_setjmp(save_regs_gc_mark);
-    mark_locations_array(objspace,
-			 (VALUE*)save_regs_gc_mark,
-			 sizeof(save_regs_gc_mark) / sizeof(VALUE));
-
-    rb_gc_mark_locations(stack_start, stack_end);
-#ifdef __ia64
-    rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end);
-#endif
-#if defined(__human68k__) || defined(__mc68000__)
-    mark_locations_array((VALUE*)((char*)STACK_END + 2),
-			 (STACK_START - STACK_END));
-#endif
-}
-
-void rb_gc_mark_encodings(void);
-
 static int
-garbage_collect(rb_objspace_t *objspace)
-{
-    struct gc_list *list;
-    rb_thread_t *th = GET_THREAD();
-
-    if (GC_NOTIFY) printf("start garbage_collect()\n");
-
-    if (!heaps) {
-	return Qfalse;
-    }
-
-    if (dont_gc || during_gc) {
-	if (!freelist) {
-            if (!heaps_increment(objspace)) {
-                set_heaps_increment(objspace);
-                heaps_increment(objspace);
-            }
-	}
-	return Qtrue;
-    }
-    during_gc++;
-    objspace->count++;
-
-    SET_STACK_END;
-
-    init_mark_stack(objspace);
-
-    th->vm->self ? rb_gc_mark(th->vm->self) : rb_vm_mark(th->vm);
-
-    if (finalizer_table) {
-	mark_tbl(objspace, finalizer_table, 0);
-    }
-
-    mark_current_machine_context(objspace, th);
-
-    rb_gc_mark_threads();
-    rb_gc_mark_symbols();
-    rb_gc_mark_encodings();
-
-    /* mark protected global variables */
-    for (list = global_List; list; list = list->next) {
-	rb_gc_mark_maybe(*list->varptr);
-    }
-    rb_mark_end_proc();
-    rb_gc_mark_global_tbl();
-
-    mark_tbl(objspace, rb_class_tbl, 0);
-    rb_gc_mark_trap_list();
-
-    /* mark generic instance variables for special constants */
-    rb_mark_generic_ivar_tbl();
-
-    rb_gc_mark_parser();
-
-    /* gc_mark objects whose marking are not completed*/
-    while (!MARK_STACK_EMPTY) {
-	if (mark_stack_overflow) {
-	    gc_mark_all(objspace);
-	}
-	else {
-	    gc_mark_rest(objspace);
-	}
-    }
-
-    gc_sweep(objspace);
-
-    if (GC_NOTIFY) printf("end garbage_collect()\n");
-    return Qtrue;
-}
-
-int
-rb_garbage_collect(void)
-{
-    return garbage_collect(&rb_objspace);
-}
-
-void
-rb_gc_mark_machine_stack(rb_thread_t *th)
-{
-    rb_objspace_t *objspace = &rb_objspace;
-#if STACK_GROW_DIRECTION < 0
-    rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start);
-#elif STACK_GROW_DIRECTION > 0
-    rb_gc_mark_locations(th->machine_stack_start, th->machine_stack_end);
-#else
-    if (th->machine_stack_start < th->machine_stack_end) {
-	rb_gc_mark_locations(th->machine_stack_start, th->machine_stack_end);
-    }
-    else {
-	rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start);
-    }
-#endif
-#ifdef __ia64
-    rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end);
-#endif
-}
-
-#else /* !WITH_OBJC */
-
-static int
 garbage_collect(void)
 {
     if (dont_gc)
@@ -2111,15 +585,10 @@
     return Qtrue;
 }
 
-#endif
-
 void
 rb_gc(void)
 {
     garbage_collect();
-#if !WITH_OBJC
-    rb_gc_finalize_deferred();
-#endif
 }
 
 /*
@@ -2139,20 +608,6 @@
     return Qnil;
 }
 
-#if !WITH_OBJC
-void
-ruby_set_stack_size(size_t size)
-{
-    rb_gc_stack_maxsize = size;
-}
-
-void
-Init_stack(VALUE *addr)
-{
-    ruby_init_stack(addr);
-}
-#endif
-
 #undef ruby_init_stack
 void
 ruby_init_stack(VALUE *addr
@@ -2231,7 +686,6 @@
  *
  */
 
-#if WITH_OBJC
 static bool
 rb_objc_is_placeholder(void *obj)
 {
@@ -2339,51 +793,7 @@
 	ctx->count++;
     }	
 }
-#else
-void
-Init_heap(void)
-{
-    if (!rb_gc_stack_start) {
-	Init_stack(0);
-    }
-    init_heap(&rb_objspace);
-}
 
-static VALUE
-os_obj_of(rb_objspace_t *objspace, VALUE of)
-{
-    size_t i;
-    size_t n = 0;
-
-    for (i = 0; i < heaps_used; i++) {
-	RVALUE *p, *pend;
-
-	p = heaps[i].slot; pend = p + heaps[i].limit;
-	for (;p < pend; p++) {
-	    if (p->as.basic.flags) {
-		switch (BUILTIN_TYPE(p)) {
-		  case T_NONE:
-		  case T_ICLASS:
-		  case T_NODE:
-		  case T_VALUES:
-		    continue;
-		  case T_CLASS:
-		    if (FL_TEST(p, FL_SINGLETON)) continue;
-		  default:
-		    if (!p->as.basic.klass) continue;
-		    if (!of || rb_obj_is_kind_of((VALUE)p, of)) {
-			rb_yield((VALUE)p);
-			n++;
-		    }
-		}
-	    }
-	}
-    }
-
-    return SIZET2NUM(n);
-}
-#endif
-
 /*
  *  call-seq:
  *     ObjectSpace.each_object([module]) {|obj| ... } => fixnum
@@ -2421,6 +831,7 @@
 os_each_obj(int argc, VALUE *argv, VALUE os)
 {
     VALUE of;
+    int count;
 
     rb_secure(4);
     if (argc == 0) {
@@ -2430,9 +841,9 @@
 	rb_scan_args(argc, argv, "01", &of);
     }
     RETURN_ENUMERATOR(os, 1, &of);
-#if WITH_OBJC
+
     /* Class/Module are a special case, because they are not auto objects */
-    int count = rb_objc_yield_classes(of);
+    count = rb_objc_yield_classes(of);
 
     if (of != rb_cClass && of != rb_cModule) {
 	struct rb_objc_recorder_context ctx = {of, count};
@@ -2445,9 +856,6 @@
     }
 
     return INT2FIX(count);
-#else
-    return os_obj_of(&rb_objspace, of);
-#endif
 }
 
 /*
@@ -2458,14 +866,11 @@
  *
  */
 
-#if WITH_OBJC
 static CFMutableDictionaryRef __os_finalizers = NULL;
-#endif
 
 static VALUE
 undefine_final(VALUE os, VALUE obj)
 {
-#if WITH_OBJC
     if (__os_finalizers != NULL)
 	CFDictionaryRemoveValue(__os_finalizers, (const void *)obj);
     
@@ -2475,12 +880,6 @@
     else {
 	FL_UNSET(obj, FL_FINALIZE);
     }
-#else
-    rb_objspace_t *objspace = &rb_objspace;
-    if (finalizer_table) {
-	st_delete(finalizer_table, (st_data_t*)&obj, 0);
-    }
-#endif
     return obj;
 }
 
@@ -2496,7 +895,6 @@
 static VALUE
 define_final(int argc, VALUE *argv, VALUE os)
 {
-#if WITH_OBJC
     VALUE obj, block, table;
 
     if (__os_finalizers == NULL)
@@ -2529,40 +927,12 @@
     else {
 	FL_SET(obj, FL_FINALIZE);
     }
-#else
-    rb_objspace_t *objspace = &rb_objspace;
-    VALUE obj, block, table;
-
-    rb_scan_args(argc, argv, "11", &obj, &block);
-    if (argc == 1) {
-	block = rb_block_proc();
-    }
-    else if (!rb_respond_to(block, rb_intern("call"))) {
-	rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
-		 rb_obj_classname(block));
-    }
-    need_call_final = 1;
-    FL_SET(obj, FL_FINALIZE);
-
-    block = rb_ary_new3(2, INT2FIX(rb_safe_level()), block);
-
-    if (!finalizer_table) {
-	finalizer_table = st_init_numtable();
-    }
-    if (st_lookup(finalizer_table, obj, &table)) {
-	rb_ary_push(table, block);
-    }
-    else {
-	st_add_direct(finalizer_table, obj, rb_ary_new3(1, block));
-    }
-#endif
     return block;
 }
 
 void
 rb_gc_copy_finalizer(VALUE dest, VALUE obj)
 {
-#if WITH_OBJC
     VALUE table;
 
     if (__os_finalizers == NULL)
@@ -2587,55 +957,8 @@
 	CFDictionarySetValue(__os_finalizers, (const void *)dest, 
 	    (const void *)table);	
     }
-#else
-    rb_objspace_t *objspace = &rb_objspace;
-    VALUE table;
-
-    if (!finalizer_table) return;
-    if (!FL_TEST(obj, FL_FINALIZE)) return;
-    if (st_lookup(finalizer_table, obj, &table)) {
-	st_insert(finalizer_table, dest, table);
-    }
-    FL_SET(dest, FL_FINALIZE);
-#endif
 }
 
-#if !WITH_OBJC
-static VALUE
-run_single_final(VALUE arg)
-{
-    VALUE *args = (VALUE *)arg;
-    rb_eval_cmd(args[0], args[1], (int)args[2]);
-    return Qnil;
-}
-
-static void
-run_final(rb_objspace_t *objspace, VALUE obj)
-{
-    long i;
-    int status, critical_save = rb_thread_critical;
-    VALUE args[3], table, objid;
-
-    objid = rb_obj_id(obj);	/* make obj into id */
-    rb_thread_critical = Qtrue;
-    args[1] = 0;
-    args[2] = (VALUE)rb_safe_level();
-    if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
-	if (!args[1] && RARRAY_LEN(table) > 0) {
-	    args[1] = rb_obj_freeze(rb_ary_new3(1, objid));
-	}
-	for (i=0; i<RARRAY_LEN(table); i++) {
-	    VALUE final = RARRAY_PTR(table)[i];
-	    args[0] = RARRAY_PTR(final)[1];
-	    args[2] = FIX2INT(RARRAY_PTR(final)[0]);
-	    rb_protect(run_single_final, (VALUE)args, &status);
-	}
-    }
-    rb_thread_critical = critical_save;
-}
-#endif
-
-#if WITH_OBJC
 static CFMutableArrayRef __exit_finalize = NULL;
 
 static void
@@ -2694,91 +1017,6 @@
     auto_collect(__auto_zone, AUTO_COLLECT_FULL_COLLECTION, NULL);
 }
 
-#else /* WITH_OBJC */
-
-static void
-gc_finalize_deferred(rb_objspace_t *objspace)
-{
-    RVALUE *p = deferred_final_list;
-
-    during_gc++;
-    deferred_final_list = 0;
-    if (p) {
-	finalize_list(objspace, p);
-    }
-    free_unused_heaps(objspace);
-    during_gc = 0;
-}
-
-void
-rb_gc_finalize_deferred(void)
-{
-    gc_finalize_deferred(&rb_objspace);
-}
-
-void
-rb_gc_call_finalizer_at_exit(void)
-{
-    rb_objspace_t *objspace = &rb_objspace;
-    RVALUE *p, *pend;
-    size_t i;
-
-    /* finalizers are part of garbage collection */
-    during_gc++;
-    /* run finalizers */
-    if (need_call_final) {
-	p = deferred_final_list;
-	deferred_final_list = 0;
-	finalize_list(objspace, p);
-	for (i = 0; i < heaps_used; i++) {
-	    p = heaps[i].slot; pend = p + heaps[i].limit;
-	    while (p < pend) {
-		if (FL_TEST(p, FL_FINALIZE)) {
-		    FL_UNSET(p, FL_FINALIZE);
-		    p->as.basic.klass = 0;
-		    run_final(objspace, (VALUE)p);
-		}
-		p++;
-	    }
-	}
-    }
-    /* run data object's finalizers */
-    for (i = 0; i < heaps_used; i++) {
-	p = heaps[i].slot; pend = p + heaps[i].limit;
-	while (p < pend) {
-	    if (BUILTIN_TYPE(p) == T_DATA &&
-		DATA_PTR(p) && RANY(p)->as.data.dfree &&
-		RANY(p)->as.basic.klass != rb_cThread) {
-		p->as.free.flags = 0;
-		if ((long)RANY(p)->as.data.dfree == -1) {
-		    RUBY_CRITICAL(free(DATA_PTR(p)));
-		}
-		else if (RANY(p)->as.data.dfree) {
-		    (*RANY(p)->as.data.dfree)(DATA_PTR(p));
-		}
-                VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
-	    }
-	    else if (BUILTIN_TYPE(p) == T_FILE) {
-		if (rb_io_fptr_finalize(RANY(p)->as.file.fptr)) {
-		    p->as.free.flags = 0;
-                    VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
-		}
-	    }
-	    p++;
-	}
-    }
-    during_gc = 0;
-}
-
-void
-rb_gc(void)
-{
-    rb_objspace_t *objspace = &rb_objspace;
-    garbage_collect(objspace);
-    gc_finalize_deferred(objspace);
-}
-#endif
-
 /*
  *  call-seq:
  *     ObjectSpace._id2ref(object_id) -> an_object
@@ -2800,9 +1038,6 @@
 #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
 #define NUM2PTR(x) NUM2ULL(x)
 #endif
-#if !WITH_OBJC
-    rb_objspace_t *objspace = &rb_objspace;
-#endif
     VALUE ptr;
     void *p0;
 
@@ -2813,22 +1048,9 @@
     if (ptr == Qtrue) return Qtrue;
     if (ptr == Qfalse) return Qfalse;
     if (ptr == Qnil) return Qnil;
-#if WITH_OBJC
     if (FIXNUM_P(ptr) || SYMBOL_P(ptr))
 	return ptr;
-#else
-    if (FIXNUM_P(ptr)) return (VALUE)ptr;
-    ptr = objid ^ FIXNUM_FLAG;	/* unset FIXNUM_FLAG */
 
-    if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
-        ID symid = ptr / sizeof(RVALUE);
-        if (rb_id2name(symid) == 0)
-	    rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
-	return ID2SYM(symid);
-    }
-#endif
-
-#if WITH_OBJC
     if (auto_zone_is_valid_pointer(auto_zone(), p0)) {
 	auto_memory_type_t type = 
 	    auto_zone_get_layout_type_no_lock(__auto_zone, p0);
@@ -2839,16 +1061,6 @@
 	    return (VALUE)p0;
     }
     rb_raise(rb_eRangeError, "%p is not id value", p0);
-#else
-    if (!is_pointer_to_heap(objspace, (void *)ptr) ||
-	BUILTIN_TYPE(ptr) >= T_VALUES || BUILTIN_TYPE(ptr) == T_ICLASS) {
-	rb_raise(rb_eRangeError, "%p is not id value", p0);
-    }
-    if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) {
-	rb_raise(rb_eRangeError, "%p is recycled object", p0);
-    }
-    return (VALUE)ptr;
-#endif
 }
 
 /*
@@ -2881,47 +1093,7 @@
 VALUE
 rb_obj_id(VALUE obj)
 {
-    /*
-     *                32-bit VALUE space
-     *          MSB ------------------------ LSB
-     *  false   00000000000000000000000000000000
-     *  true    00000000000000000000000000000010
-     *  nil     00000000000000000000000000000100
-     *  undef   00000000000000000000000000000110
-     *  symbol  ssssssssssssssssssssssss00001110
-     *  object  oooooooooooooooooooooooooooooo00        = 0 (mod sizeof(RVALUE))
-     *  fixnum  fffffffffffffffffffffffffffffff1
-     *
-     *                    object_id space
-     *                                       LSB
-     *  false   00000000000000000000000000000000
-     *  true    00000000000000000000000000000010
-     *  nil     00000000000000000000000000000100
-     *  undef   00000000000000000000000000000110
-     *  symbol   000SSSSSSSSSSSSSSSSSSSSSSSSSSS0        S...S % A = 4 (S...S = s...s * A + 4)
-     *  object   oooooooooooooooooooooooooooooo0        o...o % A = 0
-     *  fixnum  fffffffffffffffffffffffffffffff1        bignum if required
-     *
-     *  where A = sizeof(RVALUE)/4
-     *
-     *  sizeof(RVALUE) is
-     *  20 if 32-bit, double is 4-byte aligned
-     *  24 if 32-bit, double is 8-byte aligned
-     *  40 if 64-bit
-     */
-#if !WITH_OBJC
-    if (TYPE(obj) == T_SYMBOL) {
-        return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
-    }
-#endif
-    if (SPECIAL_CONST_P(obj)) {
-        return LONG2NUM((SIGNED_VALUE)obj);
-    }
-#if WITH_OBJC
     return (VALUE)LONG2NUM((SIGNED_VALUE)obj);
-#else
-    return (VALUE)((SIGNED_VALUE)obj|FIXNUM_FLAG);
-#endif
 }
 
 /*
@@ -2947,9 +1119,9 @@
 static VALUE
 count_objects(int argc, VALUE *argv, VALUE os)
 {
-#if WITH_OBJC
+    /* TODO implement me! */
     return rb_hash_new();
-#else
+#if 0
     rb_objspace_t *objspace = &rb_objspace;
     size_t counts[T_MASK+1];
     size_t freed = 0;
@@ -3035,18 +1207,12 @@
  *
  */
 
-#if WITH_OBJC
 static long _gc_count = 0;
-#endif
 
 static VALUE
 gc_count(VALUE self)
 {
-#if WITH_OBJC
     return UINT2NUM(_gc_count);
-#else
-    return UINT2NUM((&rb_objspace)->count);
-#endif
 }
 
 /*
@@ -3055,7 +1221,6 @@
  *  are also available via the <code>ObjectSpace</code> module.
  */
 
-#if WITH_OBJC
 static void (*old_batch_invalidate)(auto_zone_t *, 
     auto_zone_foreach_object_t, auto_zone_cursor_t, size_t);
 
@@ -3139,20 +1304,16 @@
      */
     _gc_count++;
 }
-#endif
 
 void
 Init_PreGC(void)
 {
-#if WITH_OBJC
     auto_collection_control_t *control;
 
     __auto_zone = auto_zone();
     
     if (__auto_zone == NULL)
 	rb_objc_no_gc_error();
-    
-    //auto_zone_register_thread(__auto_zone);
 
     control = auto_collection_parameters(__auto_zone);
     control->scan_external_callout = 
@@ -3162,19 +1323,16 @@
 		       | AUTO_LOG_UNUSUAL;
     old_batch_invalidate = control->batch_invalidate;
     control->batch_invalidate = rb_objc_batch_invalidate;
-#endif
 }
 
 void
 Init_PostGC(void)
 {
-#if WITH_OBJC
-# if 0
+#if 0
     /* It is better to let Foundation start the dedicated collection thread
      * when necessary. 
      */
     objc_startCollectorThread();
-# endif
 #endif
 }
 
@@ -3209,4 +1367,4 @@
     rb_define_method(rb_mKernel, "object_id", rb_obj_id, 0);
 
     rb_define_module_function(rb_mObSpace, "count_objects", count_objects, -1);
-}
+}
\ No newline at end of file

Modified: MacRuby/branches/lrz_unstable/hash.c
===================================================================
--- MacRuby/branches/lrz_unstable/hash.c	2008-08-15 06:08:01 UTC (rev 447)
+++ MacRuby/branches/lrz_unstable/hash.c	2008-08-16 02:25:22 UTC (rev 448)
@@ -1,31 +1,24 @@
-/**********************************************************************
+/* 
+ * MacRuby implementation of Ruby 1.9's hash.c.
+ *
+ * This file is covered by the Ruby license. See COPYING for more details.
+ * 
+ * Copyright (C) 2007-2008, Apple Inc. All rights reserved.
+ * Copyright (C) 1993-2007 Yukihiro Matsumoto
+ * Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ * Copyright (C) 2000 Information-technology Promotion Agency, Japan
+ */
 
-  hash.c -
-
-  $Author: knu $
-  created at: Mon Nov 22 18:51:18 JST 1993
-
-  Copyright (C) 1993-2007 Yukihiro Matsumoto
-  Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
-  Copyright (C) 2000  Information-technology Promotion Agency, Japan
-
-**********************************************************************/
-
 #include "ruby/ruby.h"
 #include "ruby/st.h"
 #include "ruby/util.h"
 #include "ruby/signal.h"
 #include "id.h"
 
-#ifdef __APPLE__
 #include <crt_externs.h>
-#endif
 
 static VALUE rb_hash_s_try_convert(VALUE, VALUE);
 
-#define HASH_DELETED  FL_USER1
-#define HASH_PROC_DEFAULT FL_USER2
-
 VALUE
 rb_hash_freeze(VALUE hash)
 {
@@ -33,91 +26,19 @@
 }
 
 VALUE rb_cHash;
-#if WITH_OBJC
 VALUE rb_cCFHash;
 VALUE rb_cNSHash;
 VALUE rb_cNSMutableHash;
-#endif
 
 static VALUE envtbl;
 static ID id_hash, id_yield, id_default;
 
-#if !WITH_OBJC
-static VALUE
-eql(VALUE *args)
-{
-    return (VALUE)rb_eql(args[0], args[1]);
-}
-
-int
-rb_any_cmp(VALUE a, VALUE b)
-{
-    VALUE args[2];
-
-    if (a == b) return 0;
-    if (a == Qundef || b == Qundef) return -1;
-    if (FIXNUM_P(a) && FIXNUM_P(b)) {
-	return a != b;
-    }
-    if (SYMBOL_P(a) && SYMBOL_P(b)) {
-	return a != b;
-    }
-    if (TYPE(a) == T_STRING && RBASIC(a)->klass == rb_cString &&
-	TYPE(b) == T_STRING && RBASIC(b)->klass == rb_cString) {
-	return rb_str_hash_cmp(a, b);
-    }
-
-    args[0] = a;
-    args[1] = b;
-    return !rb_with_disable_interrupt(eql, (VALUE)args);
-}
-#endif
-
 VALUE
 rb_hash(VALUE obj)
 {
     return rb_funcall(obj, id_hash, 0);
 }
 
-#if !WITH_OBJC
-static int
-rb_any_hash(VALUE a)
-{
-    VALUE hval;
-    int hnum;
-
-    switch (TYPE(a)) {
-      case T_FIXNUM:
-      case T_SYMBOL:
-	hnum = (int)a;
-	break;
-
-      case T_STRING:
-	hnum = rb_str_hash(a);
-	break;
-
-      default:
-	hval = rb_funcall(a, id_hash, 0);
-	if (!FIXNUM_P(hval)) {
-	    hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
-	}
-	hnum = (int)FIX2LONG(hval);
-    }
-    hnum <<= 1;
-    return RSHIFT(hnum, 1);
-}
-
-static const struct st_hash_type objhash = {
-    rb_any_cmp,
-    rb_any_hash,
-};
-
-static const struct st_hash_type identhash = {
-    st_numcmp,
-    st_numhash,
-};
-#endif
-
 typedef int st_foreach_func(st_data_t, st_data_t, st_data_t);
 
 struct foreach_safe_arg {
@@ -152,67 +73,9 @@
     }
 }
 
-#if !WITH_OBJC
-typedef int rb_foreach_func(VALUE, VALUE, VALUE);
-
-struct hash_foreach_arg {
-    VALUE hash;
-    rb_foreach_func *func;
-    VALUE arg;
-};
-
-static int
-hash_foreach_iter(VALUE key, VALUE value, struct hash_foreach_arg *arg)
-{
-    int status;
-    st_table *tbl;
-
-    tbl = RHASH(arg->hash)->ntbl;
-    if (key == Qundef) return ST_CONTINUE;
-    status = (*arg->func)(key, value, arg->arg);
-    if (RHASH(arg->hash)->ntbl != tbl) {
-	rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
-    }
-    switch (status) {
-      case ST_DELETE:
-	st_delete_safe(tbl, (st_data_t*)&key, 0, Qundef);
-	FL_SET(arg->hash, HASH_DELETED);
-      case ST_CONTINUE:
-	break;
-      case ST_STOP:
-	return ST_STOP;
-    }
-    return ST_CHECK;
-}
-
-static VALUE
-hash_foreach_ensure(VALUE hash)
-{
-    RHASH(hash)->iter_lev--;
-
-    if (RHASH(hash)->iter_lev == 0) {
-	if (FL_TEST(hash, HASH_DELETED)) {
-	    st_cleanup_safe(RHASH(hash)->ntbl, Qundef);
-	    FL_UNSET(hash, HASH_DELETED);
-	}
-    }
-    return 0;
-}
-
-static VALUE
-hash_foreach_call(struct hash_foreach_arg *arg)
-{
-    if (st_foreach(RHASH(arg->hash)->ntbl, hash_foreach_iter, (st_data_t)arg)) {
- 	rb_raise(rb_eRuntimeError, "hash modified during iteration");
-    }
-    return Qnil;
-}
-#endif
-
 void
 rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
 {
-#if WITH_OBJC
     CFIndex i, count;
     const void **keys;
     const void **values;
@@ -230,21 +93,8 @@
 	if ((*func)(OC2RB(keys[i]), OC2RB(values[i]), farg) != ST_CONTINUE)
 	    break;
     }
-#else
-    struct hash_foreach_arg arg;
-
-    if (!RHASH(hash)->ntbl)
-        return;
-    RHASH(hash)->iter_lev++;
-    arg.hash = hash;
-    arg.func = (rb_foreach_func *)func;
-    arg.arg  = farg;
-    rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
-#endif
 }
 
-#if WITH_OBJC
-
 # define HASH_KEY_CALLBACKS(h) \
   ((CFDictionaryKeyCallBacks *)((uint8_t *)h + 52))
 
@@ -288,12 +138,10 @@
     GC_WB(&s->ifnone, ifnone);
     s->has_proc_default = has_proc_default;
 }
-#endif
 
 static VALUE
 hash_alloc(VALUE klass)
 {
-#if WITH_OBJC
     CFMutableDictionaryRef hash;
 
     hash = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
@@ -301,12 +149,7 @@
 	*(Class *)hash = (Class)klass;
 
     CFMakeCollectable(hash);
-#else
-    NEWOBJ(hash, struct RHash);
-    OBJSETUP(hash, klass, T_HASH);
 
-    hash->ifnone = Qnil;
-#endif
     return (VALUE)hash;
 }
 
@@ -332,15 +175,9 @@
 VALUE
 rb_hash_new(void)
 {
-#if WITH_OBJC
     return hash_alloc(0);
-#else
-    return hash_alloc(rb_cHash);
-#endif
 }
 
-#if WITH_OBJC
-
 static inline void
 rb_hash_modify_check(VALUE hash)
 {
@@ -359,34 +196,6 @@
 
 #define rb_hash_modify rb_hash_modify_check
 
-#else
-
-static void
-rb_hash_modify_check(VALUE hash)
-{
-    if (OBJ_FROZEN(hash)) rb_error_frozen("hash");
-    if (!OBJ_TAINTED(hash) && rb_safe_level() >= 4)
-	rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
-}
-
-struct st_table *
-rb_hash_tbl(VALUE hash)
-{
-    if (!RHASH(hash)->ntbl) {
-	GC_WB(&RHASH(hash)->ntbl, st_init_table(&objhash));
-    }
-    return RHASH(hash)->ntbl;
-}
-
-static void
-rb_hash_modify(VALUE hash)
-{
-    rb_hash_modify_check(hash);
-    rb_hash_tbl(hash);
-}
-#endif
-
-
 /*
  *  call-seq:
  *     Hash.new                          => hash
@@ -427,31 +236,18 @@
 {
     VALUE ifnone;
 
-#if WITH_OBJC
     hash = (VALUE)objc_msgSend((id)hash, selInit);
-#else
-    rb_hash_modify(hash);
-#endif
 
     if (rb_block_given_p()) {
 	if (argc > 0) {
 	    rb_raise(rb_eArgError, "wrong number of arguments");
 	}
-#if WITH_OBJC
 	rb_objc_hash_set_struct(hash, rb_block_proc(), true);
-#else
-	RHASH(hash)->ifnone = rb_block_proc();
-	FL_SET(hash, HASH_PROC_DEFAULT);
-#endif
     }
     else {
 	rb_scan_args(argc, argv, "01", &ifnone);
-#if WITH_OBJC
 	if (ifnone != Qnil)
 	    rb_objc_hash_set_struct(hash, ifnone, false);
-#else
-	RHASH(hash)->ifnone = ifnone;
-#endif
     }
 
     return hash;
@@ -479,7 +275,6 @@
     if (argc == 1) {
 	tmp = rb_hash_s_try_convert(Qnil, argv[0]);
 	if (!NIL_P(tmp)) {
-#if WITH_OBJC
 	    CFIndex i, count;
 	    const void **keys;
 	    const void **values;
@@ -499,13 +294,6 @@
 			RB2OC(keys[i]), RB2OC(values[i]));
 
 	    return hash;
-#else
-	    hash = hash_alloc(klass);
-	    if (RHASH(argv[0])->ntbl) {
-		GC_WB(&RHASH(hash)->ntbl, st_copy(RHASH(argv[0])->ntbl));
-	    }
-#endif
-	    return hash;
 	}
 
 	tmp = rb_check_array_type(argv[0]);
@@ -558,15 +346,6 @@
     return rb_check_convert_type(hash, T_HASH, "Hash", "to_hash");
 }
 
-#if !WITH_OBJC
-static int
-rb_hash_rehash_i(VALUE key, VALUE value, st_table *tbl)
-{
-    if (key != Qundef) st_insert(tbl, key, value);
-    return ST_CONTINUE;
-}
-#endif
-
 /*
  *  call-seq:
  *     hsh.rehash -> hsh
@@ -590,7 +369,6 @@
 static VALUE
 rb_hash_rehash(VALUE hash)
 {
-#if WITH_OBJC
     CFIndex i, count;
     const void **keys;
     const void **values;
@@ -612,22 +390,6 @@
 	    (const void *)keys[i], (const void *)values[i]);
 
     return hash;
-#else
-    st_table *tbl;
-
-    if (RHASH(hash)->iter_lev > 0) {
-	rb_raise(rb_eRuntimeError, "rehash during iteration");
-    }
-    rb_hash_modify_check(hash);
-    if (!RHASH(hash)->ntbl)
-        return hash;
-    tbl = st_init_table_with_size(RHASH(hash)->ntbl->type, RHASH(hash)->ntbl->num_entries);
-    rb_hash_foreach(hash, rb_hash_rehash_i, (st_data_t)tbl);
-    st_free_table(RHASH(hash)->ntbl);
-    GC_WB(&RHASH(hash)->ntbl, tbl);
-
-    return hash;
-#endif
 }
 
 /*
@@ -649,17 +411,11 @@
 {
     VALUE val;
 
-#if WITH_OBJC
     if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)hash, (const void *)RB2OC(key),
 	(const void **)&val)) {
 	return rb_funcall(hash, id_default, 1, key);
     }
     val = OC2RB(val);
-#else
-    if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
-	return rb_funcall(hash, id_default, 1, key);
-    }
-#endif
     return val;
 }
 
@@ -668,17 +424,11 @@
 {
     VALUE val;
 
-#if WITH_OBJC
     if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)hash, (const void *)RB2OC(key),
 	(const void **)&val)) {
 	return Qnil;
     }
     val = OC2RB(val);
-#else
-    if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
-	return Qnil; /* without Hash#default */
-    }
-#endif
     return val;
 }
 
@@ -724,12 +474,8 @@
     if (block_given && argc == 2) {
 	rb_warn("block supersedes default value argument");
     }
-#if WITH_OBJC
     if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)hash, (const void *)RB2OC(key),
 	(const void **)&val)) {
-#else
-    if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
-#endif
 	if (block_given) return rb_yield(key);
 	if (argc == 1) {
 	    rb_raise(rb_eKeyError, "key not found");
@@ -763,7 +509,6 @@
 static VALUE
 rb_hash_default(int argc, VALUE *argv, VALUE hash)
 {
-#if WITH_OBJC
     struct rb_objc_hash_struct *s = rb_objc_hash_get_struct(hash);
     VALUE key;
 
@@ -776,16 +521,6 @@
 	return rb_funcall(s->ifnone, id_yield, 2, hash, key);
     }
     return s->ifnone;
-#else
-    VALUE key;
-
-    rb_scan_args(argc, argv, "01", &key);
-    if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
-	if (argc == 0) return Qnil;
-	return rb_funcall(RHASH(hash)->ifnone, id_yield, 2, hash, key);
-    }
-    return RHASH(hash)->ifnone;
-#endif
 }
 
 /*
@@ -812,12 +547,7 @@
 rb_hash_set_default(VALUE hash, VALUE ifnone)
 {
     rb_hash_modify(hash);
-#if WITH_OBJC
     rb_objc_hash_set_struct(hash, ifnone, false);
-#else
-    RHASH(hash)->ifnone = ifnone;
-    FL_UNSET(hash, HASH_PROC_DEFAULT);
-#endif
     return ifnone;
 }
 
@@ -839,17 +569,10 @@
 static VALUE
 rb_hash_default_proc(VALUE hash)
 {
-#if WITH_OBJC
     struct rb_objc_hash_struct *s = rb_objc_hash_get_struct(hash);
     if (s != NULL && s->has_proc_default)
 	return s->ifnone;
     return Qnil;
-#else
-    if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
-	return RHASH(hash)->ifnone;
-    }
-    return Qnil;
-#endif
 }
 
 static int
@@ -898,7 +621,6 @@
 static VALUE
 rb_hash_delete_key(VALUE hash, VALUE key)
 {
-#if WITH_OBJC
     VALUE val;
     id ockey = RB2OC(key);
     if (CFDictionaryGetValueIfPresent((CFDictionaryRef)hash,
@@ -908,21 +630,6 @@
 	return OC2RB(val);
     }
     return Qundef;
-#else
-    st_data_t ktmp = (st_data_t)key, val;
-
-    if (!RHASH(hash)->ntbl)
-        return Qundef;
-    if (RHASH(hash)->iter_lev > 0) {
-	if (st_delete_safe(RHASH(hash)->ntbl, &ktmp, &val, Qundef)) {
-	    FL_SET(hash, HASH_DELETED);
-	    return (VALUE)val;
-	}
-    }
-    else if (st_delete(RHASH(hash)->ntbl, &ktmp, &val))
-	return (VALUE)val;
-    return Qundef;
-#endif
 }
 
 /*
@@ -957,32 +664,6 @@
     return Qnil;
 }
 
-#if !WITH_OBJC
-struct shift_var {
-    VALUE key;
-    VALUE val;
-};
-
-static int
-shift_i(VALUE key, VALUE value, struct shift_var *var)
-{
-    if (key == Qundef) return ST_CONTINUE;
-    if (var->key != Qundef) return ST_STOP;
-    var->key = key;
-    var->val = value;
-    return ST_DELETE;
-}
-
-static int
-shift_i_safe(VALUE key, VALUE value, struct shift_var *var)
-{
-    if (key == Qundef) return ST_CONTINUE;
-    var->key = key;
-    var->val = value;
-    return ST_STOP;
-}
-#endif
-
 /*
  *  call-seq:
  *     hsh.shift -> anArray or obj
@@ -996,14 +677,11 @@
  *     h         #=> {2=>"b", 3=>"c"}
  */
 
-#if WITH_OBJC
 static VALUE rb_hash_keys(VALUE);
-#endif
 
 static VALUE
 rb_hash_shift(VALUE hash)
 {
-#if WITH_OBJC
     VALUE keys, key, val;
 
     keys = rb_hash_keys(hash);
@@ -1023,27 +701,6 @@
     rb_hash_delete(hash, key);
 
     return rb_assoc_new(key, val);
-#else
-    struct shift_var var;
-
-    rb_hash_modify(hash);
-    var.key = Qundef;
-    rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i,
-		    (st_data_t)&var);
-
-    if (var.key != Qundef) {
-	if (RHASH(hash)->iter_lev > 0) {
-	    rb_hash_delete_key(hash, var.key);
-	}
-	return rb_assoc_new(var.key, var.val);
-    }
-    else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
-	return rb_funcall(RHASH(hash)->ifnone, id_yield, 2, hash, Qnil);
-    }
-    else {
-	return RHASH(hash)->ifnone;
-    }
-#endif
 }
 
 static int
@@ -1088,7 +745,6 @@
 VALUE
 rb_hash_reject_bang(VALUE hash)
 {
-#if WITH_OBJC
     CFIndex n;
 
     RETURN_ENUMERATOR(hash, 0, 0);
@@ -1097,17 +753,6 @@
     if (n == CFDictionaryGetCount((CFDictionaryRef)hash))
 	return Qnil;
     return hash;
-#else
-    int n;
-
-    RETURN_ENUMERATOR(hash, 0, 0);
-    if (!RHASH(hash)->ntbl)
-        return Qnil;
-    n = RHASH(hash)->ntbl->num_entries;
-    rb_hash_delete_if(hash);
-    if (n == RHASH(hash)->ntbl->num_entries) return Qnil;
-    return hash;
-#endif
 }
 
 /*
@@ -1180,14 +825,6 @@
     return result;
 }
 
-#if !WITH_OBJC
-static int
-clear_i(VALUE key, VALUE value, VALUE dummy)
-{
-    return ST_DELETE;
-}
-#endif
-
 /*
  *  call-seq:
  *     hsh.clear -> hsh
@@ -1203,18 +840,7 @@
 rb_hash_clear(VALUE hash)
 {
     rb_hash_modify_check(hash);
-#if WITH_OBJC
     CFDictionaryRemoveAllValues((CFMutableDictionaryRef)hash);
-#else
-    if (!RHASH(hash)->ntbl)
-        return hash;
-    if (RHASH(hash)->ntbl->num_entries > 0) {
-	if (RHASH(hash)->iter_lev > 0)
-	    rb_hash_foreach(hash, clear_i, 0);
-	else
-	    st_clear(RHASH(hash)->ntbl);
-    }
-#endif
 
     return hash;
 }
@@ -1241,18 +867,8 @@
 rb_hash_aset(VALUE hash, VALUE key, VALUE val)
 {
     rb_hash_modify(hash);
-#if WITH_OBJC
     CFDictionarySetValue((CFMutableDictionaryRef)hash, (const void *)RB2OC(key),
 	(const void *)RB2OC(val));
-#else
-    if (RHASH(hash)->ntbl->type == &identhash ||
-	TYPE(key) != T_STRING || st_lookup(RHASH(hash)->ntbl, key, 0)) {
-	st_insert(RHASH(hash)->ntbl, key, val);
-    }
-    else {
-	st_add_direct(RHASH(hash)->ntbl, rb_str_new4(key), val);
-    }
-#endif
     return val;
 }
 
@@ -1285,21 +901,11 @@
     if (hash == hash2) return hash;
     rb_hash_clear(hash);
     rb_hash_foreach(hash2, replace_i, hash);
-#if WITH_OBJC
     {
 	struct rb_objc_hash_struct *s = rb_objc_hash_get_struct(hash2);
 	if (s != NULL)
 	    rb_objc_hash_set_struct(hash, s->ifnone, s->has_proc_default);
     }
-#else
-    RHASH(hash)->ifnone = RHASH(hash2)->ifnone;
-    if (FL_TEST(hash2, HASH_PROC_DEFAULT)) {
-	FL_SET(hash, HASH_PROC_DEFAULT);
-    }
-    else {
-	FL_UNSET(hash, HASH_PROC_DEFAULT);
-    }
-#endif
 
     return hash;
 }
@@ -1320,13 +926,7 @@
 static VALUE
 rb_hash_size(VALUE hash)
 {
-#if WITH_OBJC
     return INT2FIX(CFDictionaryGetCount((CFDictionaryRef)hash));
-#else
-    if (!RHASH(hash)->ntbl)
-        return INT2FIX(0);
-    return INT2FIX(RHASH(hash)->ntbl->num_entries);
-#endif
 }
 
 
@@ -1485,15 +1085,9 @@
     }
     str2 = rb_inspect(key);
     rb_str_buf_append(str, str2);
-#if !WITH_OBJC
-    OBJ_INFECT(str, str2);
-#endif
     rb_str_buf_cat2(str, "=>");
     str2 = rb_inspect(value);
     rb_str_buf_append(str, str2);
-#if !WITH_OBJC
-    OBJ_INFECT(str, str2);
-#endif
 
     return ST_CONTINUE;
 }
@@ -1624,33 +1218,12 @@
 static VALUE
 rb_hash_has_key(VALUE hash, VALUE key)
 {
-#if WITH_OBJC
     if (CFDictionaryContainsKey((CFDictionaryRef)hash, (const void *)RB2OC(key)))
 	return Qtrue;
-#else
-    if (!RHASH(hash)->ntbl)
-        return Qfalse;
-    if (st_lookup(RHASH(hash)->ntbl, key, 0)) {
-	return Qtrue;
-    }
-#endif
 
     return Qfalse;
 }
 
-#if !WITH_OBJC
-static int
-rb_hash_search_value(VALUE key, VALUE value, VALUE *data)
-{
-    if (key == Qundef) return ST_CONTINUE;
-    if (rb_equal(value, data[1])) {
-	data[0] = Qtrue;
-	return ST_STOP;
-    }
-    return ST_CONTINUE;
-}
-#endif
-
 /*
  *  call-seq:
  *     hsh.has_value?(value)    => true or false
@@ -1667,58 +1240,11 @@
 static VALUE
 rb_hash_has_value(VALUE hash, VALUE val)
 {
-#if WITH_OBJC
     return CFDictionaryContainsValue((CFDictionaryRef)hash, (const void *)RB2OC(val))
 	? Qtrue : Qfalse;
-#else
-    VALUE data[2];
-
-    data[0] = Qfalse;
-    data[1] = val;
-    rb_hash_foreach(hash, rb_hash_search_value, (st_data_t)data);
-    return data[0];
-#endif
 }
 
-#if !WITH_OBJC
-struct equal_data {
-    VALUE result;
-    st_table *tbl;
-    int eql;
-};
-
-static int
-eql_i(VALUE key, VALUE val1, struct equal_data *data)
-{
-    VALUE val2;
-
-    if (key == Qundef) return ST_CONTINUE;
-    if (!st_lookup(data->tbl, key, &val2)) {
-	data->result = Qfalse;
-	return ST_STOP;
-    }
-    if (!(data->eql ? rb_eql(val1, val2) : rb_equal(val1, val2))) {
-	data->result = Qfalse;
-	return ST_STOP;
-    }
-    return ST_CONTINUE;
-}
-
 static VALUE
-recursive_eql(VALUE hash, VALUE dt, int recur)
-{
-    struct equal_data *data;
-
-    if (recur) return Qfalse;
-    data = (struct equal_data*)dt;
-    data->result = Qtrue;
-    rb_hash_foreach(hash, eql_i, (st_data_t)data);
-
-    return data->result;
-}
-#endif
-
-static VALUE
 hash_equal(VALUE hash1, VALUE hash2, int eql)
 {
     if (hash1 == hash2) return Qtrue;
@@ -1733,23 +1259,7 @@
     }
     if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2))
 	return Qfalse;
-#if WITH_OBJC
     return CFEqual((CFTypeRef)hash1, (CFTypeRef)hash2) ? Qtrue : Qfalse;
-#else
-    if (!RHASH(hash1)->ntbl || !RHASH(hash2)->ntbl)
-        return Qtrue;
-    if (RHASH(hash1)->ntbl->type != RHASH(hash2)->ntbl->type)
-	return Qfalse;
-#if 0
-    if (!(rb_equal(RHASH(hash1)->ifnone, RHASH(hash2)->ifnone) &&
-	  FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT)))
-	return Qfalse;
-#endif
-
-    data.tbl = RHASH(hash2)->ntbl;
-    data.eql = eql;
-    return rb_exec_recursive(recursive_eql, hash1, (VALUE)&data);
-#endif
 }
 
 /*
@@ -1791,50 +1301,7 @@
     return hash_equal(hash1, hash2, Qtrue);
 }
 
-#if !WITH_OBJC
 static int
-hash_i(VALUE key, VALUE val, int *hval)
-{
-    if (key == Qundef) return ST_CONTINUE;
-    *hval ^= rb_hash(key);
-    *hval *= 137;
-    *hval ^= rb_hash(val);
-    return ST_CONTINUE;
-}
-
-static VALUE
-recursive_hash(VALUE hash, VALUE dummy, int recur)
-{
-    int hval;
-
-    if (recur) {
-	return LONG2FIX(0);
-    }
-    if (!RHASH(hash)->ntbl)
-        return LONG2FIX(0);
-    hval = RHASH(hash)->ntbl->num_entries;
-    rb_hash_foreach(hash, hash_i, (st_data_t)&hval);
-    return INT2FIX(hval);
-}
-#endif
-
-/*
- *  call-seq:
- *     array.hash   -> fixnum
- *
- *  Compute a hash-code for this array. Two arrays with the same content
- *  will have the same hash code (and will compare using <code>eql?</code>).
- */
-
-#if !WITH_OBJC
-static VALUE
-rb_hash_hash(VALUE hash)
-{
-    return rb_exec_recursive(recursive_hash, hash, 0);
-}
-#endif
-
-static int
 rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
 {
     if (key == Qundef) return ST_CONTINUE;
@@ -2062,12 +1529,7 @@
 rb_hash_compare_by_id(VALUE hash)
 {
     rb_hash_modify(hash);
-#if WITH_OBJC
     HASH_KEY_CALLBACKS(hash)->equal = NULL;
-#else
-    RHASH(hash)->ntbl->type = &identhash;
-    rb_hash_rehash(hash);
-#endif
     return hash;
 }
 
@@ -2083,37 +1545,16 @@
 static VALUE
 rb_hash_compare_by_id_p(VALUE hash)
 {
-#if WITH_OBJC
     return HASH_KEY_CALLBACKS(hash)->equal == NULL ? Qtrue : Qfalse;
-#else
-    if (!RHASH(hash)->ntbl)
-        return Qfalse;
-    if (RHASH(hash)->ntbl->type == &identhash) {
-	return Qtrue;
-    }
-    return Qfalse;
-#endif
 }
 
 static int path_tainted = -1;
 
 static char **origenviron;
-#ifdef _WIN32
-#define GET_ENVIRON(e) (e = rb_w32_get_environ())
-#define FREE_ENVIRON(e) rb_w32_free_environ(e)
-static char **my_environ;
 #undef environ
-#define environ my_environ
-#elif defined(__APPLE__)
-#undef environ
 #define environ (*_NSGetEnviron())
 #define GET_ENVIRON(e) (e)
 #define FREE_ENVIRON(e)
-#else
-extern char **environ;
-#define GET_ENVIRON(e) (e)
-#define FREE_ENVIRON(e)
-#endif
 
 static VALUE
 env_str_new(const char *ptr, long len)
@@ -2249,107 +1690,15 @@
     return path_tainted;
 }
 
-#if !defined(_WIN32) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
-static int
-envix(const char *nam)
-{
-    register int i, len = strlen(nam);
-    char **env;
-
-    env = GET_ENVIRON(environ);
-    for (i = 0; env[i]; i++) {
-	if (
-#ifdef ENV_IGNORECASE
-	    STRNCASECMP(env[i],nam,len) == 0
-#else
-	    memcmp(env[i],nam,len) == 0
-#endif
-	    && env[i][len] == '=')
-	    break;			/* memcmp must come first to avoid */
-    }					/* potential SEGV's */
-    FREE_ENVIRON(environ);
-    return i;
-}
-#endif
-
 void
 ruby_setenv(const char *name, const char *value)
 {
-#if defined(_WIN32)
-    /* The sane way to deal with the environment.
-     * Has these advantages over putenv() & co.:
-     *  * enables us to store a truly empty value in the
-     *    environment (like in UNIX).
-     *  * we don't have to deal with RTL globals, bugs and leaks.
-     *  * Much faster.
-     * Why you may want to enable USE_WIN32_RTL_ENV:
-     *  * environ[] and RTL functions will not reflect changes,
-     *    which might be an issue if extensions want to access
-     *    the env. via RTL.  This cuts both ways, since RTL will
-     *    not see changes made by extensions that call the Win32
-     *    functions directly, either.
-     * GSAR 97-06-07
-     *
-     * REMARK: USE_WIN32_RTL_ENV is already obsoleted since we don't use
-     *         RTL's environ global variable directly yet.
-     */
-    SetEnvironmentVariable(name,value);
-#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
 #undef setenv
 #undef unsetenv
     if (value)
 	setenv(name,value,1);
     else
 	unsetenv(name);
-#else  /* WIN32 */
-    size_t len;
-    int i=envix(name);		        /* where does it go? */
-
-    if (environ == origenviron) {	/* need we copy environment? */
-	int j;
-	int max;
-	char **tmpenv;
-
-	for (max = i; environ[max]; max++) ;
-	tmpenv = ALLOC_N(char*, max+2);
-	for (j=0; j<max; j++)		/* copy environment */
-	    tmpenv[j] = strdup(environ[j]);
-	tmpenv[max] = 0;
-	environ = tmpenv;		/* tell exec where it is now */
-    }
-    if (environ[i]) {
-	char **envp = origenviron;
-	while (*envp && *envp != environ[i]) envp++;
-	if (!*envp)
-	    free(environ[i]);
-	if (!value) {
-	    while (environ[i]) {
-		environ[i] = environ[i+1];
-		i++;
-	    }
-	    return;
-	}
-    }
-    else {			/* does not exist yet */
-	if (!value) return;
-	REALLOC_N(environ, char*, i+2);	/* just expand it a bit */
-	environ[i+1] = 0;	/* make sure it's null terminated */
-    }
-    len = strlen(name) + strlen(value) + 2;
-    environ[i] = ALLOC_N(char, len);
-#ifndef MSDOS
-    snprintf(environ[i],len,"%s=%s",name,value); /* all that work just for this */
-#else
-    /* MS-DOS requires environment variable names to be in uppercase */
-    /* [Tom Dinger, 27 August 1990: Well, it doesn't _require_ it, but
-     * some utilities and applications may break because they only look
-     * for upper case strings. (Fixed strupr() bug here.)]
-     */
-    strcpy(environ[i],name); strupr(environ[i]);
-    sprintf(environ[i] + strlen(name),"=%s", value);
-#endif /* MSDOS */
-
-#endif /* WIN32 */
 }
 
 void
@@ -2885,21 +2234,6 @@
     return env;
 }
 
-/*
- *  A <code>Hash</code> is a collection of key-value pairs. It is
- *  similar to an <code>Array</code>, except that indexing is done via
- *  arbitrary keys of any object type, not an integer index. The order
- *  in which you traverse a hash by either key or value may seem
- *  arbitrary, and will generally not be in the insertion order.
- *
- *  Hashes have a <em>default value</em> that is returned when accessing
- *  keys that do not exist in the hash. By default, that value is
- *  <code>nil</code>.
- *
- */
-
-#if WITH_OBJC
-
 #define PREPARE_RCV(x) \
     Class old = *(Class *)x; \
     *(Class *)x = (Class)rb_cCFHash;
@@ -3030,8 +2364,20 @@
 
 #undef INSTALL_METHOD
 }
-#endif
 
+/*
+ *  A <code>Hash</code> is a collection of key-value pairs. It is
+ *  similar to an <code>Array</code>, except that indexing is done via
+ *  arbitrary keys of any object type, not an integer index. The order
+ *  in which you traverse a hash by either key or value may seem
+ *  arbitrary, and will generally not be in the insertion order.
+ *
+ *  Hashes have a <em>default value</em> that is returned when accessing
+ *  keys that do not exist in the hash. By default, that value is
+ *  <code>nil</code>.
+ *
+ */
+
 void
 Init_Hash(void)
 {
@@ -3039,25 +2385,18 @@
     id_yield = rb_intern("yield");
     id_default = rb_intern("default");
 
-#if WITH_OBJC
     rb_cCFHash = (VALUE)objc_getClass("NSCFDictionary");
     rb_cHash = rb_cNSHash = (VALUE)objc_getClass("NSDictionary");
     rb_cNSMutableHash = (VALUE)objc_getClass("NSMutableDictionary");
     rb_set_class_path(rb_cNSMutableHash, rb_cObject, "NSMutableDictionary");
     rb_const_set(rb_cObject, rb_intern("Hash"), rb_cNSMutableHash);
-#else
-    rb_cHash = rb_define_class("Hash", rb_cObject);
-#endif
 
     rb_include_module(rb_cHash, rb_mEnumerable);
 
-#if WITH_OBJC
     /* to return mutable copies */
     rb_define_method(rb_cHash, "dup", rb_hash_dup, 0);
     rb_define_method(rb_cHash, "clone", rb_hash_clone, 0);
-#else
-    rb_define_alloc_func(rb_cHash, hash_alloc);
-#endif
+
     rb_define_singleton_method(rb_cHash, "[]", rb_hash_s_create, -1);
     rb_define_singleton_method(rb_cHash, "try_convert", rb_hash_s_try_convert, 1);
     rb_define_method(rb_cHash,"initialize", rb_hash_initialize, -1);
@@ -3071,9 +2410,6 @@
 
     rb_define_method(rb_cHash,"==", rb_hash_equal, 1);
     rb_define_method(rb_cHash,"[]", rb_hash_aref, 1);
-#if !WITH_OBJC
-    rb_define_method(rb_cHash,"hash", rb_hash_hash, 0);
-#endif
     rb_define_method(rb_cHash,"eql?", rb_hash_eql, 1);
     rb_define_method(rb_cHash,"fetch", rb_hash_fetch, -1);
     rb_define_method(rb_cHash,"[]=", rb_hash_aset, 2);
@@ -3104,10 +2440,10 @@
     rb_define_method(rb_cHash,"reject!", rb_hash_reject_bang, 0);
     rb_define_method(rb_cHash,"clear", rb_hash_clear, 0);
     rb_define_method(rb_cHash,"invert", rb_hash_invert, 0);
-#if WITH_OBJC
+
     /* to override the private -[NSMutableDictionary invert] method */
     rb_define_method(rb_cNSMutableHash,"invert", rb_hash_invert, 0);
-#endif
+
     rb_define_method(rb_cHash,"update", rb_hash_update, 1);
     rb_define_method(rb_cHash,"replace", rb_hash_replace, 1);
     rb_define_method(rb_cHash,"merge!", rb_hash_update, 1);
@@ -3126,7 +2462,6 @@
     rb_define_method(rb_cHash,"compare_by_identity", rb_hash_compare_by_id, 0);
     rb_define_method(rb_cHash,"compare_by_identity?", rb_hash_compare_by_id_p, 0);
 
-#ifndef __MACOS__ /* environment variables nothing on MacOS. */
     origenviron = environ;
     envtbl = rb_obj_alloc(rb_cObject);
     rb_extend_object(envtbl, rb_mEnumerable);
@@ -3172,8 +2507,4 @@
     rb_define_singleton_method(envtbl,"rassoc", env_rassoc, 1);
 
     rb_define_global_const("ENV", envtbl);
-#else /* __MACOS__ */
-    envtbl = rb_hash_s_new(0, NULL, rb_cHash);
-    rb_define_global_const("ENV", envtbl);
-#endif  /* ifndef __MACOS__  environment variables nothing on MacOS. */
 }

Modified: MacRuby/branches/lrz_unstable/string.c
===================================================================
--- MacRuby/branches/lrz_unstable/string.c	2008-08-15 06:08:01 UTC (rev 447)
+++ MacRuby/branches/lrz_unstable/string.c	2008-08-16 02:25:22 UTC (rev 448)
@@ -1,16 +1,14 @@
-/**********************************************************************
+/* 
+ * MacRuby implementation of Ruby 1.9's string.c.
+ *
+ * This file is covered by the Ruby license. See COPYING for more details.
+ * 
+ * Copyright (C) 2007-2008, Apple Inc. All rights reserved.
+ * Copyright (C) 1993-2007 Yukihiro Matsumoto
+ * Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ * Copyright (C) 2000 Information-technology Promotion Agency, Japan
+ */
 
-  string.c -
-
-  $Author: nobu $
-  created at: Mon Aug  9 17:12:58 JST 1993
-
-  Copyright (C) 1993-2007 Yukihiro Matsumoto
-  Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
-  Copyright (C) 2000  Information-technology Promotion Agency, Japan
-
-**********************************************************************/
-
 #include "ruby/ruby.h"
 #include "ruby/re.h"
 #include "ruby/encoding.h"
@@ -27,79 +25,11 @@
 #endif
 
 VALUE rb_cString;
-#if WITH_OBJC
 VALUE rb_cCFString;
 VALUE rb_cNSString;
 VALUE rb_cNSMutableString;
-#endif
 VALUE rb_cSymbol;
 
-#if !WITH_OBJC
-#define STR_TMPLOCK FL_USER7
-#define STR_NOEMBED FL_USER1
-#define STR_SHARED  FL_USER2 /* = ELTS_SHARED */
-#define STR_ASSOC   FL_USER3
-#define STR_SHARED_P(s) FL_ALL(s, STR_NOEMBED|ELTS_SHARED)
-#define STR_ASSOC_P(s)  FL_ALL(s, STR_NOEMBED|STR_ASSOC)
-#define STR_NOCAPA  (STR_NOEMBED|ELTS_SHARED|STR_ASSOC)
-#define STR_NOCAPA_P(s) (FL_TEST(s,STR_NOEMBED) && FL_ANY(s,ELTS_SHARED|STR_ASSOC))
-#define STR_UNSET_NOCAPA(s) do {\
-    if (FL_TEST(s,STR_NOEMBED)) FL_UNSET(s,(ELTS_SHARED|STR_ASSOC));\
-} while (0)
-				    
-
-#define STR_SET_NOEMBED(str) do {\
-    FL_SET(str, STR_NOEMBED);\
-    STR_SET_EMBED_LEN(str, 0);\
-} while (0)
-#define STR_SET_EMBED(str) FL_UNSET(str, STR_NOEMBED)
-#define STR_EMBED_P(str) (!FL_TEST(str, STR_NOEMBED))
-#define STR_SET_EMBED_LEN(str, n) do { \
-    long tmp_n = (n);\
-    RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\
-    RBASIC(str)->flags |= (tmp_n) << RSTRING_EMBED_LEN_SHIFT;\
-} while (0)
-
-#define STR_SET_LEN(str, n) do { \
-    if (STR_EMBED_P(str)) {\
-	STR_SET_EMBED_LEN(str, n);\
-    }\
-    else {\
-	RSTRING(str)->as.heap.len = (n);\
-    }\
-} while (0) 
-
-#define STR_DEC_LEN(str) do {\
-    if (STR_EMBED_P(str)) {\
-	long n = RSTRING_BYTELEN(str);\
-	n--;\
-	STR_SET_EMBED_LEN(str, n);\
-    }\
-    else {\
-	RSTRING(str)->as.heap.len--;\
-    }\
-} while (0)
-
-#define RESIZE_CAPA(str,capacity) do {\
-    if (STR_EMBED_P(str)) {\
-	if ((capacity) > RSTRING_EMBED_LEN_MAX) {\
-	    char *tmp = ALLOC_N(char, capacity+1);\
-	    memcpy(tmp, RSTRING_BYTEPTR(str), RSTRING_BYTELEN(str));\
-	    GC_WB(&RSTRING(str)->as.heap.ptr, tmp); \
-	    RSTRING(str)->as.heap.len = RSTRING_BYTELEN(str);\
-            STR_SET_NOEMBED(str);\
-	    RSTRING(str)->as.heap.aux.capa = (capacity);\
-	}\
-    }\
-    else {\
-	REALLOC_N(RSTRING(str)->as.heap.ptr, char, (capacity)+1);\
-	if (!STR_NOCAPA_P(str))\
-	    RSTRING(str)->as.heap.aux.capa = (capacity);\
-    }\
-} while (0)
-
-#else
-
 static void *rb_str_cfdata_key;
 
 static inline void
@@ -215,253 +145,15 @@
 {
     return rb_objc_str_is_bytestring(str) ? Qtrue : Qfalse;
 }
-#endif
 
-#if WITH_OBJC
-/* TODO */
-# define is_ascii_string(str) (1)
-# define is_broken_string(str) (0)
-# define STR_ENC_GET(str) (NULL)
-#else
-# define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
-# define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
-# define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
-#endif
+#define is_ascii_string(str) (1)
+#define is_broken_string(str) (0)
+#define STR_ENC_GET(str) (NULL)
+#define str_mod_check(x,y,z)
 
-#if !WITH_OBJC
-static int
-single_byte_optimizable(VALUE str)
-{
-    rb_encoding *enc = STR_ENC_GET(str);
-
-    if (rb_enc_mbmaxlen(enc) == 1)
-        return 1;
-
-    /* Conservative.  It may be ENC_CODERANGE_UNKNOWN. */
-    if (ENC_CODERANGE(str) == ENC_CODERANGE_7BIT)
-        return 1;
-
-    /* Conservative.  Possibly single byte.
-     * "\xa1" in Shift_JIS for example. */
-    return 0;
-}
-#endif
-
 VALUE rb_fs;
 
-#if !WITH_OBJC
-static inline const char *
-search_nonascii(const char *p, const char *e)
-{
-#if SIZEOF_VALUE == 8
-# define NONASCII_MASK 0x8080808080808080LL
-#elif SIZEOF_VALUE == 4
-# define NONASCII_MASK 0x80808080UL
-#endif
-#ifdef NONASCII_MASK
-    if (sizeof(long) * 2 < e - p) {
-        const unsigned long *s, *t;
-        const VALUE lowbits = sizeof(unsigned long) - 1;
-        s = (const unsigned long*)(~lowbits & ((VALUE)p + lowbits));
-        while (p < (const char *)s) {
-            if (!ISASCII(*p))
-                return p;
-            p++;
-        }
-        t = (const unsigned long*)(~lowbits & (VALUE)e);
-        while (s < t) {
-            if (*s & NONASCII_MASK) {
-                t = s;
-                break;
-            }
-            s++;
-        }
-        p = (const char *)t;
-    }
-#endif
-    while (p < e) {
-        if (!ISASCII(*p))
-            return p;
-        p++;
-    }
-    return NULL;
-}
-
-static int
-coderange_scan(const char *p, long len, rb_encoding *enc)
-{
-    const char *e = p + len;
-
-    if (rb_enc_to_index(enc) == 0) {
-        /* enc is ASCII-8BIT.  ASCII-8BIT string never be broken. */
-        p = search_nonascii(p, e);
-        return p ? ENC_CODERANGE_VALID : ENC_CODERANGE_7BIT;
-    }
-
-    if (rb_enc_asciicompat(enc)) {
-        p = search_nonascii(p, e);
-        if (!p) {
-            return ENC_CODERANGE_7BIT;
-        }
-        while (p < e) {
-            int ret = rb_enc_precise_mbclen(p, e, enc);
-            if (!MBCLEN_CHARFOUND_P(ret)) {
-                return ENC_CODERANGE_BROKEN;
-            }
-            p += MBCLEN_CHARFOUND_LEN(ret);
-            if (p < e) {
-                p = search_nonascii(p, e);
-                if (!p) {
-                    return ENC_CODERANGE_VALID;
-                }
-            }
-        }
-        if (e < p) {
-            return ENC_CODERANGE_BROKEN;
-        }
-        return ENC_CODERANGE_VALID;
-    }
-
-    while (p < e) {
-        int ret = rb_enc_precise_mbclen(p, e, enc);
-
-        if (!MBCLEN_CHARFOUND_P(ret)) {
-            return ENC_CODERANGE_BROKEN;
-        }
-        p += MBCLEN_CHARFOUND_LEN(ret);
-    }
-    if (e < p) {
-        return ENC_CODERANGE_BROKEN;
-    }
-    return ENC_CODERANGE_VALID;
-}
-
-long
-rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc, int *cr)
-{
-    const char *p = s;
-
-    if (*cr == ENC_CODERANGE_BROKEN)
-	return e - s;
-
-    if (rb_enc_to_index(enc) == 0) {
-	/* enc is ASCII-8BIT.  ASCII-8BIT string never be broken. */
-	p = search_nonascii(p, e);
-	*cr = (!p && *cr != ENC_CODERANGE_VALID) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
-	return e - s;
-    }
-    else if (rb_enc_asciicompat(enc)) {
-	p = search_nonascii(p, e);
-	if (!p) {
-	    if (*cr != ENC_CODERANGE_VALID) *cr = ENC_CODERANGE_7BIT;
-	    return e - s;
-        }
-        while (p < e) {
-            int ret = rb_enc_precise_mbclen(p, e, enc);
-            if (!MBCLEN_CHARFOUND_P(ret)) {
-		*cr = MBCLEN_INVALID_P(ret) ? ENC_CODERANGE_BROKEN: ENC_CODERANGE_UNKNOWN;
-		return p - s;
-            }
-            p += MBCLEN_CHARFOUND_LEN(ret);
-            if (p < e) {
-                p = search_nonascii(p, e);
-                if (!p) {
-		    *cr = ENC_CODERANGE_VALID;
-		    return e - s;
-		}
-	    }
-	}
-	*cr = e < p ? ENC_CODERANGE_BROKEN: ENC_CODERANGE_VALID;
-	return p - s;
-    }
-    else {
-    while (p < e) {
-        int ret = rb_enc_precise_mbclen(p, e, enc);
-        if (!MBCLEN_CHARFOUND_P(ret)) {
-		*cr = MBCLEN_INVALID_P(ret) ? ENC_CODERANGE_BROKEN: ENC_CODERANGE_UNKNOWN;
-		return p - s;
-        }
-        p += MBCLEN_CHARFOUND_LEN(ret);
-    }
-	*cr = e < p ? ENC_CODERANGE_BROKEN: ENC_CODERANGE_VALID;
-	return p - s;
-    }
-}
-
-static void
-rb_enc_cr_str_copy_for_substr(VALUE dest, VALUE src)
-{
-    /* this function is designed for copying encoding and coderange
-     * from src to new string "dest" which is made from the part of src.
-     */
-    rb_enc_copy(dest, src);
-    switch (ENC_CODERANGE(src)) {
-      case ENC_CODERANGE_7BIT:
-	ENC_CODERANGE_SET(dest, ENC_CODERANGE_7BIT);
-	break;
-      case ENC_CODERANGE_VALID:
-	if (!rb_enc_asciicompat(STR_ENC_GET(src)) ||
-	    search_nonascii(RSTRING_BYTEPTR(dest), RSTRING_END(dest)))
-	    ENC_CODERANGE_SET(dest, ENC_CODERANGE_VALID);
-	else
-	    ENC_CODERANGE_SET(dest, ENC_CODERANGE_7BIT);
-	break;
-      default:
-	if (RSTRING_BYTELEN(dest) == 0) {
-	    if (!rb_enc_asciicompat(STR_ENC_GET(src)))
-		ENC_CODERANGE_SET(dest, ENC_CODERANGE_VALID);
-	    else
-		ENC_CODERANGE_SET(dest, ENC_CODERANGE_7BIT);
-	}
-	break;
-    }
-    }
-
-static void
-rb_enc_cr_str_exact_copy(VALUE dest, VALUE src)
-{
-    rb_enc_copy(dest, src);
-    ENC_CODERANGE_SET(dest, ENC_CODERANGE(src));
-}
-
-int
-rb_enc_str_coderange(VALUE str)
-{
-    int cr = ENC_CODERANGE(str);
-
-    if (cr == ENC_CODERANGE_UNKNOWN) {
-	rb_encoding *enc = STR_ENC_GET(str);
-        cr = coderange_scan(RSTRING_BYTEPTR(str), RSTRING_BYTELEN(str), enc);
-        ENC_CODERANGE_SET(str, cr);
-    }
-    return cr;
-}
-
-int
-rb_enc_str_asciionly_p(VALUE str)
-{
-    rb_encoding *enc = STR_ENC_GET(str);
-
-    if (!rb_enc_asciicompat(enc))
-        return Qfalse;
-    else if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
-        return Qtrue;
-    return Qfalse;
-}
-#endif
-
 static inline void
-str_mod_check(VALUE s, const char *p, long len)
-{
-#if !WITH_OBJC
-    /* TODO */
-    if (RSTRING_BYTEPTR(s) != p || RSTRING_BYTELEN(s) != len){
-	rb_raise(rb_eRuntimeError, "string modified");
-    }
-#endif
-}
-
-static inline void
 str_frozen_check(VALUE s)
 {
     if (OBJ_FROZEN(s)) {
@@ -472,7 +164,6 @@
 static VALUE
 str_alloc(VALUE klass)
 {
-#if WITH_OBJC
     VALUE str;
 
     str = (VALUE)CFStringCreateMutable(NULL, 0);
@@ -482,23 +173,10 @@
 	&& klass != rb_cSymbol)
 	*(Class *)str = (Class)klass;
     CFMakeCollectable((CFTypeRef)str);
-#else
-    NEWOBJ(str, struct RString);
-    OBJSETUP(str, klass, T_STRING);
 
-    if (klass == rb_cSymbol) {
-	/* need to be registered in table */
-	RBASIC(str)->klass = rb_cString;
-    }
-    str->as.heap.ptr = 0;
-    str->as.heap.len = 0;
-    str->as.heap.aux.capa = 0;
-#endif
-
     return (VALUE)str;
 }
 
-#if WITH_OBJC
 static void
 rb_objc_str_set_bytestring(VALUE str, const char *dataptr, long datalen)
 {
@@ -513,7 +191,6 @@
     rb_str_cfdata_set(str, data);
     CFMakeCollectable(data);
 }
-#endif
 
 static VALUE
 str_new(VALUE klass, const char *ptr, long len)
@@ -525,7 +202,6 @@
     }
 
     str = str_alloc(klass);
-#if WITH_OBJC
     bool need_padding = len > 0;
     if (ptr != NULL && len > 0) {
 	long slen;
@@ -563,18 +239,7 @@
     rb_gc_malloc_increase(32 + (sizeof(UniChar) * len));
     if (need_padding)
 	CFStringPad((CFMutableStringRef)str, CFSTR(" "), len, 0);
-#else
-    if (len > RSTRING_EMBED_LEN_MAX) {
-	RSTRING(str)->as.heap.aux.capa = len;
-	GC_WB(&RSTRING(str)->as.heap.ptr, ALLOC_N(char,len+1));
-	STR_SET_NOEMBED(str);
-    }
-    if (ptr) {
-	memcpy(RSTRING_BYTEPTR(str), ptr, len);
-    }
-    STR_SET_LEN(str, len);
-    RSTRING_BYTEPTR(str)[len] = '\0';
-#endif
+
     return str;
 }
 
@@ -589,7 +254,6 @@
 {
     VALUE str = str_new(rb_cString, ptr, len);
 
-    //ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
     return str;
 }
 
@@ -598,8 +262,6 @@
 {
     VALUE str = str_new(rb_cString, ptr, len);
 
-    // TODO we should pass the real encoding
-    //rb_enc_associate(str, enc);
     return str;
 }
 
@@ -639,112 +301,9 @@
     return str;
 }
 
-#if !WITH_OBJC
 static VALUE
-str_replace_shared(VALUE str2, VALUE str)
-{
-    if (RSTRING_BYTELEN(str) <= RSTRING_EMBED_LEN_MAX) {
-	STR_SET_EMBED(str2);
-	memcpy(RSTRING_BYTEPTR(str2), RSTRING_BYTEPTR(str), RSTRING_BYTELEN(str)+1);
-	STR_SET_EMBED_LEN(str2, RSTRING_BYTELEN(str));
-    }
-    else {
-	FL_SET(str2, STR_NOEMBED);
-	RSTRING(str2)->as.heap.len = RSTRING_BYTELEN(str);
-	RSTRING(str2)->as.heap.ptr = RSTRING_BYTEPTR(str);
-	RSTRING(str2)->as.heap.aux.shared = str;
-	FL_SET(str2, ELTS_SHARED);
-    }
-    rb_enc_cr_str_exact_copy(str2, str);
-
-    return str2;
-}
-
-static VALUE
-str_new_shared(VALUE klass, VALUE str)
-{
-    return str_replace_shared(str_alloc(klass), str);
-}
-
-static VALUE
 str_new3(VALUE klass, VALUE str)
 {
-    return str_new_shared(klass, str);
-}
-
-VALUE
-rb_str_new3(VALUE str)
-{
-    VALUE str2 = str_new3(rb_obj_class(str), str);
-
-    OBJ_INFECT(str2, str);
-    return str2;
-}
-
-static VALUE
-str_new4(VALUE klass, VALUE str)
-{
-    VALUE str2;
-
-    str2 = str_alloc(klass);
-    STR_SET_NOEMBED(str2);
-    RSTRING(str2)->as.heap.len = RSTRING_BYTELEN(str);
-    RSTRING(str2)->as.heap.ptr = RSTRING_BYTEPTR(str);
-    if (STR_SHARED_P(str)) {
-	FL_SET(str2, ELTS_SHARED);
-	RSTRING(str2)->as.heap.aux.shared = RSTRING(str)->as.heap.aux.shared;
-    }
-    else {
-	FL_SET(str, ELTS_SHARED);
-	RSTRING(str)->as.heap.aux.shared = str2;
-    }
-    rb_enc_cr_str_exact_copy(str2, str);
-    OBJ_INFECT(str2, str);
-    return str2;
-}
-
-VALUE
-rb_str_new4(VALUE orig)
-{
-    VALUE klass, str;
-
-    if (OBJ_FROZEN(orig)) return orig;
-    klass = rb_obj_class(orig);
-    if (STR_SHARED_P(orig) && (str = RSTRING(orig)->as.heap.aux.shared)) {
-	long ofs;
-	ofs = RSTRING_BYTELEN(str) - RSTRING_BYTELEN(orig);
-	if ((ofs > 0) || (klass != RBASIC(str)->klass) ||
-	    (!OBJ_TAINTED(str) && OBJ_TAINTED(orig))) {
-	    str = str_new3(klass, str);
-	    RSTRING(str)->as.heap.ptr += ofs;
-	    RSTRING(str)->as.heap.len -= ofs;
-	}
-	rb_enc_cr_str_exact_copy(str, orig);
-	OBJ_INFECT(str, orig);
-    }
-    else if (STR_EMBED_P(orig)) {
-	str = str_new(klass, RSTRING_BYTEPTR(orig), RSTRING_BYTELEN(orig));
-	rb_enc_cr_str_exact_copy(str, orig);
-	OBJ_INFECT(str, orig);
-    }
-    else if (STR_ASSOC_P(orig)) {
-	VALUE assoc = RSTRING(orig)->as.heap.aux.shared;
-	FL_UNSET(orig, STR_ASSOC);
-	str = str_new4(klass, orig);
-	FL_SET(str, STR_ASSOC);
-	RSTRING(str)->as.heap.aux.shared = assoc;
-    }
-    else {
-	str = str_new4(klass, orig);
-    }
-    OBJ_FREEZE(str);
-    return str;
-}
-#else
-
-static VALUE
-str_new3(VALUE klass, VALUE str)
-{
     return rb_str_dup(str);
 }
 
@@ -753,7 +312,6 @@
 {
     VALUE str2 = str_new3(rb_obj_class(str), str);
 
-    // TODO OBJ_INFECT(str2, str);
     return str2;
 }
 
@@ -762,7 +320,6 @@
 {
     return rb_str_new3(orig);
 }
-#endif
 
 VALUE
 rb_str_new5(VALUE obj, const char *ptr, long len)
@@ -777,16 +334,6 @@
 {
     VALUE str = str_alloc(rb_cString);
 
-#if !WITH_OBJC
-    if (capa < STR_BUF_MIN_SIZE) {
-	capa = STR_BUF_MIN_SIZE;
-    }
-    FL_SET(str, STR_NOEMBED);
-    RSTRING(str)->as.heap.aux.capa = capa;
-    GC_WB(&RSTRING(str)->as.heap.ptr, ALLOC_N(char, capa+1));
-    RSTRING(str)->as.heap.ptr[0] = '\0';
-#endif
-
     return str;
 }
 
@@ -808,16 +355,6 @@
     return str_new(0, 0, len);
 }
 
-void
-rb_str_free(VALUE str)
-{
-#if !WITH_OBJC
-    if (!STR_EMBED_P(str) && !STR_SHARED_P(str)) {
-	xfree(RSTRING(str)->as.heap.ptr);
-    }
-#endif
-}
-
 VALUE
 rb_str_to_str(VALUE str)
 {
@@ -827,46 +364,8 @@
 void
 rb_str_shared_replace(VALUE str, VALUE str2)
 {
-#if WITH_OBJC
     rb_str_modify(str);
     CFStringReplaceAll((CFMutableStringRef)str, (CFStringRef)str2);
-#else
-    rb_encoding *enc;
-    int cr;
-    if (str == str2) return;
-    enc = STR_ENC_GET(str2);
-    cr = ENC_CODERANGE(str2);
-    rb_str_modify(str);
-    if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
-    if (RSTRING_BYTELEN(str2) <= RSTRING_EMBED_LEN_MAX) {
-	STR_SET_EMBED(str);
-	memcpy(RSTRING_BYTEPTR(str), RSTRING_BYTEPTR(str2), RSTRING_BYTELEN(str2)+1);
-	STR_SET_EMBED_LEN(str, RSTRING_BYTELEN(str2));
-        rb_enc_associate(str, enc);
-        ENC_CODERANGE_SET(str, cr);
-	return;
-    }
-    if (!STR_SHARED_P(str) && !STR_EMBED_P(str)) {
-	xfree(RSTRING_BYTEPTR(str));
-    }
-    STR_SET_NOEMBED(str);
-    STR_UNSET_NOCAPA(str);
-    RSTRING(str)->as.heap.ptr = RSTRING_BYTEPTR(str2);
-    RSTRING(str)->as.heap.len = RSTRING_BYTELEN(str2);
-    if (STR_NOCAPA_P(str2)) {
-	FL_SET(str, RBASIC(str2)->flags & STR_NOCAPA);
-	RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
-    }
-    else {
-	RSTRING(str)->as.heap.aux.capa = RSTRING(str2)->as.heap.aux.capa;
-    }
-    RSTRING(str2)->as.heap.ptr = 0;	/* abandon str2 */
-    RSTRING(str2)->as.heap.len = 0;
-    RSTRING(str2)->as.heap.aux.capa = 0;
-    STR_UNSET_NOCAPA(str2);
-    rb_enc_associate(str, enc);
-    ENC_CODERANGE_SET(str, cr);
-#endif
 }
 
 static ID id_to_s;
@@ -891,7 +390,6 @@
 VALUE
 rb_str_dup(VALUE str)
 {
-#if WITH_OBJC
     VALUE dup;
     void *data;
 
@@ -905,10 +403,6 @@
 	OBJ_TAINT(dup);
 
     CFMakeCollectable((CFTypeRef)dup);
-#else
-    VALUE dup = str_alloc(rb_obj_class(str));
-    rb_str_replace(dup, str);
-#endif
 
     return dup;
 }
@@ -934,153 +428,18 @@
 {
     VALUE orig;
 
-#if WITH_OBJC
     str = (VALUE)objc_msgSend((id)str, selInit);
-#endif
 
     if (argc > 0 && rb_scan_args(argc, argv, "01", &orig) == 1)
 	rb_str_replace(str, orig);
     return str;
 }
 
-#if !WITH_OBJC
-long
-rb_enc_strlen(const char *p, const char *e, rb_encoding *enc)
-{
-    long c;
-    const char *q;
-
-    if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
-        return (e - p + rb_enc_mbminlen(enc) - 1) / rb_enc_mbminlen(enc);
-    }
-    else if (rb_enc_asciicompat(enc)) {
-        c = 0;
-        while (p < e) {
-            if (ISASCII(*p)) {
-                q = search_nonascii(p, e);
-                if (!q)
-                    return c + (e - p);
-                c += q - p;
-                p = q;
-            }
-            p += rb_enc_mbclen(p, e, enc);
-            c++;
-        }
-        return c;
-    }
-
-    for (c=0; p<e; c++) {
-        p += rb_enc_mbclen(p, e, enc);
-    }
-    return c;
-}
-
-long
-rb_enc_strlen_cr(const char *p, const char *e, rb_encoding *enc, int *cr)
-{
-    long c;
-    const char *q;
-    int ret;
-
-    *cr = 0;
-    if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
-	return (e - p + rb_enc_mbminlen(enc) - 1) / rb_enc_mbminlen(enc);
-    }
-    else if (rb_enc_asciicompat(enc)) {
-	c = 0;
-	while (p < e) {
-	    if (ISASCII(*p)) {
-		q = search_nonascii(p, e);
-		if (!q) {
-		    return c + (e - p);
-		}
-		c += q - p;
-		p = q;
-	    }
-	    ret = rb_enc_precise_mbclen(p, e, enc);
-	    if (MBCLEN_CHARFOUND_P(ret)) {
-		*cr |= ENC_CODERANGE_VALID;
-		p += MBCLEN_CHARFOUND_LEN(ret);
-	    }
-	    else {
-		*cr = ENC_CODERANGE_BROKEN;
-		p++;
-	    }
-	    c++;
-	}
-	if (!*cr) *cr = ENC_CODERANGE_7BIT;
-	return c;
-    }
-
-    for (c=0; p<e; c++) {
-	ret = rb_enc_precise_mbclen(p, e, enc);
-	if (MBCLEN_CHARFOUND_P(ret)) {
-	    *cr |= ENC_CODERANGE_VALID;
-	    p += MBCLEN_CHARFOUND_LEN(ret);
-	}
-	else {
-	    *cr = ENC_CODERANGE_BROKEN;
-	    p++;
-	}
-    }
-    if (!*cr) *cr = ENC_CODERANGE_7BIT;
-    return c;
-}
-#endif
-
 static long
 str_strlen(VALUE str, rb_encoding *enc)
 {
-#if WITH_OBJC
     /* TODO should use CFStringGetMaximumSizeForEncoding too */
     return RSTRING_LEN(str);
-#else
-    const char *p, *e;
-    int n, cr;
-
-    if (single_byte_optimizable(str)) return RSTRING_BYTELEN(str);
-    if (!enc) enc = STR_ENC_GET(str);
-    p = RSTRING_BYTEPTR(str);
-    e = RSTRING_END(str);
-#ifdef NONASCII_MASK
-    if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
-        enc == rb_utf8_encoding()) {
-        long len = 0;
-	if (sizeof(long) * 2 < e - p) {
-	    const unsigned long *s, *t;
-	    const VALUE lowbits = sizeof(unsigned long) - 1;
-	    s = (const unsigned long*)(~lowbits & ((VALUE)p + lowbits));
-	    t = (const unsigned long*)(~lowbits & (VALUE)e);
-	    for (len=0; p<(const char *)s; p++) {
-		if (((*p)&0xC0) != 0x80) len++;
-	    }
-	    while (s < t) {
-		unsigned long d = *s;
-		d = ~d | (d<<1);
-		d &= NONASCII_MASK;
-		d >>= 7;
-		d += (d>>8);
-		d += (d>>16);
-#if NONASCII_MASK == 0x8080808080808080UL
-		d = d + (d>>32);
-#endif
-		len += (long)(d&0xF);
-		s++;
-	    }
-	    p = (const char *)t;
-	}
-	for (; p<e; p++) {
-	    if (((*p)&0xC0) != 0x80) len++;
-	}
-	return len;
-    }
-#endif
-    n = rb_enc_strlen_cr(p, e, enc, &cr);
-    if (cr) {
-        ENC_CODERANGE_SET(str, cr);
-    }
-    return n;
-#endif
 }
 
 /*
@@ -1144,29 +503,11 @@
 VALUE
 rb_str_plus(VALUE str1, VALUE str2)
 {
-#if WITH_OBJC
     VALUE str3 = rb_str_new(0, 0);
     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;
-
-    StringValue(str2);
-    enc = rb_enc_check(str1, str2);
-    str3 = rb_str_new(0, RSTRING_BYTELEN(str1)+RSTRING_BYTELEN(str2));
-    memcpy(RSTRING_BYTEPTR(str3), RSTRING_BYTEPTR(str1), RSTRING_BYTELEN(str1));
-    memcpy(RSTRING_BYTEPTR(str3) + RSTRING_BYTELEN(str1),
-	   RSTRING_BYTEPTR(str2), RSTRING_BYTELEN(str2));
-    RSTRING_BYTEPTR(str3)[RSTRING_BYTELEN(str3)] = '\0';
-
-    if (OBJ_TAINTED(str1) || OBJ_TAINTED(str2))
-	OBJ_TAINT(str3);
-    ENCODING_CODERANGE_SET(str3, rb_enc_to_index(enc),
-			   ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2)));
-#endif
     return str3;
 }
 
@@ -1195,24 +536,9 @@
 	rb_raise(rb_eArgError, "argument too big");
     }
 
-#if WITH_OBJC
     str2 = rb_str_new(NULL, 0);
     CFStringPad((CFMutableStringRef)str2, (CFStringRef)str,
 	len * n, 0);
-#else
-    str2 = rb_str_new5(str, 0, len *= n);
-    if (len) {
-        memcpy(RSTRING_BYTEPTR(str2), RSTRING_BYTEPTR(str), n);
-        while (n <= len/2) {
-            memcpy(RSTRING_BYTEPTR(str2) + n, RSTRING_BYTEPTR(str2), n);
-            n *= 2;
-        }
-        memcpy(RSTRING_BYTEPTR(str2) + n, RSTRING_BYTEPTR(str2), len-n);
-    }
-    RSTRING_BYTEPTR(str2)[RSTRING_BYTELEN(str2)] = '\0';
-    OBJ_INFECT(str2, str);
-    rb_enc_cr_str_copy_for_substr(str2, str);
-#endif
 
     return str2;
 }
@@ -1245,49 +571,14 @@
 static inline void
 str_modifiable(VALUE str)
 {
-#if WITH_OBJC
     bool __CFStringIsMutable(void *);
     if (!__CFStringIsMutable((void *)str)) 
 	rb_raise(rb_eRuntimeError, "can't modify immutable string");
-#else
-    if (FL_TEST(str, STR_TMPLOCK)) {
-	rb_raise(rb_eRuntimeError, "can't modify string; temporarily locked");
-    }
-#endif
     if (OBJ_FROZEN(str)) rb_error_frozen("string");
     if (!OBJ_TAINTED(str) && rb_safe_level() >= 4)
 	rb_raise(rb_eSecurityError, "Insecure: can't modify string");
 }
 
-#if !WITH_OBJC
-static int
-str_independent(VALUE str)
-{
-    str_modifiable(str);
-    if (!STR_SHARED_P(str)) return 1;
-    if (STR_EMBED_P(str)) return 1;
-    return 0;
-}
-
-static void
-str_make_independent(VALUE str)
-{
-    char *ptr;
-    long len = RSTRING_BYTELEN(str);
-
-    ptr = ALLOC_N(char, len+1);
-    if (RSTRING_BYTEPTR(str)) {
-	memcpy(ptr, RSTRING_BYTEPTR(str), len);
-    }
-    STR_SET_NOEMBED(str);
-    ptr[len] = 0;
-    GC_WB(&RSTRING(str)->as.heap.ptr, ptr);
-    RSTRING(str)->as.heap.len = len;
-    RSTRING(str)->as.heap.aux.capa = len;
-    STR_UNSET_NOCAPA(str);
-}
-#endif
-
 void
 rb_str_modify(VALUE str)
 {
@@ -1305,43 +596,11 @@
 {
     /* sanity check */
     if (OBJ_FROZEN(str)) rb_error_frozen("string");
-#if !WITH_OBJC
-    if (STR_ASSOC_P(str)) {
-	/* already associated */
-	rb_ary_concat(RSTRING(str)->as.heap.aux.shared, add);
-    }
-    else {
-	if (STR_SHARED_P(str)) {
-	    VALUE assoc = RSTRING(str)->as.heap.aux.shared;
-	    str_make_independent(str);
-	    if (STR_ASSOC_P(assoc)) {
-		assoc = RSTRING(assoc)->as.heap.aux.shared;
-		rb_ary_concat(assoc, add);
-		add = assoc;
-	    }
-	}
-	else if (STR_EMBED_P(str)) {
-	    str_make_independent(str);
-	}
-	else if (RSTRING(str)->as.heap.aux.capa != RSTRING_BYTELEN(str)) {
-	    RESIZE_CAPA(str, RSTRING_BYTELEN(str));
-	}
-	FL_SET(str, STR_ASSOC);
-	RBASIC(add)->klass = 0;
-	RSTRING(str)->as.heap.aux.shared = add;
-    }
-#endif
 }
 
 VALUE
 rb_str_associated(VALUE str)
 {
-#if !WITH_OBJC
-    if (STR_SHARED_P(str)) str = RSTRING(str)->as.heap.aux.shared;
-    if (STR_ASSOC_P(str)) {
-	return RSTRING(str)->as.heap.aux.shared;
-    }
-#endif
     return Qfalse;
 }
 
@@ -1362,7 +621,6 @@
     return (char *)RSTRING_PTR(rb_string_value(ptr));
 }
 
-#if WITH_OBJC
 const char *
 rb_str_cstr(VALUE ptr)
 {
@@ -1393,22 +651,12 @@
 	? CFStringGetLength((CFStringRef)ptr) 
 	: CFDataGetLength(data);
 }
-#endif
 
 char *
 rb_string_value_cstr(volatile VALUE *ptr)
 {
-#if WITH_OBJC
     VALUE str = rb_string_value(ptr);
     return (char *)rb_str_cstr(str);
-#else
-    char *s = RSTRING_BYTEPTR(str);
-
-    if (!s || RSTRING_BYTELEN(str) != strlen(s)) {
-	rb_raise(rb_eArgError, "string contains null byte");
-    }
-    return s;
-#endif
 }
 
 VALUE
@@ -1435,143 +683,16 @@
     return rb_check_string_type(str);
 }
 
-#if !WITH_OBJC
-char*
-rb_enc_nth(const char *p, const char *e, int nth, rb_encoding *enc)
-{
-    if (rb_enc_mbmaxlen(enc) == 1) {
-        p += nth;
-    }
-    else if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
-        p += nth * rb_enc_mbmaxlen(enc);
-    }
-    else if (rb_enc_asciicompat(enc)) {
-        const char *p2, *e2;
-        int n;
-
-        while (p < e && 0 < nth) {
-            e2 = p + nth;
-            if (e < e2)
-                return (char *)e;
-            if (ISASCII(*p)) {
-                p2 = search_nonascii(p, e2);
-                if (!p2)
-                    return (char *)e2;
-                nth -= p2 - p;
-                p = p2;
-            }
-            n = rb_enc_mbclen(p, e, enc);
-            p += n;
-            nth--;
-        }
-        if (nth != 0)
-            return (char *)e;
-        return (char *)p;
-    }
-    else {
-        while (p<e && nth--) {
-            p += rb_enc_mbclen(p, e, enc);
-        }
-    }
-    if (p > e) p = e;
-    return (char*)p;
-}
-
-static char*
-str_nth(const char *p, const char *e, int nth, rb_encoding *enc, int singlebyte)
-{
-    if (singlebyte)
-	p += nth;
-    else {
-	p = rb_enc_nth(p, e, nth, enc);
-    }
-    if (!p) return 0;
-    if (p > e) p = e;
-    return (char *)p;
-}
-
-/* char offset to byte offset */
-static int
-str_offset(const char *p, const char *e, int nth, rb_encoding *enc, int singlebyte)
-{
-    const char *pp = str_nth(p, e, nth, enc, singlebyte);
-    if (!pp) return e - p;
-    return pp - p;
-}
-
-#ifdef NONASCII_MASK
-static char *
-str_utf8_nth(const char *p, const char *e, int nth)
-{
-    if (sizeof(long) * 2 < nth) {
-	const unsigned long *s, *t;
-	const VALUE lowbits = sizeof(unsigned long) - 1;
-	s = (const unsigned long*)(~lowbits & ((VALUE)p + lowbits));
-	t = (const unsigned long*)(~lowbits & (VALUE)e);
-	for (; p<(const char *)s && 0<nth; p++) {
-	    if (((*p)&0xC0) != 0x80) nth--;
-	}
-	while (s < t) {
-	    unsigned long d = *s++;
-	    d = ~d | (d<<1);
-	    d &= NONASCII_MASK;
-	    d >>= 7;
-	    d += (d>>8);
-	    d += (d>>16);
-#if NONASCII_MASK == 0x8080808080808080UL
-	    d += (d>>32);
-#endif
-	    nth -= (long)(d&0xF);
-	    if (nth < 8) {
-		t = s;
-		break;
-	    }
-	}
-	p = (char *)t;
-    }
-    if (0 < nth) {
-	while (p < e) {
-	    if (((*p)&0xC0) != 0x80) {
-		nth--;
-		if (nth < 0)
-		    break;
-	    }
-	    p++;
-	}
-    }
-    return (char *)p;
-}
-
-static int
-str_utf8_offset(const char *p, const char *e, int nth)
-{
-    const char *pp = str_utf8_nth(p, e, nth);
-    if (!pp) return e - p;
-    return pp - p;
-}
-#endif /* NONASCII_MASK */
-#endif /* WITH_OBJC */
-
 /* byte offset to char offset */
 long
 rb_str_sublen(VALUE str, long pos)
 {
-#if WITH_OBJC
     return pos;
-#else
-    if (single_byte_optimizable(str) || pos < 0)
-        return pos;
-    else {
-	char *p = RSTRING_BYTEPTR(str);
-        return rb_enc_strlen(p, p + pos, STR_ENC_GET(str));
-    }
-#endif
 }
 
 VALUE
 rb_str_subseq(VALUE str, long beg, long len)
 {
-#if WITH_OBJC
     CFDataRef data;
     CFMutableStringRef substr;
     long n;
@@ -1627,157 +748,38 @@
     }
     CFMakeCollectable(substr);
     return (VALUE)substr;
-#else
-    VALUE str2 = rb_str_new5(str, RSTRING_BYTEPTR(str)+beg, len);
-
-    rb_enc_cr_str_copy_for_substr(str2, str);
-    OBJ_INFECT(str2, str);
-
-    return str2;
-#endif
 }
 
 VALUE
 rb_str_substr(VALUE str, long beg, long len)
 {
-#if WITH_OBJC
     return rb_str_subseq(str, beg, len);
-#else
-    rb_encoding *enc = STR_ENC_GET(str);
-    VALUE str2;
-    char *p, *s = RSTRING_BYTEPTR(str), *e = s + RSTRING_BYTELEN(str);
-    int singlebyte = single_byte_optimizable(str);
-
-    if (len < 0) return Qnil;
-    if (!RSTRING_BYTELEN(str)) {
-	len = 0;
-    }
-    if (beg < 0) {
-	if (len > -beg) len = -beg;
-	if (-beg * rb_enc_mbmaxlen(enc) < RSTRING_BYTELEN(str) / 8) {
-	    beg = -beg;
-	    while (beg-- > len && (e = rb_enc_prev_char(s, e, enc)) != 0);
-	    p = e;
-	    if (!p) return Qnil;
-	    while (len-- > 0 && (p = rb_enc_prev_char(s, p, enc)) != 0);
-	    if (!p) return Qnil;
-	    len = e - p;
-	    goto sub;
-	}
-	else {
-	    beg += str_strlen(str, enc);
-	    if (beg < 0) return Qnil;
-	}
-    }
-    else if (beg > 0 && beg > str_strlen(str, enc)) {
-	return Qnil;
-    }
-    if (len == 0) {
-	p = 0;
-    }
-#ifdef NONASCII_MASK
-    else if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
-        enc == rb_utf8_encoding()) {
-        p = str_utf8_nth(s, e, beg);
-        len = str_utf8_offset(p, e, len);
-    }
-#endif
-    else if ((p = str_nth(s, e, beg, enc, singlebyte)) == e) {
-	len = 0;
-    }
-    else if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
-        if (len * rb_enc_mbmaxlen(enc) > e - p)
-            len = e - p;
-	else
-	    len *= rb_enc_mbmaxlen(enc);
-    }
-    else {
-	len = str_offset(p, e, len, enc, singlebyte);
-    }
-  sub:
-    if (len > RSTRING_EMBED_LEN_MAX && beg + len == RSTRING_BYTELEN(str)) {
-	str2 = rb_str_new4(str);
-	str2 = str_new3(rb_obj_class(str2), str2);
-	RSTRING(str2)->as.heap.ptr += RSTRING(str2)->as.heap.len - len;
-	RSTRING(str2)->as.heap.len = len;
-    }
-    else {
-	str2 = rb_str_new5(str, p, len);
-	rb_enc_cr_str_copy_for_substr(str2, str);
-	OBJ_INFECT(str2, str);
-    }
-
-    return str2;
-#endif
 }
 
-#if !WITH_OBJC
 VALUE
-rb_str_freeze(VALUE str)
-{
-    if (STR_ASSOC_P(str)) {
-	VALUE ary = RSTRING(str)->as.heap.aux.shared;
-	OBJ_FREEZE(ary);
-    }
-    return rb_obj_freeze(str);
-}
-#endif
-
-VALUE
 rb_str_dup_frozen(VALUE str)
 {
-#if WITH_OBJC
     str = rb_str_dup(str);
     rb_str_freeze(str);
     return str;
-#else
-    if (STR_SHARED_P(str) && RSTRING(str)->as.heap.aux.shared) {
-	VALUE shared = RSTRING(str)->as.heap.aux.shared;
-	if (RSTRING_BYTELEN(shared) == RSTRING_BYTELEN(str)) {
-	    OBJ_FREEZE(shared);
-	    return shared;
-	}
-    }
-    if (OBJ_FROZEN(str)) return str;
-    str = rb_str_dup(str);
-    OBJ_FREEZE(str);
-    return str;
-#endif
 }
 
 VALUE
 rb_str_locktmp(VALUE str)
 {
-#if !WITH_OBJC
-    if (FL_TEST(str, STR_TMPLOCK)) {
-	rb_raise(rb_eRuntimeError, "temporal locking already locked string");
-    }
-    FL_SET(str, STR_TMPLOCK);
-#endif
     return str;
 }
 
 VALUE
 rb_str_unlocktmp(VALUE str)
 {
-#if !WITH_OBJC
-    if (!FL_TEST(str, STR_TMPLOCK)) {
-	rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
-    }
-    FL_UNSET(str, STR_TMPLOCK);
-#endif
     return str;
 }
 
 void
 rb_str_set_len(VALUE str, long len)
 {
-#if WITH_OBJC
     rb_str_resize(str, len);    
-#else
-    STR_SET_LEN(str, len);
-    RSTRING_BYTEPTR(str)[len] = '\0';
-#endif
 }
 
 VALUE
@@ -1790,7 +792,6 @@
     }
 
     rb_str_modify(str);
-#if WITH_OBJC
     slen = RSTRING_LEN(str);
     if (slen != len) {
 	void *cfdata;
@@ -1801,44 +802,9 @@
 	if (cfdata != NULL)
 	    CFDataSetLength((CFMutableDataRef)cfdata, len); 
     }
-#else
-    slen = RSTRING_BYTELEN(str);
-    if (len != slen) {
-	if (STR_EMBED_P(str)) {
-	    char *ptr;
-	    if (len <= RSTRING_EMBED_LEN_MAX) {
-		STR_SET_EMBED_LEN(str, len);
-		RSTRING(str)->as.ary[len] = '\0';
-		return str;
-	    }
-	    ptr = ALLOC_N(char,len+1);
-	    MEMCPY(ptr, RSTRING(str)->as.ary, char, slen);
-	    GC_WB(&RSTRING(str)->as.heap.ptr, ptr);
-	    STR_SET_NOEMBED(str);
-	}
-	else if (len <= RSTRING_EMBED_LEN_MAX) {
-	    char *ptr = RSTRING(str)->as.heap.ptr;
-	    STR_SET_EMBED(str);
-	    if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, len);
-	    RSTRING(str)->as.ary[len] = '\0';
-	    STR_SET_EMBED_LEN(str, len);
-	    xfree(ptr);
-	    return str;
-	}
-	else if (slen < len || slen - len > 1024) {
-	    REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1);
-	}
-	if (!STR_NOCAPA_P(str)) {
-	    RSTRING(str)->as.heap.aux.capa = len;
-	}
-	RSTRING(str)->as.heap.len = len;
-	RSTRING(str)->as.heap.ptr[len] = '\0';	/* sentinel */
-    }
-#endif
     return str;
 }
 
-#if WITH_OBJC
 static void
 rb_objc_str_cat(VALUE str, const char *ptr, long len, int cfstring_encoding)
 {
@@ -1870,43 +836,12 @@
 	}
     }
 }
-#endif
 
 VALUE
 rb_str_buf_cat(VALUE str, const char *ptr, long len)
 {
-#if WITH_OBJC
     rb_objc_str_cat(str, ptr, len, kCFStringEncodingASCII);
-#else
-    long capa, total;
 
-    if (len == 0) return str;
-    if (len < 0) {
-	rb_raise(rb_eArgError, "negative string size (or size too big)");
-    }
-    rb_str_modify(str);
-    if (STR_ASSOC_P(str)) {
-	FL_UNSET(str, STR_ASSOC);
-	capa = RSTRING(str)->as.heap.aux.capa = RSTRING_BYTELEN(str);
-    }
-    else if (STR_EMBED_P(str)) {
-	capa = RSTRING_EMBED_LEN_MAX;
-    }
-    else {
-	capa = RSTRING(str)->as.heap.aux.capa;
-    }
-    total = RSTRING_BYTELEN(str)+len;
-    if (capa <= total) {
-	while (total > capa) {
-	    capa = (capa + 1) * 2;
-	}
-	RESIZE_CAPA(str, capa);
-    }
-    memcpy(RSTRING_BYTEPTR(str) + RSTRING_BYTELEN(str), ptr, len);
-    STR_SET_LEN(str, total);
-    RSTRING_BYTEPTR(str)[total] = '\0'; /* sentinel */
-#endif
-
     return str;
 }
 
@@ -1922,17 +857,6 @@
     if (len < 0) {
 	rb_raise(rb_eArgError, "negative string size (or size too big)");
     }
-#if !WITH_OBJC
-    if (STR_ASSOC_P(str)) {
-	rb_str_modify(str);
-	if (STR_EMBED_P(str)) str_make_independent(str);
-	REALLOC_N(RSTRING(str)->as.heap.ptr, char, RSTRING(str)->as.heap.len+len);
-	memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len, ptr, len);
-	RSTRING(str)->as.heap.len += len;
-	RSTRING(str)->as.heap.ptr[RSTRING(str)->as.heap.len] = '\0'; /* sentinel */
-	return str;
-    }
-#endif
 
     return rb_str_buf_cat(str, ptr, len);
 }
@@ -1943,173 +867,23 @@
     return rb_str_cat(str, ptr, strlen(ptr));
 }
 
-#if !WITH_OBJC
-static VALUE
-rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
-    int ptr_encindex, int ptr_cr, int *ptr_cr_ret)
-{
-    long capa, total, off = -1;
-
-    int str_encindex = ENCODING_GET(str);
-    int res_encindex;
-    int str_cr, res_cr;
-    int str_a8 = ENCODING_IS_ASCII8BIT(str);
-    int ptr_a8 = ptr_encindex == 0;
-
-    str_cr = ENC_CODERANGE(str);
-
-    if (str_encindex == ptr_encindex) {
-        if (str_cr == ENC_CODERANGE_UNKNOWN ||
-            (ptr_a8 && str_cr != ENC_CODERANGE_7BIT)) {
-            ptr_cr = ENC_CODERANGE_UNKNOWN;
-        }
-        else if (ptr_cr == ENC_CODERANGE_UNKNOWN) {
-            ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex));
-        }
-    }
-    else {
-        rb_encoding *str_enc = rb_enc_from_index(str_encindex);
-        rb_encoding *ptr_enc = rb_enc_from_index(ptr_encindex);
-        if (!rb_enc_asciicompat(str_enc) || !rb_enc_asciicompat(ptr_enc)) {
-            if (len == 0)
-                return str;
-            if (RSTRING_BYTELEN(str) == 0) {
-                rb_str_buf_cat(str, ptr, len);
-                ENCODING_CODERANGE_SET(str, ptr_encindex, ptr_cr);
-                return str;
-            }
-            goto incompatible;
-        }
-	if (ptr_cr == ENC_CODERANGE_UNKNOWN) {
-	    ptr_cr = coderange_scan(ptr, len, ptr_enc);
-	}
-        if (str_cr == ENC_CODERANGE_UNKNOWN) {
-            if (str_a8 || ptr_cr != ENC_CODERANGE_7BIT) {
-                str_cr = rb_enc_str_coderange(str);
-            }
-        }
-    }
-    if (ptr_cr_ret)
-        *ptr_cr_ret = ptr_cr;
-
-    if (str_encindex != ptr_encindex &&
-        str_cr != ENC_CODERANGE_7BIT &&
-        ptr_cr != ENC_CODERANGE_7BIT) {
-      incompatible:
-        rb_raise(rb_eArgError, "append incompatible encoding strings: %s and %s",
-            rb_enc_name(rb_enc_from_index(str_encindex)),
-            rb_enc_name(rb_enc_from_index(ptr_encindex)));
-    }
-
-    if (str_cr == ENC_CODERANGE_UNKNOWN) {
-        res_encindex = str_encindex;
-        res_cr = ENC_CODERANGE_UNKNOWN;
-    }
-    else if (str_cr == ENC_CODERANGE_7BIT) {
-        if (ptr_cr == ENC_CODERANGE_7BIT) {
-            res_encindex = !str_a8 ? str_encindex : ptr_encindex;
-            res_cr = ENC_CODERANGE_7BIT;
-        }
-        else {
-            res_encindex = ptr_encindex;
-            res_cr = ptr_cr;
-        }
-    }
-    else if (str_cr == ENC_CODERANGE_VALID) {
-        res_encindex = str_encindex;
-        res_cr = str_cr;
-    }
-    else { /* str_cr == ENC_CODERANGE_BROKEN */
-        res_encindex = str_encindex;
-        res_cr = str_cr;
-        if (0 < len) res_cr = ENC_CODERANGE_UNKNOWN;
-    }
-
-    if (len < 0) {
-	rb_raise(rb_eArgError, "negative string size (or size too big)");
-    }
-    if (ptr >= RSTRING_BYTEPTR(str) && ptr <= RSTRING_END(str)) {
-        off = ptr - RSTRING_BYTEPTR(str);
-    }
-    rb_str_modify(str);
-    if (len == 0) {
-        ENCODING_CODERANGE_SET(str, res_encindex, res_cr);
-        return str;
-    }
-    if (STR_ASSOC_P(str)) {
-	FL_UNSET(str, STR_ASSOC);
-	capa = RSTRING(str)->as.heap.aux.capa = RSTRING_BYTELEN(str);
-    }
-    else if (STR_EMBED_P(str)) {
-	capa = RSTRING_EMBED_LEN_MAX;
-    }
-    else {
-	capa = RSTRING(str)->as.heap.aux.capa;
-    }
-    total = RSTRING_BYTELEN(str)+len;
-    if (capa <= total) {
-	while (total > capa) {
-	    capa = (capa + 1) * 2;
-	}
-	RESIZE_CAPA(str, capa);
-    }
-    if (off != -1) {
-        ptr = RSTRING_BYTEPTR(str) + off;
-    }
-    memcpy(RSTRING_BYTEPTR(str) + RSTRING_BYTELEN(str), ptr, len);
-    STR_SET_LEN(str, total);
-    RSTRING_BYTEPTR(str)[total] = '\0'; // sentinel
-
-    ENCODING_CODERANGE_SET(str, res_encindex, res_cr);
-    return str;
-}
-#endif
-
 VALUE
 rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *ptr_enc)
 {
-#if WITH_OBJC
     rb_objc_str_cat(str, ptr, len, kCFStringEncodingUTF8);
     return str;
-#else
-    return rb_enc_cr_str_buf_cat(str, ptr, len,
-        rb_enc_to_index(ptr_enc), ENC_CODERANGE_UNKNOWN, NULL);
-#endif
 }
 
 VALUE
 rb_str_buf_cat_ascii(VALUE str, const char *ptr)
 {
-#if WITH_OBJC
     rb_objc_str_cat(str, ptr, strlen(ptr), kCFStringEncodingASCII);
     return str;
-#else
-    /* ptr must reference NUL terminated ASCII string. */
-    int encindex = ENCODING_GET(str);
-    rb_encoding *enc = rb_enc_from_index(encindex);
-    if (rb_enc_asciicompat(enc)) {
-        return rb_enc_cr_str_buf_cat(str, ptr, strlen(ptr),
-            encindex, ENC_CODERANGE_7BIT, 0);
-    }
-    else {
-        char *buf = ALLOCA_N(char, rb_enc_mbmaxlen(enc));
-        while (*ptr) {
-            int c = (unsigned char)*ptr;
-            int len = rb_enc_codelen(c, enc);
-            rb_enc_mbcput(c, buf, enc);
-            rb_enc_cr_str_buf_cat(str, buf, len,
-                encindex, ENC_CODERANGE_VALID, 0);
-            ptr++;
-        }
-        return str;
-    }
-#endif
 }
 
 VALUE
 rb_str_buf_append(VALUE str, VALUE str2)
 {
-#if WITH_OBJC
     CFMutableDataRef mdata;
     CFDataRef data;
     long str2len;
@@ -2137,18 +911,7 @@
 	}
     }
     rb_gc_malloc_increase(sizeof(UniChar) * str2len);
-#else
-    int str2_cr;
 
-    str2_cr = ENC_CODERANGE(str2);
-
-    rb_enc_cr_str_buf_cat(str, RSTRING_BYTEPTR(str2), RSTRING_BYTELEN(str2),
-        ENCODING_GET(str2), str2_cr, &str2_cr);
-
-    OBJ_INFECT(str, str2);
-    ENC_CODERANGE_SET(str2, str2_cr);
-#endif
-
     return str;
 }
 
@@ -2156,27 +919,6 @@
 rb_str_append(VALUE str, VALUE str2)
 {
     StringValue(str2);
-#if !WITH_OBJC
-    if (RSTRING_BYTELEN(str2) > 0 && STR_ASSOC_P(str)) {
-	rb_encoding *enc;
-	int cr, cr2;
-
-        long len = RSTRING_BYTELEN(str)+RSTRING_BYTELEN(str2);
-        enc = rb_enc_check(str, str2);
-        cr = ENC_CODERANGE(str);
-        if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2;
-        rb_str_modify(str);
-        REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1);
-	GC_WB(&RSTRING(str)->as.heap.ptr, RSTRING(str)->as.heap.ptr);
-        memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len,
-               RSTRING_BYTEPTR(str2), RSTRING_BYTELEN(str2)+1);
-        RSTRING(str)->as.heap.len = len;
-        rb_enc_associate(str, enc);
-        ENC_CODERANGE_SET(str, cr);
-        OBJ_INFECT(str, str2);
-        return str;
-    }
-#endif
     return rb_str_buf_append(str, str2);
 }
 
@@ -2201,7 +943,6 @@
 rb_str_concat(VALUE str1, VALUE str2)
 {
     if (FIXNUM_P(str2)) {
-#if WITH_OBJC
         int c = FIX2INT(str2);
 	char buf[2];
 
@@ -2211,172 +952,14 @@
 	CFStringAppendCString((CFMutableStringRef)str1, buf, 
 			      kCFStringEncodingUTF8);
 	rb_gc_malloc_increase(sizeof(UniChar));
-#else
-	rb_encoding *enc = STR_ENC_GET(str1);
-	int c = FIX2INT(str2);
-	int pos = RSTRING_BYTELEN(str1);
-	int len = rb_enc_codelen(c, enc);
-	int cr = ENC_CODERANGE(str1);
-
-	rb_str_resize(str1, pos+len);
-	rb_enc_mbcput(c, RSTRING_BYTEPTR(str1)+pos, enc);
-	ENC_CODERANGE_SET(str1, cr);
-#endif
 	return str1;
     }
     return rb_str_append(str1, str2);
 }
 
-#if !WITH_OBJC
-
-typedef  unsigned int  ub4;   /* unsigned 4-byte quantities */
-typedef  unsigned char ub1;   /* unsigned 1-byte quantities */
-
-#define hashsize(n) ((ub4)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-
-/*
---------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-For every delta with one or two bits set, and the deltas of all three
-  high bits or all three low bits, whether the original value of a,b,c
-  is almost all zero or is uniformly distributed,
-* If mix() is run forward or backward, at least 32 bits in a,b,c
-  have at least 1/4 probability of changing.
-* If mix() is run forward, every bit of c will change between 1/3 and
-  2/3 of the time.  (Well, 22/100 and 78/100 for some 2-bit deltas.)
-mix() was built out of 36 single-cycle latency instructions in a 
-  structure that could supported 2x parallelism, like so:
-      a -= b; 
-      a -= c; x = (c>>13);
-      b -= c; a ^= x;
-      b -= a; x = (a<<8);
-      c -= a; b ^= x;
-      c -= b; x = (b>>13);
-      ...
-  Unfortunately, superscalar Pentiums and Sparcs can't take advantage 
-  of that parallelism.  They've also turned some of those single-cycle
-  latency instructions into multi-cycle latency instructions.  Still,
-  this is the fastest good hash I could find.  There were about 2^^68
-  to choose from.  I only looked at a billion or so.
---------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
-  a -= b; a -= c; a ^= (c>>13); \
-  b -= c; b -= a; b ^= (a<<8); \
-  c -= a; c -= b; c ^= (b>>13); \
-  a -= b; a -= c; a ^= (c>>12);  \
-  b -= c; b -= a; b ^= (a<<16); \
-  c -= a; c -= b; c ^= (b>>5); \
-  a -= b; a -= c; a ^= (c>>3);  \
-  b -= c; b -= a; b ^= (a<<10); \
-  c -= a; c -= b; c ^= (b>>15); \
-}
-
-/*
---------------------------------------------------------------------
-hash() -- hash a variable-length key into a 32-bit value
-  k       : the key (the unaligned variable-length array of bytes)
-  len     : the length of the key, counting by bytes
-  initval : can be any 4-byte value
-Returns a 32-bit value.  Every bit of the key affects every bit of
-the return value.  Every 1-bit and 2-bit delta achieves avalanche.
-About 6*len+35 instructions.
-
-The best hash table sizes are powers of 2.  There is no need to do
-mod a prime (mod is sooo slow!).  If you need less than 32 bits,
-use a bitmask.  For example, if you need only 10 bits, do
-  h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (ub1 **)k, do it like this:
-  for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
-
-By Bob Jenkins, 1996.  bob_jenkins at burtleburtle.net.  You may use this
-code any way you wish, private, educational, or commercial.  It's free.
-
-See http://burtleburtle.net/bob/hash/evahash.html
-Use for hash table lookup, or anything where one collision in 2^^32 is
-acceptable.  Do NOT use for cryptographic purposes.
---------------------------------------------------------------------
-*/
-
-static ub4
-hash(const ub1 *k, ub4 length, ub4 initval)
-    /* k: the key */
-    /* length: the length of the key */
-    /* initval: the previous hash, or an arbitrary value */
-{
-    register ub4 a,b,c,len;
-
-    /* Set up the internal state */
-    len = length;
-    a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
-    c = initval;         /* the previous hash value */
-
-   /*---------------------------------------- handle most of the key */
-    while (len >= 12) {
-	a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
-	b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
-	c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
-	mix(a,b,c);
-	k += 12; len -= 12;
-    }
-
-    /*------------------------------------- handle the last 11 bytes */
-    c += length;
-    switch(len)              /* all the case statements fall through */
-    {
-      case 11: c+=((ub4)k[10]<<24);
-      case 10: c+=((ub4)k[9]<<16);
-      case 9 : c+=((ub4)k[8]<<8);
-	/* the first byte of c is reserved for the length */
-      case 8 : b+=((ub4)k[7]<<24);
-      case 7 : b+=((ub4)k[6]<<16);
-      case 6 : b+=((ub4)k[5]<<8);
-      case 5 : b+=k[4];
-      case 4 : a+=((ub4)k[3]<<24);
-      case 3 : a+=((ub4)k[2]<<16);
-      case 2 : a+=((ub4)k[1]<<8);
-      case 1 : a+=k[0];
-	/* case 0: nothing left to add */
-    }
-    mix(a,b,c);
-    /*-------------------------------------------- report the result */
-    return c;
-}
-
 int
 rb_memhash(const void *ptr, long len)
 {
-    return hash(ptr, len, 0);
-}
-
-int
-rb_str_hash(VALUE str)
-{
-    return hash((const void *)RSTRING_BYTEPTR(str), RSTRING_BYTELEN(str), 0);
-}
-
-int
-rb_str_hash_cmp(VALUE str1, VALUE str2)
-{
-    int len;
-
-    if (!rb_str_comparable(str1, str2)) return 1;
-    if (RSTRING_BYTELEN(str1) == (len = RSTRING_BYTELEN(str2)) &&
-	memcmp(RSTRING_BYTEPTR(str1), RSTRING_BYTEPTR(str2), len) == 0) {
-	return 0;
-    }
-    return 1;
-}
-
-#else
-
-int
-rb_memhash(const void *ptr, long len)
-{
     CFDataRef data;
     int code;
 
@@ -2398,85 +981,21 @@
     return CFEqual((CFTypeRef)str1, (CFTypeRef)str2) ? 0 : 1;
 }
 
-#endif
-
-/*
- * call-seq:
- *    str.hash   => fixnum
- *
- * Return a hash based on the string's length and content.
- */
-
-#if !WITH_OBJC
-static VALUE
-rb_str_hash_m(VALUE str)
-{
-    int hval = rb_str_hash(str);
-    return INT2FIX(hval);
-}
-#endif
-
 #define lesser(a,b) (((a)>(b))?(b):(a))
 
 int
 rb_str_comparable(VALUE str1, VALUE str2)
 {
-#if WITH_OBJC
     return Qtrue;
-#else
-    int idx1 = ENCODING_GET(str1);
-    int idx2 = ENCODING_GET(str2);
-    int rc1, rc2;
-
-    if (idx1 == idx2) return Qtrue;
-    rc1 = rb_enc_str_coderange(str1);
-    rc2 = rb_enc_str_coderange(str2);
-    if (rc1 == ENC_CODERANGE_7BIT) {
-	if (rc2 == ENC_CODERANGE_7BIT) return Qtrue;
-	if (rb_enc_asciicompat(rb_enc_from_index(idx1)))
-	    return Qtrue;
-    }
-    if (rc2 == ENC_CODERANGE_7BIT) {
-	if (rb_enc_asciicompat(rb_enc_from_index(idx2)))
-	    return Qtrue;
-    }
-    return Qfalse;
-#endif
 }
 
 int
 rb_str_cmp(VALUE str1, VALUE str2)
 {
-#if WITH_OBJC
     return CFStringCompare((CFStringRef)str1, (CFStringRef)str2, 0);
-#else
-    long len;
-    int retval;
-    rb_encoding *enc;
-
-    enc = rb_enc_compatible(str1, str2);
-    len = lesser(RSTRING_BYTELEN(str1), RSTRING_BYTELEN(str2));
-    retval = memcmp(RSTRING_BYTEPTR(str1), RSTRING_BYTEPTR(str2), len);
-    if (retval == 0) {
-	if (RSTRING_BYTELEN(str1) == RSTRING_BYTELEN(str2)) {
-	    if (!enc) {
-		if (ENCODING_GET(str1) - ENCODING_GET(str2) > 0)
-		    return 1;
-		return -1;
-	    }
-	    return 0;
-	}
-	if (RSTRING_BYTELEN(str1) > RSTRING_BYTELEN(str2)) return 1;
-	return -1;
-    }
-    if (retval > 0) return 1;
-    return -1;
-#endif
 }
 
-#if WITH_OBJC
 bool rb_objc_str_is_pure(VALUE);
-#endif
 
 /*
  *  call-seq:
@@ -2499,7 +1018,6 @@
 	}
 	return rb_equal(str2, str1);
     }
-#if WITH_OBJC
     len = RSTRING_LEN(str1);
     if (len != RSTRING_LEN(str2))
 	return Qfalse;
@@ -2515,13 +1033,6 @@
     }
     if (CFEqual((CFTypeRef)str1, (CFTypeRef)str2))
 	return Qtrue;
-#else
-    if (!rb_str_comparable(str1, str2)) return Qfalse;
-    if (RSTRING_BYTELEN(str1) == (len = RSTRING_BYTELEN(str2)) &&
-	memcmp(RSTRING_BYTEPTR(str1), RSTRING_BYTEPTR(str2), len) == 0) {
-	return Qtrue;
-    }
-#endif
 
     return Qfalse;
 }
@@ -2539,15 +1050,8 @@
     if (TYPE(str2) != T_STRING || RSTRING_BYTELEN(str1) != RSTRING_BYTELEN(str2))
 	return Qfalse;
 
-#if WITH_OBJC
     if (CFEqual((CFTypeRef)str1, (CFTypeRef)str2))
 	return Qtrue;
-#else
-    if (!rb_str_comparable(str1, str2)) return Qfalse;
-    if (memcmp(RSTRING_BYTEPTR(str1), RSTRING_BYTEPTR(str2),
-	       lesser(RSTRING_BYTELEN(str1), RSTRING_BYTELEN(str2))) == 0)
-	return Qtrue;
-#endif
 
     return Qfalse;
 }
@@ -2618,46 +1122,13 @@
 static VALUE
 rb_str_casecmp(VALUE str1, VALUE str2)
 {
-#if WITH_OBJC
     return INT2FIX(CFStringCompare((CFStringRef)str1, (CFStringRef)str2,
 	kCFCompareCaseInsensitive));
-#else
-    long len;
-    rb_encoding *enc;
-    char *p1, *p1end, *p2, *p2end;
-
-    StringValue(str2);
-    enc = rb_enc_compatible(str1, str2);
-    if (!enc) {
-	return Qnil;
-    }
-
-    p1 = RSTRING_BYTEPTR(str1); p1end = RSTRING_END(str1);
-    p2 = RSTRING_BYTEPTR(str2); p2end = RSTRING_END(str2);
-    while (p1 < p1end && p2 < p2end) {
-	int c1 = rb_enc_codepoint(p1, p1end, enc);
-	int c2 = rb_enc_codepoint(p2, p2end, enc);
-
-	if (c1 != c2) {
-	    c1 = rb_enc_toupper(c1, enc);
-	    c2 = rb_enc_toupper(c2, enc);
-	    if (c1 > c2) return INT2FIX(1);
-	    if (c1 < c2) return INT2FIX(-1);
-	}
-	len = rb_enc_codelen(c1, enc);
-	p1 += len;
-	p2 += len;
-    }
-    if (RSTRING_BYTELEN(str1) == RSTRING_BYTELEN(str2)) return INT2FIX(0);
-    if (RSTRING_BYTELEN(str1) > RSTRING_BYTELEN(str2)) return INT2FIX(1);
-    return INT2FIX(-1);
-#endif
 }
 
 static long
 rb_str_index(VALUE str, VALUE sub, long offset)
 {
-#if WITH_OBJC
     CFRange r;
     return (CFStringFindWithOptions((CFStringRef)str, 
 		(CFStringRef)sub,
@@ -2665,45 +1136,6 @@
 		0,
 		&r))
 	? r.location : -1;
-#else
-    long pos;
-    char *s, *sptr;
-    long len, slen;
-    rb_encoding *enc;
-
-    enc = rb_enc_check(str, sub);
-    if (is_broken_string(sub)) {
-	return -1;
-    }
-    len = str_strlen(str, enc);
-    slen = str_strlen(sub, enc);
-    if (offset < 0) {
-	offset += len;
-	if (offset < 0) return -1;
-    }
-    if (len - offset < slen) return -1;
-    s = RSTRING_BYTEPTR(str);
-    if (offset) {
-	offset = str_offset(s, RSTRING_END(str), offset, enc, single_byte_optimizable(str));
-	s += offset;
-    }
-    if (slen == 0) return offset;
-    /* need proceed one character at a time */
-    sptr = RSTRING_BYTEPTR(sub);
-    slen = RSTRING_BYTELEN(sub);
-    len = RSTRING_BYTELEN(str) - offset;
-    for (;;) {
-	char *t;
-	pos = rb_memsearch(sptr, slen, s, len);
-	if (pos < 0) return pos;
-	t = rb_enc_right_char_head(s, s+pos, enc);
-	if (t == s) break;
-	if ((len -= t - s) <= 0) return -1;
-	offset += t - s;
-	s = t;
-    }
-    return pos + offset;
-#endif
 }
 
 /*
@@ -2779,7 +1211,6 @@
 static long
 rb_str_rindex(VALUE str, VALUE sub, long pos)
 {
-#if WITH_OBJC
     CFRange r;
     long sublen, strlen;
     sublen = RSTRING_LEN(sub);
@@ -2795,41 +1226,6 @@
 		kCFCompareBackwards,
 		&r))
 	? r.location : -1;
-#else
-    long len, slen;
-    char *s, *sbeg, *e, *t;
-    rb_encoding *enc;
-    int singlebyte = single_byte_optimizable(str);
-
-    enc = rb_enc_check(str, sub);
-    if (is_broken_string(sub)) {
-	return -1;
-    }
-    len = str_strlen(str, enc);
-    slen = str_strlen(sub, enc);
-    /* substring longer than string */
-    if (len < slen) return -1;
-    if (len - pos < slen) {
-	pos = len - slen;
-    }
-    if (len == 0) {
-	return pos;
-    }
-    sbeg = RSTRING_BYTEPTR(str);
-    e = RSTRING_END(str);
-    t = RSTRING_BYTEPTR(sub);
-    slen = RSTRING_BYTELEN(sub);
-    for (;;) {
-	s = str_nth(sbeg, e, pos, enc, singlebyte);
-	if (!s) return -1;
-	if (memcmp(s, t, slen) == 0) {
-	    return pos;
-	}
-	if (pos == 0) break;
-	pos--;
-    }
-    return -1;
-#endif
 }
 
 
@@ -2984,146 +1380,7 @@
     return result;
 }
 
-enum neighbor_char {
-    NEIGHBOR_NOT_CHAR,
-    NEIGHBOR_FOUND,
-    NEIGHBOR_WRAPPED
-};
-
-#if !WITH_OBJC
-static enum neighbor_char
-enc_succ_char(char *p, int len, rb_encoding *enc)
-{
-    int i, l;
-    while (1) {
-        for (i = len-1; 0 <= i && (unsigned char)p[i] == 0xff; i--)
-            p[i] = '\0';
-        if (i < 0)
-            return NEIGHBOR_WRAPPED;
-        ++((unsigned char*)p)[i];
-        l = rb_enc_precise_mbclen(p, p+len, enc);
-        if (MBCLEN_CHARFOUND_P(l)) {
-            l = MBCLEN_CHARFOUND_LEN(l);
-            if (l == len) {
-                return NEIGHBOR_FOUND;
-            }
-            else {
-                memset(p+l, 0xff, len-l);
-            }
-        }
-        if (MBCLEN_INVALID_P(l) && i < len-1) {
-            int len2, l2;
-            for (len2 = len-1; 0 < len2; len2--) {
-                l2 = rb_enc_precise_mbclen(p, p+len2, enc);
-                if (!MBCLEN_INVALID_P(l2))
-                    break;
-            }
-            memset(p+len2+1, 0xff, len-(len2+1));
-        }
-    }
-}
-
-static enum neighbor_char
-enc_pred_char(char *p, int len, rb_encoding *enc)
-{
-    int i, l;
-    while (1) {
-        for (i = len-1; 0 <= i && (unsigned char)p[i] == 0; i--)
-            p[i] = '\xff';
-        if (i < 0)
-            return NEIGHBOR_WRAPPED;
-        --((unsigned char*)p)[i];
-        l = rb_enc_precise_mbclen(p, p+len, enc);
-        if (MBCLEN_CHARFOUND_P(l)) {
-            l = MBCLEN_CHARFOUND_LEN(l);
-            if (l == len) {
-                return NEIGHBOR_FOUND;
-            }
-            else {
-                memset(p+l, 0, len-l);
-            }
-        }
-        if (MBCLEN_INVALID_P(l) && i < len-1) {
-            int len2, l2;
-            for (len2 = len-1; 0 < len2; len2--) {
-                l2 = rb_enc_precise_mbclen(p, p+len2, enc);
-                if (!MBCLEN_INVALID_P(l2))
-                    break;
-            }
-            memset(p+len2+1, 0, len-(len2+1));
-        }
-    }
-}
-#endif
-
 /*
-  overwrite +p+ by succeeding letter in +enc+ and returns
-  NEIGHBOR_FOUND or NEIGHBOR_WRAPPED.
-  When NEIGHBOR_WRAPPED, carried-out letter is stored into carry.
-  assuming each ranges are successive, and mbclen
-  never change in each ranges.
-  NEIGHBOR_NOT_CHAR is returned if invalid character or the range has only one
-  character.
- */
-#if !WITH_OBJC
-static enum neighbor_char
-enc_succ_alnum_char(char *p, int len, rb_encoding *enc, char *carry)
-{
-    enum neighbor_char ret;
-    int c;
-    int ctype;
-    int range;
-    char save[ONIGENC_CODE_TO_MBC_MAXLEN];
-
-    c = rb_enc_mbc_to_codepoint(p, p+len, enc);
-    if (rb_enc_isctype(c, ONIGENC_CTYPE_DIGIT, enc))
-        ctype = ONIGENC_CTYPE_DIGIT;
-    else if (rb_enc_isctype(c, ONIGENC_CTYPE_ALPHA, enc))
-        ctype = ONIGENC_CTYPE_ALPHA;
-    else
-        return NEIGHBOR_NOT_CHAR;
-
-    MEMCPY(save, p, char, len);
-    ret = enc_succ_char(p, len, enc);
-    if (ret == NEIGHBOR_FOUND) {
-        c = rb_enc_mbc_to_codepoint(p, p+len, enc);
-        if (rb_enc_isctype(c, ctype, enc))
-            return NEIGHBOR_FOUND;
-    }
-    MEMCPY(p, save, char, len);
-    range = 1;
-    while (1) {
-        MEMCPY(save, p, char, len);
-        ret = enc_pred_char(p, len, enc);
-        if (ret == NEIGHBOR_FOUND) {
-            c = rb_enc_mbc_to_codepoint(p, p+len, enc);
-            if (!rb_enc_isctype(c, ctype, enc)) {
-                MEMCPY(p, save, char, len);
-                break;
-            }
-        }
-        else {
-            MEMCPY(p, save, char, len);
-            break;
-        }
-        range++;
-    }
-    if (range == 1) {
-        return NEIGHBOR_NOT_CHAR;
-    }
-
-    if (ctype != ONIGENC_CTYPE_DIGIT) {
-        MEMCPY(carry, p, char, len);
-        return NEIGHBOR_WRAPPED;
-    }
-
-    MEMCPY(carry, p, char, len);
-    enc_succ_char(carry, len, enc);
-    return NEIGHBOR_WRAPPED;
-}
-#endif
-
-/*
  *  call-seq:
  *     str.succ   => new_str
  *     str.next   => new_str
@@ -3151,7 +1408,6 @@
 VALUE
 rb_str_succ(VALUE orig)
 {
-#if WITH_OBJC
     UniChar *buf;
     UniChar carry;
     long i, len;
@@ -3213,79 +1469,6 @@
     CFMakeCollectable(newstr);
 
     return (VALUE)newstr;
-#else
-    rb_encoding *enc;
-    VALUE str;
-    char *sbeg, *s, *e;
-    int c = -1;
-    long l;
-    char carry[ONIGENC_CODE_TO_MBC_MAXLEN] = "\1";
-    int carry_pos = 0, carry_len = 1;
-
-    str = rb_str_new5(orig, RSTRING_PTR(orig), RSTRING_LEN(orig));
-#if !WITH_OBJC
-    rb_enc_cr_str_copy_for_substr(str, orig);
-    OBJ_INFECT(str, orig);
-#endif
-    if (RSTRING_LEN(str) == 0) return str;
-
-    enc = STR_ENC_GET(orig);
-    sbeg = RSTRING_BYTEPTR(str);
-    s = e = sbeg + RSTRING_BYTELEN(str);
-
-    while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) {
-        enum neighbor_char neighbor;
-	if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
-        neighbor = enc_succ_alnum_char(s, l, enc, carry);
-        if (neighbor == NEIGHBOR_NOT_CHAR)
-            continue;
-        if (neighbor == NEIGHBOR_FOUND) {
-	    RSTRING_SYNC(str);
-            return str;
-	}
-        c = 1;
-        carry_pos = s - sbeg;
-        carry_len = l;
-    }
-    if (c == -1) {		/* str contains no alnum */
-	s = e;
-	while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) {
-            enum neighbor_char neighbor;
-            if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
-            neighbor = enc_succ_char(s, l, enc);
-	    if (neighbor == NEIGHBOR_FOUND) {
-		RSTRING_SYNC(str);
-		return str;
-	    }
-            if (rb_enc_precise_mbclen(s, s+l, enc) != l) {
-                /* wrapped to \0...\0.  search next valid char. */
-                enc_succ_char(s, l, enc);
-            }
-            if (!rb_enc_asciicompat(enc)) {
-                MEMCPY(carry, s, char, l);
-                carry_len = l;
-            }
-            carry_pos = s - sbeg;
-	}
-    }
-#if WITH_OBJC
-    CFMutableDataRef data = (CFMutableDataRef)rb_str_cfdata(str);
-    CFDataSetLength(data, RSTRING_BYTELEN(str) + carry_len);
-    s = (char *)CFDataGetMutableBytePtr(data);
-    memmove(s + carry_len, s, RSTRING_BYTELEN(str) - carry_pos);
-    memmove(s, carry, carry_len);
-    RSTRING_SYNC(str);
-#else
-    RESIZE_CAPA(str, RSTRING_BYTELEN(str) + carry_len);
-    s = RSTRING_BYTEPTR(str) + carry_pos;
-    memmove(s + carry_len, s, RSTRING_BYTELEN(str) - carry_pos);
-    memmove(s, carry, carry_len);
-    STR_SET_LEN(str, RSTRING_BYTELEN(str) + carry_len);
-    RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-    rb_enc_str_coderange(str);
-#endif
-    return str;
-#endif
 }
 
 
@@ -3335,15 +1518,11 @@
     VALUE current, after_end;
     ID succ;
     int n, excl;
-#if !WITH_OBJC
-    rb_encoding *enc;
-#endif
 
     rb_scan_args(argc, argv, "11", &end, &exclusive);
     excl = RTEST(exclusive);
     succ = rb_intern("succ");
     StringValue(end);
-#if WITH_OBJC
     if (RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1) {
 	UniChar c = CFStringGetCharacterAtIndex((CFStringRef)beg, 0);
 	UniChar e = CFStringGetCharacterAtIndex((CFStringRef)end, 0);
@@ -3363,22 +1542,6 @@
 		break;
 	}
 	return beg;
-#else
-    enc = rb_enc_check(beg, end);
-    if (RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1 &&
-	is_ascii_string(beg) && is_ascii_string(end)) {
-	char c = RSTRING_PTR(beg)[0];
-	char e = RSTRING_PTR(end)[0];
-
-	if (c > e || (excl && c == e)) return beg;
-	for (;;) {
-	    rb_yield(rb_enc_str_new(&c, 1, enc));
-	    if (!excl && c == e) break;
-	    c++;
-	    if (excl && c == e) break;
-	}
-	return beg;
-#endif
     }
     n = rb_str_cmp(beg, end);
     if (n > 0 || (excl && n == 0)) return beg;
@@ -3519,54 +1682,20 @@
 rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
 {
     rb_str_modify(str);
-#if WITH_OBJC
     CFStringReplace((CFMutableStringRef)str, CFRangeMake(beg, len), 
 	(CFStringRef)val);
-#else
-    if (len < RSTRING_BYTELEN(val)) {
-	/* expand string */
-	RESIZE_CAPA(str, RSTRING_BYTELEN(str) + RSTRING_BYTELEN(val) - len + 1);
-    }
-
-    if (RSTRING_BYTELEN(val) != len) {
-	memmove(RSTRING_BYTEPTR(str) + beg + RSTRING_BYTELEN(val),
-		RSTRING_BYTEPTR(str) + beg + len,
-		RSTRING_BYTELEN(str) - (beg + len));
-    }
-    if (RSTRING_BYTELEN(val) < beg && len < 0) {
-	MEMZERO(RSTRING_BYTEPTR(str) + RSTRING_BYTELEN(str), char, -len);
-    }
-    if (RSTRING_BYTELEN(val) > 0) {
-	memmove(RSTRING_BYTEPTR(str)+beg, RSTRING_BYTEPTR(val), RSTRING_BYTELEN(val));
-    }
-    STR_SET_LEN(str, RSTRING_BYTELEN(str) + RSTRING_BYTELEN(val) - len);
-    if (RSTRING_BYTEPTR(str)) {
-	RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-    }
-    OBJ_INFECT(str, val);
-#endif
 }
 
 static void
 rb_str_splice(VALUE str, long beg, long len, VALUE val)
 {
     long slen;
-#if !WITH_OBJC
-    char *p, *e;
-    rb_encoding *enc;
-    int singlebyte = single_byte_optimizable(str);
-#endif
 
     if (len < 0) rb_raise(rb_eIndexError, "negative length %ld", len);
 
     StringValue(val);
     rb_str_modify(str);
-#if WITH_OBJC
     slen = CFStringGetLength((CFStringRef)str);
-#else
-    enc = rb_enc_check(str, val);
-    slen = str_strlen(str, enc);
-#endif
 
     if (slen < beg) {
       out_of_range:
@@ -3581,19 +1710,7 @@
     if (slen < len || slen < beg + len) {
 	len = slen - beg;
     }
-#if WITH_OBJC
     rb_str_splice_0(str, beg, len, val);
-#else
-    p = str_nth(RSTRING_BYTEPTR(str), RSTRING_END(str), beg, enc, singlebyte);
-    if (!p) p = RSTRING_END(str);
-    e = str_nth(p, RSTRING_END(str), len, enc, singlebyte);
-    if (!e) e = RSTRING_END(str);
-    /* error check */
-    beg = p - RSTRING_BYTEPTR(str);	/* physical position */
-    len = e - p;		/* physical length */
-    rb_str_splice_0(str, beg, len, val);
-    rb_enc_associate(str, enc);
-#endif
 }
 
 void
@@ -3607,9 +1724,6 @@
 {
     VALUE match;
     long start, end, len;
-#if !WITH_OBJC
-    rb_encoding *enc;
-#endif
     struct re_registers *regs;
 
     if (rb_reg_search(re, str, 0, 0) < 0) {
@@ -3635,13 +1749,7 @@
     end = END(nth);
     len = end - start;
     StringValue(val);
-#if !WITH_OBJC
-    enc = rb_enc_check(str, val);
-#endif
     rb_str_splice_0(str, start, len, val);
-#if !WITH_OBJC
-    rb_enc_associate(str, enc);
-#endif
 }
 
 static VALUE
@@ -3862,18 +1970,11 @@
 
     pat = get_pat(argv[0], 1);
     if (rb_reg_search(pat, str, 0, 0) >= 0) {
-#if !WITH_OBJC
-	rb_encoding *enc;
-	int cr = ENC_CODERANGE(str);
-#endif
 
 	match = rb_backref_get();
 	regs = RMATCH_REGS(match);
 
 	if (iter || !NIL_P(hash)) {
-#if !WITH_OBJC
-	    char *p = RSTRING_BYTEPTR(str); long len = RSTRING_BYTELEN(str);
-#endif
 
             if (iter) {
                 rb_match_busy(match);
@@ -3883,56 +1984,18 @@
                 repl = rb_hash_aref(hash, rb_str_subseq(str, BEG(0), END(0) - BEG(0)));
                 repl = rb_obj_as_string(repl);
             }
-#if !WITH_OBJC
-	    str_mod_check(str, p, len);
-#endif
 	    str_frozen_check(str);
 	    if (iter) rb_backref_set(match);
 	}
 	else {
 	    repl = rb_reg_regsub(repl, str, regs, pat);
 	}
-#if !WITH_OBJC
-        enc = rb_enc_compatible(str, repl);
-        if (!enc) {
-            rb_encoding *str_enc = STR_ENC_GET(str);
-            if (coderange_scan(RSTRING_BYTEPTR(str), BEG(0), str_enc) != ENC_CODERANGE_7BIT ||
-                coderange_scan(RSTRING_BYTEPTR(str)+END(0),
-			       RSTRING_BYTELEN(str)-END(0), str_enc) != ENC_CODERANGE_7BIT) {
-                rb_raise(rb_eArgError, "character encodings differ: %s and %s",
-			 rb_enc_name(str_enc),
-			 rb_enc_name(STR_ENC_GET(repl)));
-            }
-            enc = STR_ENC_GET(repl);
-        }
-#endif
+
 	rb_str_modify(str);
-#if WITH_OBJC
 	RSTRING_SYNC(str);
 	rb_str_splice_0(str, BEG(0), END(0) - BEG(0), repl);
 	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;
-	}
-	plen = END(0) - BEG(0);
-	if (RSTRING_BYTELEN(repl) > plen) {
-	    RESIZE_CAPA(str, RSTRING_BYTELEN(str) + RSTRING_BYTELEN(repl) - plen);
-	}
-	if (RSTRING_BYTELEN(repl) != plen) {
-	    memmove(RSTRING_BYTEPTR(str) + BEG(0) + RSTRING_BYTELEN(repl),
-		    RSTRING_BYTEPTR(str) + BEG(0) + plen,
-		    RSTRING_BYTELEN(str) - BEG(0) - plen);
-	}
-	memcpy(RSTRING_BYTEPTR(str) + BEG(0),
-	       RSTRING_BYTEPTR(repl), RSTRING_BYTELEN(repl));
-	STR_SET_LEN(str, RSTRING_BYTELEN(str) + RSTRING_BYTELEN(repl) - plen);
-	RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-	ENC_CODERANGE_SET(str, cr);
-#endif
+
 	if (tainted) OBJ_TAINT(str);
 
 	return str;
@@ -4017,20 +2080,11 @@
 	return rb_str_dup(str);
     }
 
-#if WITH_OBJC
     dest = rb_str_new5(str, NULL, 0);
     slen = RSTRING_LEN(str);
     sp = RSTRING_PTR(str);
     cp = sp;
     str_enc = NULL;
-#else
-    blen = RSTRING_BYTELEN(str) + 30; /* len + margin */
-    dest = rb_str_buf_new(blen);
-    sp = RSTRING_BYTEPTR(str);
-    slen = RSTRING_BYTELEN(str);
-    cp = sp;
-    str_enc = STR_ENC_GET(str);
-#endif
 
     do {
 	n++;
@@ -4072,11 +2126,7 @@
 	     * in order to prevent infinite loops.
 	     */
 	    if (slen <= END(0)) break;
-#if WITH_OBJC
 	    len = 1;
-#else
-	    len = rb_enc_mbclen(sp+END(0), sp+slen, str_enc);
-#endif
             rb_enc_str_buf_cat(dest, sp+END(0), len, str_enc);
 	    offset = END(0) + len;
 	}
@@ -4088,7 +2138,6 @@
         rb_enc_str_buf_cat(dest, cp, slen - offset, str_enc);
     }
     rb_backref_set(match);
-#if WITH_OBJC
     if (bang) {
 	rb_str_modify(str);
 	RSTRING_SYNC(str);
@@ -4100,17 +2149,6 @@
 	    tainted = 1;
 	str = dest;
     }
-#else
-    if (bang) {
-        rb_str_shared_replace(str, dest);
-    }
-    else {
-	RBASIC(dest)->klass = rb_obj_class(str);
-	RBASIC(dest)->isa = RCLASS_OCID(RBASIC(dest)->klass);
-	OBJ_INFECT(dest, str);
-	str = dest;
-    }
-#endif
 
     if (tainted) OBJ_TAINT(str);
     return str;
@@ -4188,7 +2226,6 @@
 rb_str_replace(VALUE str, VALUE str2)
 {
     if (str == str2) return str;
-#if WITH_OBJC
     rb_str_modify(str);
     CFDataRef data = (CFDataRef)rb_str_cfdata2(str2);
     if (data != NULL) {
@@ -4203,31 +2240,6 @@
     rb_gc_malloc_increase(CFStringGetLength((CFStringRef)str2) * sizeof(UniChar));
     if (OBJ_TAINTED(str2))
 	OBJ_TAINT(str);
-#else
-    StringValue(str2);
-    len = RSTRING_BYTELEN(str2);
-    if (STR_ASSOC_P(str2)) {
-	str2 = rb_str_new4(str2);
-    }
-    if (STR_SHARED_P(str2)) {
-	if (str_independent(str) && !STR_EMBED_P(str)) {
-	    xfree(RSTRING_BYTEPTR(str));
-	}
-	STR_SET_NOEMBED(str);
-	RSTRING(str)->as.heap.len = len;
-	RSTRING(str)->as.heap.ptr = RSTRING_BYTEPTR(str2);
-	FL_SET(str, ELTS_SHARED);
-	FL_UNSET(str, STR_ASSOC);
-	RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
-    }
-    else {
-	rb_str_modify(str);
-	str_replace_shared(str, rb_str_new4(str2));
-    }
-
-    OBJ_INFECT(str, str2);
-    rb_enc_cr_str_exact_copy(str, str2);
-#endif
     return str;
 }
 
@@ -4244,20 +2256,9 @@
 static VALUE
 rb_str_clear(VALUE str)
 {
-#if WITH_OBJC
     rb_str_modify(str);
     CFStringDelete((CFMutableStringRef)str, 
 	CFRangeMake(0, CFStringGetLength((CFStringRef)str)));
-#else
-    /* rb_str_modify() */	/* no need for str_make_independent */
-    if (str_independent(str) && !STR_EMBED_P(str)) {
-	free(RSTRING_BYTEPTR(str));
-    }
-    STR_SET_EMBED(str);
-    STR_SET_EMBED_LEN(str, 0);
-    RSTRING_BYTEPTR(str)[0] = 0;
-    ENC_CODERANGE_CLEAR(str);
-#endif
     return str;
 }
 
@@ -4318,9 +2319,7 @@
         pos += n;
 
     RSTRING_BYTEPTR(str)[pos] = byte;
-#if WITH_OBJC
     RSTRING_SYNC(str);
-#endif
 
     return value;
 }
@@ -4336,7 +2335,6 @@
 static VALUE
 rb_str_reverse_bang(VALUE str)
 {
-#if WITH_OBJC
     CFIndex i, n;
     UniChar *buffer;
 
@@ -4353,26 +2351,7 @@
     }
     CFStringDelete((CFMutableStringRef)str, CFRangeMake(0, n));
     CFStringAppendCharacters((CFMutableStringRef)str, (const UniChar *)buffer, n);
-#else
-    char *s, *e, c;
 
-    if (RSTRING_BYTELEN(str) > 1) {
-	rb_str_modify(str);
-	s = RSTRING_BYTEPTR(str);
-	e = RSTRING_END(str) - 1;
-
-	if (single_byte_optimizable(str)) {
-	    while (s < e) {
-		c = *s;
-		*s++ = *e;
- 		*e-- = c;
-	    }
-	}
-	else {
-	    rb_str_shared_replace(str, rb_str_reverse(str));
-	}
-    }
-#endif
     return str;
 }
 
@@ -4388,43 +2367,9 @@
 static VALUE
 rb_str_reverse(VALUE str)
 {
-#if WITH_OBJC
     VALUE obj = rb_str_dup(str);
     rb_str_reverse_bang(obj);
     return obj;
-#else
-    rb_encoding *enc;
-    VALUE obj;
-    char *s, *e, *p;
-
-    if (RSTRING_BYTELEN(str) <= 1) return rb_str_dup(str);
-    enc = STR_ENC_GET(str);
-    obj = rb_str_new5(str, 0, RSTRING_BYTELEN(str));
-    s = RSTRING_BYTEPTR(str); e = RSTRING_END(str);
-    p = RSTRING_END(obj);
-
-    if (RSTRING_BYTELEN(str) > 1) {
-	if (single_byte_optimizable(str)) {
-	    while (s < e) {
-		*--p = *s++;
-	    }
-	}
-	else {
-	    while (s < e) {
-		int clen = rb_enc_mbclen(s, e, enc);
-
-		p -= clen;
-		memcpy(p, s, clen);
-		s += clen;
-	    }
-	}
-    }
-    STR_SET_LEN(obj, RSTRING_BYTELEN(str));
-    OBJ_INFECT(obj, str);
-    rb_enc_cr_str_copy_for_substr(obj, str);
-
-    return obj;
-#endif
 }
 
 /*
@@ -4525,11 +2470,7 @@
 static VALUE
 rb_str_to_s(VALUE str)
 {
-#if WITH_OBJC
     if (!rb_objc_str_is_pure(str)) {
-#else
-    if (rb_obj_class(str) != rb_cString) {
-#endif
 	VALUE dup = str_alloc(rb_cString);
 	rb_str_replace(dup, str);
 	return dup;
@@ -4540,18 +2481,10 @@
 static void
 str_cat_char(VALUE str, int c, rb_encoding *enc)
 {
-#if WITH_OBJC
     char buf[2];
     buf[0] = (char)c;
     buf[1] = '\0';
     CFStringAppendCString((CFMutableStringRef)str, buf, kCFStringEncodingUTF8);
-#else
-    char s[16];
-    int n = rb_enc_codelen(c, enc);
-
-    rb_enc_mbcput(c, s, enc);
-    rb_enc_str_buf_cat(str, s, n, enc);
-#endif
 }
 
 static void
@@ -4580,7 +2513,6 @@
     const char *p, *pend;
     VALUE result;
 
-#if WITH_OBJC
     if (rb_objc_str_is_bytestring(str)) {
 	p = (const char *)RSTRING_BYTEPTR(str); 
 	pend = (const char *)RSTRING_END(str);
@@ -4591,46 +2523,22 @@
     }
     if (p == NULL)
 	return rb_str_new2("\"\"");
-#else
     p = RSTRING_BYTEPTR(str); pend = RSTRING_END(str);
-#endif
     result = rb_str_buf_new2("");
-#if !WITH_OBJC
-    if (!rb_enc_asciicompat(enc)) enc = rb_usascii_encoding();
-    rb_enc_associate(result, enc);
-#endif
     str_cat_char(result, '"', enc);
     while (p < pend) {
 	int c;
 	int n;
 	int cc;
 
-#if WITH_OBJC
 	c = *p;
 	n = 1;
-#else
-        n = rb_enc_precise_mbclen(p, pend, enc);
-        if (!MBCLEN_CHARFOUND_P(n)) {
-            p++;
-            n = 1;
-            goto escape_codepoint;
-        }
-        n = MBCLEN_CHARFOUND_LEN(n);
 
-	c = rb_enc_codepoint(p, pend, enc);
-	n = rb_enc_codelen(c, enc);
-#endif
-
 	p += n;
 	if (c == '"'|| c == '\\' ||
 	    (c == '#' &&
              p < pend &&
-#if WITH_OBJC
 	     ((cc = *p),
-#else
-             MBCLEN_CHARFOUND_P(rb_enc_precise_mbclen(p,pend,enc)) &&
-             (cc = rb_enc_codepoint(p,pend,enc),
-#endif
               (cc == '$' || cc == '@' || cc == '{')))) {
 	    prefix_escape(result, c, enc);
 	}
@@ -4666,9 +2574,6 @@
 	    char *s;
             const char *q;
 
-#if !WITH_OBJC
-	  escape_codepoint:
-#endif
             for (q = p-n; q < p; q++) {
                 s = buf;
                 sprintf(buf, "\\x%02X", *q & 0377);
@@ -4704,7 +2609,6 @@
     VALUE result;
 
     len = 2;			/* "" */
-#if WITH_OBJC
     if (rb_objc_str_is_bytestring(str)) {
 	p = RSTRING_BYTEPTR(str); 
 	pend = RSTRING_END(str);
@@ -4713,9 +2617,6 @@
 	p = RSTRING_PTR(str); 
 	pend = p + RSTRING_LEN(str);
     }
-#else
-    p = RSTRING_BYTEPTR(str); pend = p + RSTRING_BYTELEN(str);
-#endif
     while (p < pend) {
 	unsigned char c = *p++;
 	switch (c) {
@@ -4805,16 +2706,12 @@
     *q++ = '"';
     if (!rb_enc_asciicompat(enc0)) {
 	sprintf(q, ".force_encoding(\"%s\")", rb_enc_name(enc0));
-#if !WITH_OBJC
-	enc0 = rb_ascii8bit_encoding();
-#endif
+
     }
 
     OBJ_INFECT(result, str);
     /* result from dump is ASCII */
-#if !WITH_OBJC
-    rb_enc_associate(result, enc0);
-#endif
+
     RSTRING_SYNC(result);
     return result;
 }
@@ -4832,7 +2729,6 @@
 static VALUE
 rb_str_upcase_bang(VALUE str)
 {
-#if WITH_OBJC
     CFHashCode h;
     rb_str_modify(str);
     h = CFHash((CFTypeRef)str);
@@ -4840,30 +2736,6 @@
     if (h == CFHash((CFTypeRef)str))
 	return Qnil;
     return str;
-#else
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-    int cr = ENC_CODERANGE(str);
-
-    rb_str_modify(str);
-    enc = STR_ENC_GET(str);
-    s = RSTRING_BYTEPTR(str); send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-
-	if (rb_enc_islower(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    ENC_CODERANGE_SET(str, cr);
-    if (modify) return str;
-    return Qnil;
-#endif
 }
 
 
@@ -4900,7 +2772,6 @@
 static VALUE
 rb_str_downcase_bang(VALUE str)
 {
-#if WITH_OBJC
     CFHashCode h;
     rb_str_modify(str);
     h = CFHash((CFTypeRef)str);
@@ -4908,30 +2779,6 @@
     if (h == CFHash((CFTypeRef)str))
 	return Qnil;
     return str;
-#else
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-    int cr = ENC_CODERANGE(str);
-
-    rb_str_modify(str);
-    enc = STR_ENC_GET(str);
-    s = RSTRING_BYTEPTR(str); send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-
-	if (rb_enc_isupper(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    ENC_CODERANGE_SET(str, cr);
-    if (modify) return str;
-    return Qnil;
-#endif
 }
 
 
@@ -4973,7 +2820,6 @@
 static VALUE
 rb_str_capitalize_bang(VALUE str)
 {
-#if WITH_OBJC
     CFStringRef tmp;
     long i, n;
     bool changed;
@@ -5002,37 +2848,6 @@
     CFStringReplaceAll((CFMutableStringRef)str, tmp);
     CFRelease(tmp);
     return str;
-#else
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-    int c;
-    int cr = ENC_CODERANGE(str);
-
-    rb_str_modify(str);
-    enc = STR_ENC_GET(str);
-    if (RSTRING_BYTELEN(str) == 0 || !RSTRING_BYTEPTR(str)) return Qnil;
-    s = RSTRING_BYTEPTR(str); send = RSTRING_END(str);
-
-    c = rb_enc_codepoint(s, send, enc);
-    if (rb_enc_islower(c, enc)) {
-	rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
-	modify = 1;
-    }
-    s += rb_enc_codelen(c, enc);
-    while (s < send) {
-	c = rb_enc_codepoint(s, send, enc);
-	if (rb_enc_isupper(c, enc)) {
-	    rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    ENC_CODERANGE_SET(str, cr);
-    if (modify) return str;
-    return Qnil;
-#endif
 }
 
 
@@ -5070,7 +2885,6 @@
 static VALUE
 rb_str_swapcase_bang(VALUE str)
 {
-#if WITH_OBJC
     CFIndex i, n;
     UniChar *buffer;
     bool changed;
@@ -5103,35 +2917,6 @@
     CFStringDelete((CFMutableStringRef)str, CFRangeMake(0, n));
     CFStringAppendCharacters((CFMutableStringRef)str, (const UniChar *)buffer, n);
     return str;
-#else
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-    int cr = ENC_CODERANGE(str);
-
-    rb_str_modify(str);
-    enc = STR_ENC_GET(str);
-    s = RSTRING_BYTEPTR(str); send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-
-	if (rb_enc_isupper(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
-	    modify = 1;
-	}
-	else if (rb_enc_islower(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    ENC_CODERANGE_SET(str, cr);
-    if (modify) return str;
-    return Qnil;
-#endif
 }
 
 
@@ -5155,51 +2940,6 @@
     return str;
 }
 
-#if !WITH_OBJC
-typedef unsigned char *USTR;
-
-struct tr {
-    int gen, now, max;
-    char *p, *pend;
-};
-
-static int
-trnext(struct tr *t, rb_encoding *enc)
-{
-    for (;;) {
-	if (!t->gen) {
-	    if (t->p == t->pend) return -1;
-	    if (t->p < t->pend - 1 && *t->p == '\\') {
-		t->p++;
-	    }
-	    t->now = rb_enc_codepoint(t->p, t->pend, enc);
-	    t->p += rb_enc_codelen(t->now, enc);
-	    if (t->p < t->pend - 1 && *t->p == '-') {
-		t->p++;
-		if (t->p < t->pend) {
-		    int c = rb_enc_codepoint(t->p, t->pend, enc);
-		    t->p += rb_enc_codelen(c, enc);
-		    if (t->now > c) continue;
-		    t->gen = 1;
-		    t->max = c;
-		}
-	    }
-	    return t->now;
-	}
-	else if (++t->now < t->max) {
-	    return t->now;
-	}
-	else {
-	    t->gen = 0;
-	    return t->max;
-	}
-    }
-}
-
-static VALUE rb_str_delete_bang(int,VALUE*,VALUE);
-#endif
-
-#if WITH_OBJC
 typedef void str_charset_find_cb
 (CFRange *, const CFRange *, CFStringRef, UniChar, void *);
 
@@ -5507,12 +3247,10 @@
     }
     _ctx->changed = true;
 }
-#endif
 
 static VALUE
 tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
 {
-#if WITH_OBJC
     struct tr_trans_cb_ctx _ctx;
 
     StringValue(src);
@@ -5543,205 +3281,6 @@
 	CFRelease(_ctx.opt);
 
     return _ctx.changed ? str : Qnil;
-#else
-    SIGNED_VALUE trans[256];
-    rb_encoding *enc, *e1, *e2;
-    struct tr trsrc, trrepl;
-    int cflag = 0;
-    int c, last = 0, modify = 0, i;
-    char *s, *send;
-    VALUE hash = 0;
-
-    StringValue(src);
-    StringValue(repl);
-    if (RSTRING_BYTELEN(str) == 0 || !RSTRING_BYTEPTR(str)) return Qnil;
-    trsrc.p = RSTRING_BYTEPTR(src); trsrc.pend = trsrc.p + RSTRING_BYTELEN(src);
-    if (RSTRING_BYTELEN(src) >= 2 && RSTRING_BYTEPTR(src)[0] == '^') {
-	cflag++;
-	trsrc.p++;
-    }
-    if (RSTRING_BYTELEN(repl) == 0) {
-	return rb_str_delete_bang(1, &src, str);
-    }
-    e1 = rb_enc_check(str, src);
-    e2 = rb_enc_check(str, repl);
-    if (e1 == e2) {
-	enc = e1;
-    }
-    else {
-	enc = rb_enc_check(src, repl);
-    }
-    trrepl.p = RSTRING_BYTEPTR(repl);
-    trrepl.pend = trrepl.p + RSTRING_BYTELEN(repl);
-    trsrc.gen = trrepl.gen = 0;
-    trsrc.now = trrepl.now = 0;
-    trsrc.max = trrepl.max = 0;
-
-    if (cflag) {
-	for (i=0; i<256; i++) {
-	    trans[i] = 1;
-	}
-	while ((c = trnext(&trsrc, enc)) >= 0) {
-	    if (c < 256) {
-		trans[c] = -1;
-	    }
-	    else {
-		if (!hash) hash = rb_hash_new();
-		rb_hash_aset(hash, INT2NUM(c), Qtrue);
-	    }
-	}
-	while ((c = trnext(&trrepl, enc)) >= 0)
-	    /* retrieve last replacer */;
-	last = trrepl.now;
-	for (i=0; i<256; i++) {
-	    if (trans[i] >= 0) {
-		trans[i] = last;
-	    }
-	}
-    }
-    else {
-	int r;
-
-	for (i=0; i<256; i++) {
-	    trans[i] = -1;
-	}
-	while ((c = trnext(&trsrc, enc)) >= 0) {
-	    r = trnext(&trrepl, enc);
-	    if (r == -1) r = trrepl.now;
-	    if (c < 256) {
-		trans[c] = INT2NUM(r);
-	    }
-	    else {
-		if (!hash) hash = rb_hash_new();
-		rb_hash_aset(hash, INT2NUM(c), INT2NUM(r));
-	    }
-	}
-    }
-
-    rb_str_modify(str);
-    s = RSTRING_BYTEPTR(str); send = RSTRING_END(str);
-    if (sflag) {
-	int clen, tlen, max = RSTRING_BYTELEN(str);
-	int offset, save = -1;
-	char *buf = ALLOC_N(char, max), *t = buf;
-	VALUE v;
-
-	if (cflag) tlen = rb_enc_codelen(last, enc);
-	while (s < send) {
-	    c = rb_enc_codepoint(s, send, enc);
-	    tlen = clen = rb_enc_codelen(c, enc);
-
-	    s += clen;
-	    if (c < 256) {
-		v = trans[c] >= 0 ? trans[c] : Qnil;
-	    }
-	    else {
-		v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
-	    }
-	    if (!NIL_P(v)) {
-		if (!cflag) {
-		    c = NUM2INT(v);
-		    if (save == c) continue;
-		    save = c;
-		    tlen = rb_enc_codelen(c, enc);
-		    modify = 1;
-		}
-		else {
-		    save = c = last;
-		    modify = 1;
-		}
-	    }
-	    else {
-		save = -1;
-	    }
-	    while (t - buf + tlen >= max) {
-		offset = t - buf;
-		max *= 2;
-		REALLOC_N(buf, char, max);
-		t = buf + offset;
-	    }
-	    rb_enc_mbcput(c, t, enc);
-	    t += tlen;
-	}
-	*t = '\0';
-	GC_WB(&RSTRING(str)->as.heap.ptr, buf);
-	RSTRING(str)->as.heap.len = t - buf;
-	STR_SET_NOEMBED(str);
-	RSTRING(str)->as.heap.aux.capa = max;
-    }
-    else if (rb_enc_mbmaxlen(enc) == 1) {
-	while (s < send) {
-	    c = (unsigned char)*s;
-	    if (trans[c] >= 0) {
-		if (!cflag) {
-		    c = FIX2INT(trans[c]);
-		    *s = c;
-		    modify = 1;
-		}
-		else {
-		    *s = last;
-		    modify = 1;
-		}
-	    }
-	    s++;
-	}
-    }
-    else {
-	int clen, tlen, max = RSTRING_BYTELEN(str) * 1.2;
-	int offset;
-	char *buf = ALLOC_N(char, max), *t = buf;
-	VALUE v;
-
-	if (cflag) tlen = rb_enc_codelen(last, enc);
-	while (s < send) {
-	    c = rb_enc_codepoint(s, send, enc);
-	    tlen = clen = rb_enc_codelen(c, enc);
-
-	    if (c < 256) {
-		v = trans[c] >= 0 ? trans[c] : Qnil;
-	    }
-	    else {
-		v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
-	    }
-	    if (!NIL_P(v)) {
-		if (!cflag) {
-		    c = NUM2INT(v);
-		    tlen = rb_enc_codelen(c, enc);
-		    modify = 1;
-		}
-		else {
-		    c = last;
-		    modify = 1;
-		}
-	    }
-	    while (t - buf + tlen >= max) {
-		offset = t - buf;
-		max *= 2;
-		REALLOC_N(buf, char, max);
-		t = buf + offset;
-	    }
-	    if (s != t) rb_enc_mbcput(c, t, enc);
-	    s += clen;
-	    t += tlen;
-	}
-	if (!STR_EMBED_P(str)) {
-	    xfree(RSTRING(str)->as.heap.ptr);
-	}
-	*t = '\0';
-	GC_WB(&RSTRING(str)->as.heap.ptr, buf);
-	RSTRING(str)->as.heap.len = t - buf;
-	STR_SET_NOEMBED(str);
-	RSTRING(str)->as.heap.aux.capa = max;
-    }
-    
-    if (modify) {
-#if !WITH_OBJC
-	rb_enc_associate(str, enc);
-#endif
-	return str;
-    }
-    return Qnil;
-#endif
 }
 
 /*
@@ -5785,84 +3324,6 @@
     return str;
 }
 
-#if !WITH_OBJC
-static void
-tr_setup_table(VALUE str, char stable[256], int first, 
-	       VALUE *tablep, VALUE *ctablep, rb_encoding *enc)
-{
-    char buf[256];
-    struct tr tr;
-    int c, l;
-    VALUE table = 0, ptable = 0;
-    int i, cflag = 0;
-
-    tr.p = RSTRING_BYTEPTR(str); tr.pend = tr.p + RSTRING_BYTELEN(str);
-    tr.gen = tr.now = tr.max = 0;
-    
-    if (RSTRING_BYTELEN(str) > 1 && rb_enc_ascget(tr.p, tr.pend, &l, enc) == '^') {
-	cflag = 1;
-	tr.p += l;
-    }
-    if (first) {
-	for (i=0; i<256; i++) {
-	    stable[i] = 1;
-	}
-    }
-    for (i=0; i<256; i++) {
-	buf[i] = cflag;
-    }
-
-    while ((c = trnext(&tr, enc)) >= 0) {
-	if (c < 256) {
-	    buf[c & 0xff] = !cflag;
-	}
-	else {
-	    VALUE key = INT2NUM(c);
-
-	    if (!table) {
-		table = rb_hash_new();
-		if (cflag) {
-		    ptable = *ctablep;
-		    *ctablep = table;
-		}
-		else {
-		    ptable = *tablep;
-		    *tablep = table;
-		}
-	    }
-	    if (!ptable || !NIL_P(rb_hash_aref(ptable, key))) {
-		rb_hash_aset(table, key, Qtrue);
-	    }
-	}
-    }
-    for (i=0; i<256; i++) {
-	stable[i] = stable[i] && buf[i];
-    }
-}
-
-
-static int
-tr_find(int c, char table[256], VALUE del, VALUE nodel)
-{
-    if (c < 256) {
-	return table[c] ? Qtrue : Qfalse;
-    }
-    else {
-	VALUE v = INT2NUM(c);
-
-	if (!del || NIL_P(rb_hash_lookup(del, v))) {
-	    return Qfalse;
-	}
-	if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
-	    return Qfalse;
-	return Qtrue;
-    }
-}
-
-#else
-
-#endif
-
 /*
  *  call-seq:
  *     str.delete!([other_str]+)   => str or nil
@@ -5871,7 +3332,6 @@
  *  <code>nil</code> if <i>str</i> was not modified.
  */
 
-#if WITH_OBJC
 static void
 rb_str_delete_bang_cb(CFRange *search_range, const CFRange *result_range, 
     CFStringRef str, UniChar character, void *ctx)
@@ -5882,12 +3342,10 @@
     search_range->location = result_range->location;
     *(bool *)ctx = true;
 }
-#endif
 
 static VALUE
 rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
 {
-#if WITH_OBJC
     bool changed;
     if (argc < 1)
 	rb_raise(rb_eArgError, "wrong number of arguments");
@@ -5898,50 +3356,6 @@
     if (!changed)
     	return Qnil;
     return str;
-#else
-    char squeez[256];
-    rb_encoding *enc = 0;
-    char *s, *send, *t;
-    VALUE del = 0, nodel = 0;
-    int modify = 0;
-    int i;
-    int cr = ENC_CODERANGE(str);
-
-    if (argc < 1) {
-	rb_raise(rb_eArgError, "wrong number of arguments");
-    }
-    for (i=0; i<argc; i++) {
-	VALUE s = argv[i];
-
-	StringValue(s);
-	enc = rb_enc_check(str, s);
-	tr_setup_table(s, squeez, i==0, &del, &nodel, enc);
-    }
-
-    rb_str_modify(str);
-    s = t = RSTRING_BYTEPTR(str);
-    if (!s || RSTRING_BYTELEN(str) == 0) return Qnil;
-    send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-	int clen = rb_enc_codelen(c, enc);
-
-	if (tr_find(c, squeez, del, nodel)) {
-	    modify = 1;
-	}
-	else {
-	    if (t != s) rb_enc_mbcput(c, t, enc);
-	    t += clen;
-	}
-	s += clen;
-    }
-    *t = '\0';
-    STR_SET_LEN(str, t - RSTRING_BYTEPTR(str));
-
-    ENC_CODERANGE_SET(str, cr);
-    if (modify) return str;
-    return Qnil;
-#endif
 }
 
 /*
@@ -5975,7 +3389,6 @@
  *  <code>nil</code> if no changes were made.
  */
 
-#if WITH_OBJC
 static void
 rb_str_squeeze_bang_cb(CFRange *search_range, const CFRange *result_range, 
     CFStringRef str, UniChar character, void *ctx)
@@ -5990,12 +3403,10 @@
 	*(bool *)ctx = true;
     }
 }
-#endif
 
 static VALUE
 rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
 {
-#if WITH_OBJC
     bool changed;
     VALUE all_chars;
     if (argc == 0) {
@@ -6010,52 +3421,6 @@
     if (!changed)
     	return Qnil;
     return str;
-#else
-    char squeez[256];
-    rb_encoding *enc = 0;
-    VALUE del = 0, nodel = 0;
-    char *s, *send, *t;
-    int save, modify = 0;
-    int i;
-
-    if (argc == 0) {
-	enc = STR_ENC_GET(str);
-    }
-    else {
-	for (i=0; i<argc; i++) {
-	    VALUE s = argv[i];
-
-	    StringValue(s);
-	    enc = rb_enc_check(str, s);
-	    tr_setup_table(s, squeez, i==0, &del, &nodel, enc);
-	}
-    }
-
-    rb_str_modify(str);
-    s = t = RSTRING_BYTEPTR(str);
-    if (!s || RSTRING_BYTELEN(str) == 0) return Qnil;
-    send = RSTRING_END(str);
-    save = -1;
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-	int clen = rb_enc_codelen(c, enc);
-
-	if (c != save || (argc > 0 && !tr_find(c, squeez, del, nodel))) {
-	    if (t != s) rb_enc_mbcput(c, t, enc);
-	    save = c;
-	    t += clen;
-	}
-	s += clen;
-    }
-    *t = '\0';
-    if (t - RSTRING_BYTEPTR(str) != RSTRING_BYTELEN(str)) {
-	STR_SET_LEN(str, t - RSTRING_BYTEPTR(str));
-	modify = 1;
-    }
-
-    if (modify) return str;
-    return Qnil;
-#endif
 }
 
 
@@ -6136,19 +3501,16 @@
  *     a.count "ej-m"          #=> 4
  */
 
-#if WITH_OBJC
 static void
 rb_str_count_cb(CFRange *search_range, const CFRange *result_range, 
     CFStringRef str, UniChar character, void *ctx)
 {
     (*(int *)ctx) += result_range->length;
 }
-#endif
 
 static VALUE
 rb_str_count(int argc, VALUE *argv, VALUE str)
 {
-#if WITH_OBJC
     int count;
     if (argc < 1)
 	rb_raise(rb_eArgError, "wrong number of arguments");
@@ -6156,42 +3518,8 @@
     str_charset_find((CFStringRef)str, argv, argc, false,
 	rb_str_count_cb, &count); 
     return INT2NUM(count);
-#else
-    char table[256];
-    rb_encoding *enc = 0;
-    VALUE del = 0, nodel = 0;
-    char *s, *send;
-    int i;
-
-    if (argc < 1) {
-	rb_raise(rb_eArgError, "wrong number of arguments");
-    }
-    for (i=0; i<argc; i++) {
-	VALUE s = argv[i];
-
-	StringValue(s);
-	enc = rb_enc_check(str, s);
-	tr_setup_table(s, table,i==0, &del, &nodel, enc);
-    }
-
-    s = RSTRING_BYTEPTR(str);
-    if (!s || RSTRING_BYTELEN(str) == 0) return INT2FIX(0);
-    send = RSTRING_END(str);
-    i = 0;
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-	int clen = rb_enc_codelen(c, enc);
-
-	if (tr_find(c, table, del, nodel)) {
-	    i++;
-	}
-	s += clen;
-    }
-    return INT2NUM(i);
-#endif
 }
 
-
 /*
  *  call-seq:
  *     str.split(pattern=$;, [limit])   => anArray
@@ -6247,9 +3575,6 @@
     VALUE result, tmp;
     long clen;
 
-#if !WITH_OBJC
-    cstr = RSTRING_PTR(str);
-#endif
     clen = RSTRING_LEN(str);
 
     if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) {
@@ -6275,35 +3600,11 @@
     else {
       fs_set:
 	if (TYPE(spat) == T_STRING) {
-#if WITH_OBJC
 	    spat_string = Qtrue;
 	    if (RSTRING_LEN(spat) == 1
 		&& CFStringGetCharacterAtIndex((CFStringRef)spat, 0) == ' ') {
 		awk_split = Qtrue;
 	    }
-#else
-	    const char *spat_cstr;
-	    long spat_clen;
-	    rb_encoding *enc2 = STR_ENC_GET(spat);
-
-	    spat_cstr = RSTRING_PTR(spat);
-	    spat_clen = RSTRING_LEN(spat);
-	    if (rb_enc_mbminlen(enc2) == 1) {
-		if (spat_clen == 1 && spat_cstr[0] == ' '){
-		    awk_split = Qtrue;
-		}
-	    }
-	    else {
-		int l;
-		if (rb_enc_ascget(spat_cstr, spat_cstr+spat_clen, &l, enc2) == ' ' &&
-		    spat_clen == l) {
-		    awk_split = Qtrue;
-		}
-	    }
-	    if (!awk_split) {
-		spat = rb_reg_regcomp(rb_reg_quote(spat));
-	    }
-#endif
 	}
 	else {
 	    spat = get_pat(spat, 1);
@@ -6311,7 +3612,6 @@
     }
 
     beg = 0;
-#if WITH_OBJC
     if (awk_split || spat_string) {
 	CFRange search_range;
 	CFCharacterSetRef charset = NULL;
@@ -6365,41 +3665,6 @@
 	}
 	while ((limit == Qnil || --lim > 1));
 	beg = search_range.location;
-#else
-    if (awk_split) {
-	const char *ptr = cstr;
-	const char *eptr = cstr+clen;
-	const char *bptr = ptr;
-	int skip = 1;
-	int c;
-
-	end = beg;
-	while (ptr < eptr) {
-	    c = rb_enc_codepoint(ptr, eptr, enc);
-	    ptr += rb_enc_mbclen(ptr, eptr, enc);
-	    if (skip) {
-		if (rb_enc_isspace(c, enc)) {
-		    beg = ptr - bptr;
-		}
-		else {
-		    end = ptr - bptr;
-		    skip = 0;
-		    if (!NIL_P(limit) && lim <= i) break;
-		}
-	    }
-	    else {
-		if (rb_enc_isspace(c, enc)) {
-		    rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
-		    skip = 1;
-		    beg = ptr - bptr;
-		    if (!NIL_P(limit)) ++i;
-		}
-		else {
-		    end = ptr - bptr;
-		}
-	    }
-	}
-#endif
     }
     else {
 	long start = beg;
@@ -6410,34 +3675,18 @@
 	while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
 	    regs = RMATCH_REGS(rb_backref_get());
 	    if (start == end && BEG(0) == END(0)) {
-#if WITH_OBJC
 		if (0) {
-#else
-		if (!cstr) {
-		    rb_ary_push(result, rb_str_new("", 0));
-#endif
 		    break;
 		}
 		else if (last_null == 1) {
-#if WITH_OBJC
 		    rb_ary_push(result, rb_str_subseq(str, beg, 1));
-#else
-		    rb_ary_push(result, rb_str_subseq(str, beg,
-						      rb_enc_mbclen(cstr+beg,
-								    cstr+clen,
-								    enc)));
-#endif
 		    beg = start;
 		}
 		else {
                     if (start == clen)
                         start++;
                     else
-#if WITH_OBJC
 			start += 1;
-#else
-                        start += rb_enc_mbclen(cstr+start,cstr+clen,enc);
-#endif
 		    last_null = 1;
 		    continue;
 		}
@@ -6543,7 +3792,6 @@
 static VALUE
 rb_str_each_line(int argc, VALUE *argv, VALUE str)
 {
-#if WITH_OBJC
     VALUE rs;
     long n;
     CFStringRef substr;
@@ -6608,98 +3856,8 @@
 #undef YIELD_SUBSTR
 
     return str;
-#else
-    rb_encoding *enc;
-    VALUE rs;
-    int newline;
-    char *p, *pend, *s, *ptr;
-    long len, rslen; 
-    VALUE line;
-    int n;
-
-    if (argc == 0) {
-	rs = rb_rs;
-    }
-    else {
-	rb_scan_args(argc, argv, "01", &rs);
-    }
-    RETURN_ENUMERATOR(str, argc, argv);
-    if (NIL_P(rs)) {
-	rb_yield(str);
-	return str;
-    }
-    str = rb_str_new4(str);
-    ptr = p = s = RSTRING_BYTEPTR(str);
-    pend = p + RSTRING_BYTELEN(str);
-    len = RSTRING_BYTELEN(str);
-    StringValue(rs);
-    if (rs == rb_default_rs) {
-	enc = rb_enc_get(str);
-	while (p < pend) {
-	    char *p0;
-
-	    p = memchr(p, '\n', pend - p);
-	    if (!p) break;
-	    p0 = rb_enc_left_char_head(s, p, enc);
-	    if (!rb_enc_is_newline(p0, pend, enc)) {
-		p++;
-		continue;
-	    }
-	    p = p0 + rb_enc_mbclen(p0, pend, enc);
-	    line = rb_str_new5(str, s, p - s);
-	    OBJ_INFECT(line, str);
-	    rb_enc_cr_str_copy_for_substr(line, str);
-	    rb_yield(line);
-	    str_mod_check(str, ptr, len);
-	    s = p;
-	}
-	goto finish;
-    }
-
-    enc = rb_enc_check(str, rs);
-    rslen = RSTRING_BYTELEN(rs);
-    if (rslen == 0) {
-	newline = '\n';
-    }
-    else {
-	newline = rb_enc_codepoint(RSTRING_BYTEPTR(rs), RSTRING_END(rs), enc);
-    }
-
-    while (p < pend) {
-	int c = rb_enc_codepoint(p, pend, enc);
-
-	n = rb_enc_codelen(c, enc);
-	if (rslen == 0 && c == newline) {
-	    while (p < pend && rb_enc_codepoint(p, pend, enc) == newline) {
-		p += n;
-	    }
-	    p -= n;
-	}
-	if (c == newline &&
-	    (rslen <= 1 || memcmp(RSTRING_BYTEPTR(rs), p, rslen) == 0)) {
-	    line = rb_str_new5(str, s, p - s + (rslen ? rslen : n));
-	    OBJ_INFECT(line, str);
-	    rb_enc_cr_str_copy_for_substr(line, str);
-	    rb_yield(line);
-	    str_mod_check(str, ptr, len);
-	    s = p + (rslen ? rslen : n);
-	}
-	p += n;
-    }
-
-  finish:
-    if (s != pend) {
-	line = rb_str_new5(str, s, pend - s);
-	OBJ_INFECT(line, str);
-	rb_enc_cr_str_copy_for_substr(line, str);
-	rb_yield(line);
-    }
-
-    return str;
-#endif
 }
 
-
 /*
  *  Document-method: bytes
  *  call-seq:
@@ -6772,7 +3930,6 @@
 static VALUE
 rb_str_each_char(VALUE str)
 {
-#if WITH_OBJC
     CFStringInlineBuffer buf;
     long i, n;
 
@@ -6789,44 +3946,8 @@
 	rb_yield(s);
     }
     return str;
-#else
-    int i, len, n;
-    const char *ptr;
-    rb_encoding *enc;
-
-    RETURN_ENUMERATOR(str, 0, 0);
-    str = rb_str_new4(str);
-    ptr = RSTRING_BYTEPTR(str);
-    len = RSTRING_BYTELEN(str);
-    enc = rb_enc_get(str);
-    for (i = 0; i < len; i += n) {
-	n = rb_enc_mbclen(ptr + i, ptr + len, enc);
-	rb_yield(rb_str_subseq(str, i, n));
-    }
-    return str;
-#endif
 }
 
-#if !WITH_OBJC
-static long
-chopped_length(VALUE str)
-{
-    rb_encoding *enc = STR_ENC_GET(str);
-    const char *p, *p2, *beg, *end;
-
-    beg = RSTRING_BYTEPTR(str);
-    end = beg + RSTRING_BYTELEN(str);
-    if (beg > end) return 0;
-    p = rb_enc_prev_char(beg, end, enc);
-    if (!p) return 0;
-    if (p > beg && rb_enc_codepoint(p, end, enc) == '\n') {
-	p2 = rb_enc_prev_char(beg, p, enc);
-	if (p2 && rb_enc_codepoint(p2, end, enc) == '\r') p = p2;
-    }
-    return p - beg;
-}
-#endif
-
 /*
  *  call-seq:
  *     str.chop!   => str or nil
@@ -6839,7 +3960,6 @@
 static VALUE
 rb_str_chop_bang(VALUE str)
 {
-#if WITH_OBJC
     long n;
     const char *p;
     CFRange r;
@@ -6859,17 +3979,6 @@
     }
     CFStringDelete((CFMutableStringRef)str, r);
     return str;
-#else
-    if (RSTRING_BYTELEN(str) > 0) {
-	long len;
-	rb_str_modify(str);
-	len = chopped_length(str);
-	STR_SET_LEN(str, len);
-	RSTRING_BYTEPTR(str)[len] = '\0';
-	return str;
-    }
-    return Qnil;
-#endif
 }
 
 
@@ -6893,16 +4002,9 @@
 static VALUE
 rb_str_chop(VALUE str)
 {
-#if WITH_OBJC
     VALUE str2 = rb_str_dup(str);
     rb_str_chop_bang(str2);
     return str2;
-#else
-    VALUE str2 = rb_str_new5(str, RSTRING_BYTEPTR(str), chopped_length(str));
-    rb_enc_cr_str_copy_for_substr(str2, str);
-    OBJ_INFECT(str2, str);
-    return str2;
-#endif
 }
 
 
@@ -6917,7 +4019,6 @@
 static VALUE
 rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
 {
-#if WITH_OBJC
     VALUE rs;
     long len, rslen;
     CFRange range_result;
@@ -6961,99 +4062,6 @@
 	return Qnil;
     CFStringDelete((CFMutableStringRef)str, range_result);
     return str;
-#else
-    rb_encoding *enc;
-    VALUE rs;
-    int newline;
-    char *p, *pp, *e;
-    long len, rslen;
-
-	len = RSTRING_BYTELEN(str);
-	if (len == 0) return Qnil;
-	p = RSTRING_BYTEPTR(str);
-    e = p + len;
-    if (argc == 0) {
-	rs = rb_rs;
-	if (rs == rb_default_rs) {
-	  smart_chomp:
-	    rb_str_modify(str);
-	    enc = rb_enc_get(str);
-	    if (rb_enc_mbminlen(enc) > 1) {
-		pp = rb_enc_left_char_head(p, e-rb_enc_mbminlen(enc), enc);
-		if (rb_enc_is_newline(pp, e, enc)) {
-		    e = pp;
-		}
-		pp = e - rb_enc_mbminlen(enc);
-		if (pp >= p) {
-		    pp = rb_enc_left_char_head(p, pp, enc);
-		    if (rb_enc_ascget(pp, e, 0, enc) == '\r') {
-			e = pp;
-		    }
-		}
-		if (e == RSTRING_END(str)) {
-		    return Qnil;
-		}
-		len = e - RSTRING_BYTEPTR(str);
-		STR_SET_LEN(str, len);
-	    }
-	    else {
-	    if (RSTRING_BYTEPTR(str)[len-1] == '\n') {
-		STR_DEC_LEN(str);
-		if (RSTRING_BYTELEN(str) > 0 &&
-		    RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)-1] == '\r') {
-		    STR_DEC_LEN(str);
-		}
-	    }
-	    else if (RSTRING_BYTEPTR(str)[len-1] == '\r') {
-		STR_DEC_LEN(str);
-	    }
-	    else {
-		return Qnil;
-	    }
-	    }
-	    RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-	    return str;
-	}
-    }
-    if (NIL_P(rs)) return Qnil;
-    StringValue(rs);
-    rslen = RSTRING_BYTELEN(rs);
-    if (rslen == 0) {
-	while (len>0 && p[len-1] == '\n') {
-	    len--;
-	    if (len>0 && p[len-1] == '\r')
-		len--;
-	}
-	if (len < RSTRING_BYTELEN(str)) {
-	    rb_str_modify(str);
-	    STR_SET_LEN(str, len);
-	    RSTRING_BYTEPTR(str)[len] = '\0';
-	    return str;
-	}
-	return Qnil;
-    }
-    if (rslen > len) return Qnil;
-    newline = RSTRING_BYTEPTR(rs)[rslen-1];
-    if (rslen == 1 && newline == '\n')
-	goto smart_chomp;
-
-    enc = rb_enc_check(str, rs);
-    if (is_broken_string(rs)) {
-	return Qnil;
-    }
-    pp = e - rslen;
-    if (p[len-1] == newline &&
-	(rslen <= 1 ||
-	 memcmp(RSTRING_BYTEPTR(rs), pp, rslen) == 0)) {
-	if (rb_enc_left_char_head(p, pp, enc) != pp)
-	    return Qnil;
-	rb_str_modify(str);
-	STR_SET_LEN(str, RSTRING_BYTELEN(str) - rslen);
-	RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-	return str;
-    }
-    return Qnil;
-#endif
 }
 
 
@@ -7096,7 +4104,6 @@
  *     "hello".lstrip!      #=> nil
  */
 
-#if WITH_OBJC
 static VALUE
 rb_str_strip_bang2(VALUE str, int direction)
 {
@@ -7140,39 +4147,11 @@
 
     return orig_n != n ? str : Qnil;
 }
-#endif
 
 static VALUE
 rb_str_lstrip_bang(VALUE str)
 {
-#if WITH_OBJC
     return rb_str_strip_bang2(str, -1);
-#else
-    rb_encoding *enc;
-    char *s, *t, *e;
-
-    rb_str_modify(str);
-    enc = STR_ENC_GET(str);
-    s = RSTRING_BYTEPTR(str);
-    if (!s || RSTRING_BYTELEN(str) == 0) return Qnil;
-    e = t = RSTRING_END(str);
-    /* remove spaces at head */
-    while (s < e) {
-	int cc = rb_enc_codepoint(s, e, enc);
-	
-	if (!rb_enc_isspace(cc, enc)) break;
-	s += rb_enc_codelen(cc, enc);
-    }
-
-    if (s > RSTRING_BYTEPTR(str)) {
-	rb_str_modify(str);
-	STR_SET_LEN(str, t-s);
-	memmove(RSTRING_BYTEPTR(str), s, RSTRING_BYTELEN(str));
-	RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-	return str;
-    }
-    return Qnil;
-#endif
 }
 
 
@@ -7211,39 +4190,7 @@
 static VALUE
 rb_str_rstrip_bang(VALUE str)
 {
-#if WITH_OBJC
     return rb_str_strip_bang2(str, 1);
-#else
-    rb_encoding *enc;
-    char *s, *t, *e;
-    int space_seen = Qfalse;
-
-    rb_str_modify(str);
-    enc = STR_ENC_GET(str);
-    s = RSTRING_BYTEPTR(str);
-    if (!s || RSTRING_BYTELEN(str) == 0) return Qnil;
-    t = e = RSTRING_END(str);
-    while (s < e) {
-	int cc = rb_enc_codepoint(s, e, enc);
-
-	if (!cc || rb_enc_isspace(cc, enc)) {
-	    if (!space_seen) t = s;
-	    space_seen = Qtrue;
-	}
-	else {
-	    space_seen = Qfalse;
-	}
-	s += rb_enc_codelen(cc, enc);
-    }
-    if (!space_seen) t = s;
-    if (t < e) {
-	rb_str_modify(str);
-	STR_SET_LEN(str, t-RSTRING_BYTEPTR(str));
-	RSTRING_BYTEPTR(str)[RSTRING_BYTELEN(str)] = '\0';
-	return str;
-    }
-    return Qnil;
-#endif
 }
 
 
@@ -7278,15 +4225,7 @@
 static VALUE
 rb_str_strip_bang(VALUE str)
 {
-#if WITH_OBJC
     return rb_str_strip_bang2(str, 0);
-#else
-    VALUE l = rb_str_lstrip_bang(str);
-    VALUE r = rb_str_rstrip_bang(str);
-
-    if (NIL_P(l) && NIL_P(r)) return Qnil;
-    return str;
-#endif
 }
 
 
@@ -7311,14 +4250,10 @@
 static VALUE
 scan_once(VALUE str, VALUE pat, long *start, long strlen, bool pat_is_string)
 {
-#if !WITH_OBJC
-    rb_encoding *enc;
-#endif
     VALUE result, match;
     struct re_registers *regs;
     long i;
 
-#if WITH_OBJC
     if (pat_is_string) {
 	/* XXX this is sometimes slower than the regexp search, especially for
 	 * long pattern strings 
@@ -7341,11 +4276,7 @@
 	}
 	return result;
     }
-#endif
 
-#if !WITH_OBJC
-    enc = STR_ENC_GET(str);
-#endif
     if (rb_reg_search(pat, str, *start, 0) >= 0) {
 	match = rb_backref_get();
 	regs = RMATCH_REGS(match);
@@ -7353,12 +4284,6 @@
 	    /*
 	     * Always consume at least one character of the input string
 	     */
-#if !WITH_OBJC
-	    if (RSTRING_BYTELEN(str) > END(0))
-		*start = END(0)+rb_enc_mbclen(RSTRING_BYTEPTR(str)+END(0),
-					      RSTRING_END(str), enc);
-	    else
-#endif
 		*start = END(0)+1;
 	}
 	else {
@@ -7436,9 +4361,6 @@
 	match = rb_backref_get();
 	rb_match_busy(match);
 	rb_yield(result);
-#if !WITH_OBJC
-	str_mod_check(str, p, len);
-#endif
 	rb_backref_set(match);	/* restore $~ value */
     }
     rb_backref_set(match);
@@ -7552,11 +4474,7 @@
 VALUE
 rb_str_intern(VALUE s)
 {
-#if WITH_OBJC
     VALUE str = s;
-#else
-    VALUE str = RB_GC_GUARD(s);
-#endif
     ID id;
 
     if (OBJ_TAINTED(str) && rb_safe_level() >= 1) {
@@ -7578,16 +4496,9 @@
 VALUE
 rb_str_ord(VALUE s)
 {
-#if WITH_OBJC
     if (CFStringGetLength((CFStringRef)s) == 0)
 	rb_raise(rb_eArgError, "empty string");
     return INT2NUM(CFStringGetCharacterAtIndex((CFStringRef)s, 0));
-#else
-    int c;
-
-    c = rb_enc_codepoint(RSTRING_BYTEPTR(s), RSTRING_END(s), STR_ENC_GET(s));
-    return INT2NUM(c);
-#endif
 }
 
 /*
@@ -7651,7 +4562,6 @@
     }
 }
 
-#if WITH_OBJC
 static inline void
 rb_str_justify0(VALUE str, VALUE pad, long width, long padwidth, long index)
 {
@@ -7668,12 +4578,10 @@
     }
     while (width > 0);
 }
-#endif
 
 static VALUE
 rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
 {
-#if WITH_OBJC
     VALUE w, pad;
     long n, width, padwidth;
 
@@ -7710,82 +4618,6 @@
     }
 
     return str;
-#else
-    rb_encoding *enc;
-    VALUE w;
-    long width, len, flen = 1, fclen = 1;
-    VALUE res;
-    char *p, *f = " ";
-    long n, llen, rlen;
-    volatile VALUE pad;
-    int singlebyte = 1;
-
-    rb_scan_args(argc, argv, "11", &w, &pad);
-    enc = STR_ENC_GET(str);
-    width = NUM2LONG(w);
-    if (argc == 2) {
-	StringValue(pad);
-	enc = rb_enc_check(str, pad);
-	f = RSTRING_BYTEPTR(pad);
-	flen = RSTRING_BYTELEN(pad);
-	fclen = str_strlen(pad, enc);
-	singlebyte = single_byte_optimizable(pad);
-	if (flen == 0 || fclen == 0) {
-	    rb_raise(rb_eArgError, "zero width padding");
-	}
-    }
-    len = str_strlen(str, enc);
-    if (width < 0 || len >= width) return rb_str_dup(str);
-    n = width - len;
-    llen = (jflag == 'l') ? 0 : ((jflag == 'r') ? n : n/2);
-    rlen = n - llen;
-    res = rb_str_new5(str, 0, RSTRING_BYTELEN(str)+n*flen/fclen+2);
-    p = RSTRING_BYTEPTR(res);
-    while (llen) {
-	if (flen <= 1) {
-	    *p++ = *f;
-	    llen--;
-	}
-	else if (llen > fclen) {
-	    memcpy(p,f,flen);
-	    p += flen;
-	    llen -= fclen;
-	}
-	else {
-	    char *fp = str_nth(f, f+flen, llen, enc, singlebyte);
-	    n = fp - f;
-	    memcpy(p,f,n);
-	    p+=n;
-	    break;
-	}
-    }
-    memcpy(p, RSTRING_BYTEPTR(str), RSTRING_BYTELEN(str));
-    p+=RSTRING_BYTELEN(str);
-    while (rlen) {
-	if (flen <= 1) {
-	    *p++ = *f;
-	    rlen--;
-	}
-	else if (rlen > fclen) {
-	    memcpy(p,f,flen);
-	    p += flen;
-	    rlen -= fclen;
-	}
-	else {
-	    char *fp = str_nth(f, f+flen, rlen, enc, singlebyte);
-	    n = fp - f;
-	    memcpy(p,f,n);
-	    p+=n;
-	    break;
-	}
-    }
-    *p = '\0';
-    STR_SET_LEN(res, p-RSTRING_BYTEPTR(res));
-    OBJ_INFECT(res, str);
-    if (!NIL_P(pad)) OBJ_INFECT(res, pad);
-    rb_enc_associate(res, enc);
-    return res;
-#endif
 }
 
 
@@ -7962,15 +4794,8 @@
     for (i=0; i<argc; i++) {
 	VALUE tmp = rb_check_string_type(argv[i]);
 	if (NIL_P(tmp)) continue;
-#if WITH_OBJC
 	if (CFStringHasPrefix((CFStringRef)str, (CFStringRef)tmp))
 	    return Qtrue;
-#else
-	rb_enc_check(str, tmp);
-	if (RSTRING_BYTELEN(str) < RSTRING_BYTELEN(tmp)) continue;
-	if (memcmp(RSTRING_BYTEPTR(str), RSTRING_BYTEPTR(tmp), RSTRING_BYTELEN(tmp)) == 0)
-	    return Qtrue;
-#endif
     }
     return Qfalse;
 }
@@ -7986,27 +4811,12 @@
 rb_str_end_with(int argc, VALUE *argv, VALUE str)
 {
     int i;
-#if !WITH_OBJC
-    char *p, *s;
-    rb_encoding *enc;
-#endif
 
     for (i=0; i<argc; i++) {
 	VALUE tmp = rb_check_string_type(argv[i]);
 	if (NIL_P(tmp)) continue;
-#if WITH_OBJC
 	if (CFStringHasSuffix((CFStringRef)str, (CFStringRef)tmp))
 	    return Qtrue;
-#else
-	enc = rb_enc_check(str, tmp);
-	if (RSTRING_BYTELEN(str) < RSTRING_BYTELEN(tmp)) continue;
-	p = RSTRING_BYTEPTR(str);
-	s = p + RSTRING_BYTELEN(str) - RSTRING_BYTELEN(tmp);
-	if (rb_enc_left_char_head(p, s, enc) != s)
-	    continue;
-	if (memcmp(s, RSTRING_BYTEPTR(tmp), RSTRING_BYTELEN(tmp)) == 0)
-	    return Qtrue;
-#endif
     }
     return Qfalse;
 }
@@ -8032,8 +4842,7 @@
 rb_str_force_encoding(VALUE str, VALUE enc)
 {
     str_modifiable(str);
-#if WITH_OBJC
-# if 0
+#if 0
     CFDataRef data = rb_str_cfdata2(str);
     if (data != NULL) {
 	CFStringRef substr;
@@ -8050,9 +4859,6 @@
 	    rb_str_cfdata_set(str, NULL);
 	}
     }
-# endif
-#else
-    rb_enc_associate(str, rb_to_encoding(enc));
 #endif
     return str;
 }
@@ -8071,13 +4877,7 @@
 static VALUE
 rb_str_valid_encoding_p(VALUE str)
 {
-#if WITH_OBJC
     rb_notimplement();
-#else
-    int cr = rb_enc_str_coderange(str);
-
-    return cr == ENC_CODERANGE_BROKEN ? Qfalse : Qtrue;
-#endif
 }
 
 /*
@@ -8093,16 +4893,9 @@
 static VALUE
 rb_str_is_ascii_only_p(VALUE str)
 {
-#if WITH_OBJC
     rb_notimplement();
-#else
-    int cr = rb_enc_str_coderange(str);
-
-    return cr == ENC_CODERANGE_7BIT ? Qtrue : Qfalse;
-#endif
 }
 
-#if WITH_OBJC
 static VALUE
 rb_str_transform_bang(VALUE str, VALUE transform_name)
 {
@@ -8131,8 +4924,6 @@
     return str;
 }
 
-#endif
-
 /**********************************************************************
  * Document-class: Symbol
  *
@@ -8196,7 +4987,6 @@
 static VALUE
 sym_inspect(VALUE sym)
 {
-#if WITH_OBJC
     VALUE str;
 
 #if 0
@@ -8207,27 +4997,6 @@
     str = rb_str_new2(":");
     rb_str_buf_append(str, sym);
     return str;
-#else
-    VALUE str, klass = Qundef;
-    ID id = SYM2ID(sym);
-    rb_encoding *enc;
-
-    sym = rb_id2str(id);
-    enc = STR_ENC_GET(sym);
-    str = rb_enc_str_new(0, RSTRING_BYTELEN(sym)+1, enc);
-    RSTRING_BYTEPTR(str)[0] = ':';
-    memcpy(RSTRING_BYTEPTR(str)+1, RSTRING_BYTEPTR(sym), RSTRING_BYTELEN(sym));
-    if (RSTRING_BYTELEN(sym) != strlen(RSTRING_BYTEPTR(sym)) ||
-	!rb_enc_symname_p(RSTRING_BYTEPTR(sym), enc)) {	
-	str = rb_str_inspect(str);
-	strncpy(RSTRING_BYTEPTR(str), ":\"", 2);
-    }
-    if (klass != Qundef) {
-	rb_str_cat2(str, "/");
-	rb_str_append(str, rb_inspect(klass));
-    }
-    return str;
-#endif
 }
 
 
@@ -8245,13 +5014,7 @@
 VALUE
 rb_sym_to_s(VALUE sym)
 {
-#if WITH_OBJC
     return str_new3(rb_cString, sym);
-#else
-    ID id = SYM2ID(sym);
-
-    return str_new3(rb_cString, rb_id2str(id));
-#endif
 }
 
 
@@ -8298,94 +5061,6 @@
     return rb_proc_new(sym_call, (VALUE)SYM2ID(sym));
 }
 
-
-#if !WITH_OBJC
-static VALUE
-sym_succ(VALUE sym)
-{
-    return rb_str_intern(rb_str_succ(rb_sym_to_s(sym)));
-}
-
-static VALUE
-sym_cmp(VALUE sym, VALUE other)
-{
-    if (!SYMBOL_P(other)) {
-	return Qnil;
-    }
-    return rb_str_cmp_m(rb_sym_to_s(sym), rb_sym_to_s(other));
-}
-
-static VALUE
-sym_casecmp(VALUE sym, VALUE other)
-{
-    if (!SYMBOL_P(other)) {
-	return Qnil;
-    }
-    return rb_str_casecmp(rb_sym_to_s(sym), rb_sym_to_s(other));
-}
-
-static VALUE
-sym_match(VALUE sym, VALUE other)
-{
-    return rb_str_match(rb_sym_to_s(sym), other);
-}
-
-static VALUE
-sym_eqq(VALUE sym, VALUE other)
-{
-    if (sym == other) return Qtrue;
-    return rb_str_equal(rb_sym_to_s(sym), other);
-}
-
-static VALUE
-sym_aref(int argc, VALUE *argv, VALUE sym)
-{
-    return rb_str_aref_m(argc, argv, rb_sym_to_s(sym));
-}
-
-static VALUE
-sym_length(VALUE sym)
-{
-    return rb_str_length(rb_id2str(SYM2ID(sym)));
-}
-
-static VALUE
-sym_empty(VALUE sym)
-{
-    return rb_str_empty(rb_id2str(SYM2ID(sym)));
-}
-
-static VALUE
-sym_upcase(VALUE sym)
-{
-    return rb_str_intern(rb_str_upcase(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_downcase(VALUE sym)
-{
-    return rb_str_intern(rb_str_downcase(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_capitalize(VALUE sym)
-{
-    return rb_str_intern(rb_str_capitalize(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_swapcase(VALUE sym)
-{
-    return rb_str_intern(rb_str_swapcase(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_encoding(VALUE sym)
-{
-    return rb_obj_encoding(rb_id2str(SYM2ID(sym)));
-}
-#endif
-
 ID
 rb_to_id(VALUE name)
 {
@@ -8410,8 +5085,6 @@
     return id;
 }
 
-#if WITH_OBJC
-
 #define PREPARE_RCV(x) \
     Class old = *(Class *)x; \
     *(Class *)x = (Class)rb_cCFString;
@@ -8571,7 +5244,6 @@
 }
 
 #undef INSTALL_METHOD
-#endif
 
 /*
  *  A <code>String</code> object holds and manipulates an arbitrary sequence of
@@ -8589,32 +5261,21 @@
 void
 Init_String(void)
 {
-#if WITH_OBJC
     rb_cCFString = (VALUE)objc_getClass("NSCFString");
     rb_cString = rb_cNSString = (VALUE)objc_getClass("NSString");
     rb_cNSMutableString = (VALUE)objc_getClass("NSMutableString");
     rb_const_set(rb_cObject, rb_intern("String"), rb_cNSMutableString);
     rb_set_class_path(rb_cNSMutableString, rb_cObject, "NSMutableString");
     rb_define_method(rb_cString, "__bytestring__?", rb_str_bytestring_m, 0);
-#else
-    rb_cString  = rb_define_class("String", rb_cObject);
-#endif
 
     rb_include_module(rb_cString, rb_mComparable);
 
-#if !WITH_OBJC
-    rb_define_alloc_func(rb_cString, str_alloc);
-#endif
     rb_define_singleton_method(rb_cString, "try_convert", rb_str_s_try_convert, 1);
     rb_define_method(rb_cString, "initialize", rb_str_init, -1);
     rb_define_method(rb_cString, "initialize_copy", rb_str_replace, 1);
     rb_define_method(rb_cString, "<=>", rb_str_cmp_m, 1);
     rb_define_method(rb_cString, "==", rb_str_equal, 1);
     rb_define_method(rb_cString, "eql?", rb_str_eql, 1);
-#if !WITH_OBJC
-    /* already in objc */
-    rb_define_method(rb_cString, "hash", rb_str_hash_m, 0);
-#endif
     rb_define_method(rb_cString, "casecmp", rb_str_casecmp, 1);
     rb_define_method(rb_cString, "+", rb_str_plus, 1);
     rb_define_method(rb_cString, "*", rb_str_times, 1);
@@ -8622,10 +5283,6 @@
     rb_define_method(rb_cString, "[]", rb_str_aref_m, -1);
     rb_define_method(rb_cString, "[]=", rb_str_aset_m, -1);
     rb_define_method(rb_cString, "insert", rb_str_insert, 2);
-#if !WITH_OBJC
-    /* already in objc */
-    rb_define_method(rb_cString, "length", rb_str_length, 0);
-#endif
     rb_define_method(rb_cString, "size", rb_str_length, 0);
     rb_define_method(rb_cString, "bytesize", rb_str_bytesize, 0);
     rb_define_method(rb_cString, "empty?", rb_str_empty, 0);
@@ -8730,14 +5387,12 @@
     rb_define_method(rb_cString, "valid_encoding?", rb_str_valid_encoding_p, 0);
     rb_define_method(rb_cString, "ascii_only?", rb_str_is_ascii_only_p, 0);
 
-#if WITH_OBJC
     rb_define_method(rb_cString, "transform", rb_str_transform, 1);
     rb_define_method(rb_cString, "transform!", rb_str_transform_bang, 1);
 
     /* to return mutable copies */
     rb_define_method(rb_cString, "dup", rb_str_dup, 0);
     rb_define_method(rb_cString, "clone", rb_str_clone, 0);
-#endif
 
     id_to_s = rb_intern("to_s");
 
@@ -8745,53 +5400,21 @@
     rb_define_variable("$;", &rb_fs);
     rb_define_variable("$-F", &rb_fs);
 
-#if WITH_OBJC // rb_cSymbol is defined in parse.y because it's needed early
+    /* rb_cSymbol is defined in parse.y because it's needed early */
     rb_set_class_path(rb_cSymbol, rb_cObject, "Symbol");
-#else
-    rb_cSymbol = rb_define_class("Symbol", rb_cObject);
-    rb_include_module(rb_cSymbol, rb_mComparable);
-#endif
     rb_undef_alloc_func(rb_cSymbol);
     rb_undef_method(CLASS_OF(rb_cSymbol), "new");
     rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in parse.y */
 
     rb_define_method(rb_cSymbol, "==", sym_equal, 1);
     rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
-#if WITH_OBJC
     rb_define_method(rb_cSymbol, "description", sym_inspect, 0);
     rb_define_method(rb_cSymbol, "dup", rb_obj_dup, 0);
-#endif
     rb_define_method(rb_cSymbol, "to_proc", sym_to_proc, 0);
     rb_define_method(rb_cSymbol, "to_s", rb_sym_to_s, 0);
     rb_define_method(rb_cSymbol, "id2name", rb_sym_to_s, 0);
     rb_define_method(rb_cSymbol, "intern", sym_to_sym, 0);
     rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
 
-#if !WITH_OBJC
-    rb_define_method(rb_cSymbol, "succ", sym_succ, 0);
-    rb_define_method(rb_cSymbol, "next", sym_succ, 0);
-
-    rb_define_method(rb_cSymbol, "<=>", sym_cmp, 1);
-    rb_define_method(rb_cSymbol, "casecmp", sym_casecmp, 1);
-    rb_define_method(rb_cSymbol, "=~", sym_match, 1);
-    rb_define_method(rb_cSymbol, "===", sym_eqq, 1);
-
-    rb_define_method(rb_cSymbol, "[]", sym_aref, -1);
-    rb_define_method(rb_cSymbol, "slice", sym_aref, -1);
-    rb_define_method(rb_cSymbol, "length", sym_length, 0);
-    rb_define_method(rb_cSymbol, "size", sym_length, 0);
-    rb_define_method(rb_cSymbol, "empty?", sym_empty, 0);
-    rb_define_method(rb_cSymbol, "match", sym_match, 1);
-
-    rb_define_method(rb_cSymbol, "upcase", sym_upcase, 0);
-    rb_define_method(rb_cSymbol, "downcase", sym_downcase, 0);
-    rb_define_method(rb_cSymbol, "capitalize", sym_capitalize, 0);
-    rb_define_method(rb_cSymbol, "swapcase", sym_swapcase, 0);
-
-    rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
-#endif
-
-#if WITH_OBJC
     install_symbol_primitives();
-#endif
-}
+}
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080815/8a74534e/attachment-0001.html 


More information about the macruby-changes mailing list