[macruby-changes] [3708] MacRuby/branches/icu/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 5 15:26:43 PST 2010
Revision: 3708
http://trac.macosforge.org/projects/ruby/changeset/3708
Author: lsansonetti at apple.com
Date: 2010-03-05 15:26:42 -0800 (Fri, 05 Mar 2010)
Log Message:
-----------
fixed str_compare when one of the strings cannot go uchars, added #hash
Modified Paths:
--------------
MacRuby/branches/icu/string.c
Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c 2010-03-05 23:25:44 UTC (rev 3707)
+++ MacRuby/branches/icu/string.c 2010-03-05 23:26:42 UTC (rev 3708)
@@ -863,15 +863,7 @@
return -1;
}
- if (str_is_stored_in_uchars(self) != str_is_stored_in_uchars(str)) {
- // one is in uchars and the other is in binary
- if (!str_try_making_data_uchars(self)
- || !str_try_making_data_uchars(str)) {
- // one is in uchars but the other one can't be converted in
- // uchars
- return -1;
- }
- }
+ str_make_same_format(self, str);
const long min_len = self->length_in_bytes < str->length_in_bytes
? self->length_in_bytes : str->length_in_bytes;
@@ -905,16 +897,7 @@
return -1;
}
- if (str_is_stored_in_uchars(self)
- != str_is_stored_in_uchars(str)) {
- // one is in uchars and the other is in binary
- if (!str_try_making_data_uchars(self)
- || !str_try_making_data_uchars(str)) {
- // one is in uchars but the other one can't be converted in
- // uchars
- return -1;
- }
- }
+ str_make_same_format(self, str);
const long min_length = self->length_in_bytes < str->length_in_bytes
? self->length_in_bytes : str->length_in_bytes;
@@ -4816,6 +4799,19 @@
return rb_int2inum(sum);
}
+/*
+ * call-seq:
+ * str.hash => fixnum
+ *
+ * Return a hash based on the string's length and content.
+ */
+
+static VALUE
+rstr_hash(VALUE str, SEL sel)
+{
+ return LONG2NUM(rb_str_hash(str));
+}
+
// NSString primitives.
static void
@@ -4994,6 +4990,7 @@
rb_objc_define_method(rb_cRubyString, "squeeze", rstr_squeeze, -1);
rb_objc_define_method(rb_cRubyString, "squeeze!", rstr_squeeze_bang, -1);
rb_objc_define_method(rb_cRubyString, "sum", rstr_sum, -1);
+ rb_objc_define_method(rb_cRubyString, "hash", rstr_hash, 0);
// MacRuby extensions.
rb_objc_define_method(rb_cRubyString, "transform", rstr_transform, 1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100305/edbc2b96/attachment.html>
More information about the macruby-changes
mailing list