[macruby-changes] [4951] MacRuby/trunk/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 26 09:01:15 PST 2010
Revision: 4951
http://trac.macosforge.org/projects/ruby/changeset/4951
Author: watson1978 at gmail.com
Date: 2010-11-26 09:01:12 -0800 (Fri, 26 Nov 2010)
Log Message:
-----------
fixed the bug of String#setbyte.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
str = "a"
assert_equal(98, str.setbyte(0, 98))
assert_equal("b", str)
assert_raise(TypeError){ str.setbyte(0, "c") }
puts :ok
}}}
Modified Paths:
--------------
MacRuby/trunk/string.c
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2010-11-26 14:17:25 UTC (rev 4950)
+++ MacRuby/trunk/string.c 2010-11-26 17:01:12 UTC (rev 4951)
@@ -1768,6 +1768,7 @@
str_make_data_binary(RSTR(self));
long index = NUM2LONG(idx);
+ int byte = NUM2INT(value);
if ((index < -RSTR(self)->length_in_bytes)
|| (index >= RSTR(self)->length_in_bytes)) {
rb_raise(rb_eIndexError, "index %ld out of string", index);
@@ -1775,7 +1776,7 @@
if (index < 0) {
index += RSTR(self)->length_in_bytes;
}
- RSTR(self)->data.bytes[index] = value;
+ RSTR(self)->data.bytes[index] = byte;
return value;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101126/b91fb8b6/attachment.html>
More information about the macruby-changes
mailing list