[#37248] [Feature:1.9] Enumerator#inspect — "Yusuke ENDOH" <mame@...>
遠藤です。
At Tue, 2 Dec 2008 23:59:52 +0900,
まつもと ゆきひろです
こんにちは、なかむら(う)です。
At Wed, 3 Dec 2008 18:39:59 +0900,
[#37265] [Feature #819] Caching Symbol#to_proc — Shumpei Akai <redmine@...>
Feature #819: Caching Symbol#to_proc
[#37275] [Bug #821] uninitialized constant Test::Unit::AutoRunner — Naohisa Goto <redmine@...>
Bug #821: uninitialized constant Test::Unit::AutoRunner
In article <4937d5c0586c_87b76ae0c6417f@redmine.ruby-lang.org>,
[#37278] invalid byte sequence by pack format 'A' or 'a' — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#37295] [BUG:trunk] Encoding in which Array#pack returns when the last format is 'u', 'M', 'm' — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
まつもと ゆきひろです
[#37337] [Feature #841] Object#self — "rubikitch ." <redmine@...>
Feature #841: Object#self
まつもと ゆきひろです
こんにちは、なかむら(う)です。
[#37357] Math and NaN — Tadayoshi Funaba <tadf@...>
Math.sin に NaN を与えてもそのまま NaN が返ってきますが、Math.sqrt はエ
まつもと ゆきひろです
> |Math.sin に NaN を与えてもそのまま NaN が返ってきますが、Math.sqrt はエ
[#37370] IA-64とx64でBigDecimalの割り算の計算結果がおかしい — TAKANO Mitsuhiro <tak@...32.tk>
-----BEGIN PGP SIGNED MESSAGE-----
[#37378] Ruby開発ミーティングログ — SASADA Koichi <ko1@...>
ささだです.
こんにちは、なかむら(う)です。
こんにちは、なかむら(う)です。
[#37384] [Bug #853] Rake のテストが無い — okkez _ <redmine@...>
Bug #853: Rake のテストが無い
[#37390] [BUG:trunk] r20625 dumps core and many strings associated with wrong encoding — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
Yugui (Yuki Sonoda) さんは書きました:
[#37392] [1.9:Feature] faster bignum multiplication by karatsuba method — "Yusuke ENDOH" <mame@...>
遠藤です。
[#37427] Re: [ruby-core:20448] [Bug #727] Signal(CLD) seems not to work on OS X — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#37455] Re: [ruby-cvs:27996] Ruby:r20778 (trunk): * common.mk (complex.$(OBJEXT), rational.$(OBJEXT)): Properly add — Nobuyoshi Nakada <nobu@...>
なかだです。
At Tue, 16 Dec 2008 15:14:40 +0900,
[#37458] [Bug #891] MiniTest::Assertions#assert_instance_of should use Object#instance_of? — okkez _ <redmine@...>
Bug #891: MiniTest::Assertions#assert_instance_of should use Object#instance_of?
[#37483] (was Re: [ruby-cvs:28066]) — "Akinori MUSHA" <knu@...>
At Wed, 17 Dec 2008 19:57:17 +0900 (JST),
(2008/12/17 20:25), Akinori MUSHA wrote:
At Thu, 18 Dec 2008 00:56:00 +0900,
[#37490] minitest/spec, minitest/mock を標準添付から外しませんか? — okkez <okkez000@...>
okkez です。
[#37496] when to use default_internal — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#37505] Re: [ruby-cvs:28084] Ruby:r20866 (trunk): * error.c (exc_equal): duck typing equal to make it transitive. — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#37513] Current status of 1.9.1 RC1's issues — "Yugui (Yuki Sonoda)" <yugui@...>
Hi, folks
咳といいます。
Yuguiです
咳といいます。
On 12/21/08 11:22 PM, Masatoshi SEKI wrote:
咳といいます。
Yuguiです。
Yuguiです。
[#37525] [Bug #914] Integer#upto(NaN) — tadayoshi funaba <redmine@...>
Bug #914: Integer#upto(NaN)
[#37537] [Bug #913] mathn した場合、sqrt(NaN) が複素数になる — Yuki Sonoda <redmine@...>
チケット #913 が更新されました。 (by Yuki Sonoda)
[#37555] [Bug #919] tool/file2lastrev.rbでエラー — Tadashi Saito <redmine@...>
Bug #919: tool/file2lastrev.rbでエラー
[#37560] fail to complie ext pty in cygwin — Masaki Suketa <masaki.suketa@...>
助田です。
[#37572] [Bug:1.9] `initialize_copy': wrong argument type #<Class:0x825d23c> (expected Data) (TypeError) — Tanaka Akira <akr@...>
以下のプログラムで、
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
[#37576] [BUG:trunk] encoding for stdio's — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#37591] [BUG:trunk] [m17n] TestCSVFeatures fails because of r20905 — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#37646] [Bug #943] Segmentation fault (cygwin) — Martin Dürst <redmine@...>
Bug #943: Segmentation fault (cygwin)
[ruby-dev:37247] [Backport #809] String#ord and String#[gs]etbyte for 1.8
Backport #809: String#ord and String#[gs]etbyte for 1.8
http://redmine.ruby-lang.org/issues/show/809
起票者: Shinichiro Hamaji
ステータス: Open, 優先度: Normal
Ruby1.9 でコードを書いている時に、 1.8 でも動くようにしとくかなぁ…
と思う時に最も困るのが個人的には String#[] の挙動の変化なのですが、
1.9 の ord, getbyte, setbyte を backport しておくわけにはいけないもんでしょうか。
Index: string.c
===================================================================
--- string.c (revision 20448)
+++ string.c (working copy)
@@ -2473,6 +2473,51 @@
/*
* call-seq:
+ * str.getbyte(index) => 0 .. 255
+ *
+ * returns the <i>index</i>th byte as an integer.
+ */
+static VALUE
+rb_str_getbyte(VALUE str, VALUE index)
+{
+ long pos = NUM2LONG(index);
+
+ if (pos < 0)
+ pos += RSTRING_LEN(str);
+ if (pos < 0 || RSTRING_LEN(str) <= pos)
+ return Qnil;
+
+ return INT2FIX((unsigned char)RSTRING_PTR(str)[pos]);
+}
+
+
+/*
+ * call-seq:
+ * str.setbyte(index, int) => int
+ *
+ * modifies the <i>index</i>th byte as <i>int</i>.
+ */
+static VALUE
+rb_str_setbyte(VALUE str, VALUE index, VALUE value)
+{
+ long pos = NUM2LONG(index);
+ int byte = NUM2INT(value);
+
+ rb_str_modify(str);
+
+ if (pos < -RSTRING_LEN(str) || RSTRING_LEN(str) <= pos)
+ rb_raise(rb_eIndexError, "index %ld out of string", pos);
+ if (pos < 0)
+ pos += RSTRING_LEN(str);
+
+ RSTRING_PTR(str)[pos] = byte;
+
+ return value;
+}
+
+
+/*
+ * call-seq:
* str.reverse => new_str
*
* Returns a new string with the characters from <i>str</i> in reverse order.
@@ -4556,6 +4601,24 @@
/*
* call-seq:
+ * str.ord => integer
+ *
+ * Return the <code>Integer</code> ordinal of a one-character string.
+ *
+ * "a".ord #=> 97
+ */
+
+VALUE
+rb_str_ord(VALUE s)
+{
+ if (RSTRING_LEN(s) <= 0)
+ rb_raise(rb_eArgError, "empty string");
+ return INT2FIX(*RSTRING_PTR(s) & 0xff);
+}
+
+
+/*
+ * call-seq:
* str.sum(n=16) => integer
*
* Returns a basic <em>n</em>-bit checksum of the characters in <i>str</i>,
@@ -4959,6 +5022,8 @@
rb_define_method(rb_cString, "index", rb_str_index_m, -1);
rb_define_method(rb_cString, "rindex", rb_str_rindex_m, -1);
rb_define_method(rb_cString, "replace", rb_str_replace, 1);
+ rb_define_method(rb_cString, "getbyte", rb_str_getbyte, 1);
+ rb_define_method(rb_cString, "setbyte", rb_str_setbyte, 2);
rb_define_method(rb_cString, "to_i", rb_str_to_i, -1);
rb_define_method(rb_cString, "to_f", rb_str_to_f, 0);
@@ -4987,6 +5052,7 @@
rb_define_method(rb_cString, "crypt", rb_str_crypt, 1);
rb_define_method(rb_cString, "intern", rb_str_intern, 0);
rb_define_method(rb_cString, "to_sym", rb_str_intern, 0);
+ rb_define_method(rb_cString, "ord", rb_str_ord, 0);
rb_define_method(rb_cString, "include?", rb_str_include, 1);
rb_define_method(rb_cString, "start_with?", rb_str_start_with, -1);
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb (revision 20448)
+++ test/ruby/test_string.rb (working copy)
@@ -77,4 +77,28 @@
assert_equal("aaaaaaaaaaaa", "zzzzzzzzzzz".succ!)
assert_equal("aaaaaaaaaaaaaaaaaaaaaaaa", "zzzzzzzzzzzzzzzzzzzzzzz".succ!)
end
+
+ def test_getbyte
+ assert_equal(0x82, "\xE3\x81\x82\xE3\x81\x84".getbyte(2))
+ assert_equal(0x82, "\xE3\x81\x82\xE3\x81\x84".getbyte(-4))
+ assert_nil("\xE3\x81\x82\xE3\x81\x84".getbyte(100))
+ end
+
+ def test_setbyte
+ s = "\xE3\x81\x82\xE3\x81\x84"
+ s.setbyte(2, 0x84)
+ assert_equal("\xE3\x81\x84\xE3\x81\x84", s)
+
+ s = "\xE3\x81\x82\xE3\x81\x84"
+ assert_raise(IndexError) { s.setbyte(100, 0) }
+
+ s = "\xE3\x81\x82\xE3\x81\x84"
+ s.setbyte(-4, 0x84)
+ assert_equal("\xE3\x81\x84\xE3\x81\x84", s)
+ end
+
+ def test_ord
+ assert_equal(0xe3, "\xE3\x81\x82\xE3\x81\x84".ord)
+ assert_raise(ArgumentError) { "".ord }
+ end
end
----------------------------------------
http://redmine.ruby-lang.org