Revision
571
Author
lsansonetti@apple.com
Date
2008-09-07 16:47:55 -0700 (Sun, 07 Sep 2008)

Log Message

merging regression fixes from trunk

Modified Paths

Diff

Modified: MacRuby/branches/testing/hash.c (570 => 571)


--- MacRuby/branches/testing/hash.c	2008-09-07 23:42:34 UTC (rev 570)
+++ MacRuby/branches/testing/hash.c	2008-09-07 23:47:55 UTC (rev 571)
@@ -37,7 +37,13 @@
 VALUE
 rb_hash(VALUE obj)
 {
-    return rb_funcall(obj, id_hash, 0);
+    VALUE v = rb_funcall(obj, id_hash, 0);
+    if (TYPE(v) == T_BIGNUM) {
+	unsigned long l = NUM2ULONG(v);
+	l /= 2.0;
+	v = ULONG2NUM(l);
+    }
+    return v;
 }
 
 typedef int st_foreach_func(st_data_t, st_data_t, st_data_t);

Modified: MacRuby/branches/testing/string.c (570 => 571)


--- MacRuby/branches/testing/string.c	2008-09-07 23:42:34 UTC (rev 570)
+++ MacRuby/branches/testing/string.c	2008-09-07 23:47:55 UTC (rev 571)
@@ -4984,7 +4984,23 @@
     return Qfalse;
 }
 
+static VALUE
+sym_cmp(VALUE sym1, VALUE sym2)
+{
+    int code;
 
+    if (CLASS_OF(sym2) != rb_cSymbol)
+	return Qnil;
+    code = strcmp(RSYMBOL(sym1)->str, RSYMBOL(sym2)->str);
+    if (code > 0) {
+	code = 1;
+    }
+    else if (code < 0) {
+	code = -1;
+    }
+    return INT2FIX(code);
+}
+
 /*
  *  call-seq:
  *     sym.inspect    => string
@@ -5411,6 +5427,7 @@
     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, "<=>", sym_cmp, 1);
     rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
     rb_define_method(rb_cSymbol, "description", sym_inspect, 0);
     rb_define_method(rb_cSymbol, "dup", rb_obj_dup, 0);