[macruby-changes] [571] MacRuby/branches/testing

source_changes at macosforge.org source_changes at macosforge.org
Sun Sep 7 16:47:55 PDT 2008


Revision: 571
          http://trac.macosforge.org/projects/ruby/changeset/571
Author:   lsansonetti at apple.com
Date:     2008-09-07 16:47:55 -0700 (Sun, 07 Sep 2008)
Log Message:
-----------
merging regression fixes from trunk

Modified Paths:
--------------
    MacRuby/branches/testing/hash.c
    MacRuby/branches/testing/string.c

Modified: MacRuby/branches/testing/hash.c
===================================================================
--- 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
===================================================================
--- 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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080907/48be116c/attachment.html 


More information about the macruby-changes mailing list