[macruby-changes] [4035] MacRuby/trunk/NSString.m
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 6 16:26:38 PDT 2010
Revision: 4035
http://trac.macosforge.org/projects/ruby/changeset/4035
Author: lsansonetti at apple.com
Date: 2010-05-06 16:26:37 -0700 (Thu, 06 May 2010)
Log Message:
-----------
fix a bug in NSString#== where an exception would occur if the operand cannot be converted as a string
Modified Paths:
--------------
MacRuby/trunk/NSString.m
Modified: MacRuby/trunk/NSString.m
===================================================================
--- MacRuby/trunk/NSString.m 2010-05-06 23:00:56 UTC (rev 4034)
+++ MacRuby/trunk/NSString.m 2010-05-06 23:26:37 UTC (rev 4035)
@@ -135,6 +135,15 @@
static VALUE
nsstr_equal(id rcv, SEL sel, VALUE other)
{
+ if (rcv == (id)other) {
+ return Qtrue;
+ }
+ if (TYPE(other) != T_STRING) {
+ if (!rb_respond_to(other, rb_intern("to_str"))) {
+ return Qfalse;
+ }
+ return rb_equal(other, (VALUE)rcv);
+ }
return [rcv isEqualToString:(id)to_str(other)] ? Qtrue : Qfalse;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100506/20a5ddce/attachment.html>
More information about the macruby-changes
mailing list