[#24698] NKF(nkf2)を1.8ブランチに入れました — "NARUSE, Yui" <naruse@...>

naruseです。

14 messages 2004/11/03
[#24734] Re: NKF(nkf2)を1.8ブランチに入れました — 堀川 久 <vzw00011@...> 2004/11/06

こんにちは。

[#24720] メール関係ライブラリの標準添付について — MoonWolf <moonwolf@...>

MoonWolfです。

17 messages 2004/11/05
[#24721] Re: メール関係ライブラリの標準添付について — Yukihiro Matsumoto <matz@...> 2004/11/05

まつもと ゆきひろです

[#24722] Re: メール関係ライブラリの標準添付について — MoonWolf <moonwolf@...> 2004/11/05

MoonWolfです。

[#24804] Re: まつもとさんの負担を減らすために、何ができるだろう — "URABE Shyouhei aka.mput" <root@...>

mput です。 ruby-dev に移動します。

21 messages 2004/11/13
[#24805] Re: まつもとさんの負担を減らすために、何ができるだろう — Tanaka Akira <akr@...17n.org> 2004/11/13

In article <2D6284E3-351D-11D9-B7EF-000393735AAE@mput.dip.jp>,

[#24806] Re: まつもとさんの負担を減らすために、何ができるだろう — "URABE Shyouhei aka.mput" <root@...> 2004/11/13

mput です。

[#24808] Re: まつもとさんの負担を減らすために、何ができるだろう — Masayoshi Takahashi <maki@...> 2004/11/13

高橋征義です。

[#24809] Re: まつもとさんの負担を減らすために、何ができるだろう — "URABE Shyouhei aka.mput" <root@...> 2004/11/13

mput です。

[#24834] Process.getrlimit and Process.setrlimit — Tanaka Akira <akr@...17n.org>

Process.getrlimit と Process.setrlimit が欲しいので実装してみました。

25 messages 2004/11/13

[#24965] sync and stdio buffering — Tanaka Akira <akr@...17n.org>

ちょっとした思いつきなのですが、

12 messages 2004/11/26

[#24993] rb_io_sysread dumps core [BUG] rb_sys_fail() - errno == 0 — Tietew <tietew-ml-ruby-dev@...>

ソケットとスレッドを大量に使うアプリ(具体的には IRCbot です)を

13 messages 2004/11/29

[#25003] IO#flush dumps core again — Tanaka Akira <akr@...17n.org>

次のようにすると core を吐きます。

28 messages 2004/11/30
[#25004] Re: IO#flush dumps core again — nobu@... 2004/11/30

なかだです。

[#25005] Re: IO#flush dumps core again — Yukihiro Matsumoto <matz@...> 2004/11/30

まつもと ゆきひろです

[#25009] Re: IO#flush dumps core again — Tanaka Akira <akr@...17n.org> 2004/12/01

In article <1101836040.635395.27476.nullmailer@x31.priv.netlab.jp>,

[#25014] Re: IO#flush dumps core again — Tanaka Akira <akr@...17n.org> 2004/12/01

In article <1101878558.979715.1359.nullmailer@x31.priv.netlab.jp>,

[#25015] Re: IO#flush dumps core again — Yukihiro Matsumoto <matz@...> 2004/12/01

まつもと ゆきひろです

[#25056] Re: IO#flush dumps core again — Tanaka Akira <akr@...17n.org> 2004/12/05

In article <1101888165.570792.4192.nullmailer@x31.priv.netlab.jp>,

[#25074] Re: IO#flush dumps core again — Tanaka Akira <akr@...17n.org> 2004/12/06

In article <1102293033.356112.2288.nullmailer@x31.priv.netlab.jp>,

[ruby-dev:24915] String#upcase bug

From: Kazuhiro NISHIYAMA <zn@...>
Date: 2004-11-18 09:55:53 UTC
List: ruby-dev #24915
西山和広です。

String#upcaseが元の文字列を変更してしまうようです。


% ruby18 -ve 's="hoge";s.upcase;p s'
ruby 1.8.2 (2004-11-18) [i686-linux]
"HOGE"
% ruby18 -ve 's="hoge";s.freeze.upcase;p s'
ruby 1.8.2 (2004-11-18) [i686-linux]
"HOGE"
% ruby18 -ve 's="hoge";s.freeze.upcase!;p s'
ruby 1.8.2 (2004-11-18) [i686-linux]
"HOGE"
%

Index: ChangeLog
===================================================================
RCS file: /src/ruby/ChangeLog,v
retrieving revision 1.2673.2.619
diff -u -p -r1.2673.2.619 ChangeLog
--- ChangeLog	18 Nov 2004 03:47:14 -0000	1.2673.2.619
+++ ChangeLog	18 Nov 2004 09:47:25 -0000
@@ -1,3 +1,10 @@
+Thu Nov 18 18:41:08 2004  Kazuhiro NISHIYAMA  <zn@mbf.nifty.com>
+
+	* test/ruby/test_stringchar.rb (test_bang): added.
+
+	* string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
+	(rb_str_swapcase_bang): missing rb_str_modify().
+
 Thu Nov 18 00:21:15 2004  Yukihiro Matsumoto  <matz@ruby-lang.org>
 
 	* process.c (proc_getpgrp): prohibit for $SAFE=2.
Index: string.c
===================================================================
RCS file: /src/ruby/string.c,v
retrieving revision 1.182.2.29
diff -u -p -r1.182.2.29 string.c
--- string.c	18 Nov 2004 03:47:13 -0000	1.182.2.29
+++ string.c	18 Nov 2004 09:47:25 -0000
@@ -2725,6 +2725,7 @@ rb_str_upcase_bang(str)
     char *s, *send;
     int modify = 0;
 
+    rb_str_modify(str);
     s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
     while (s < send) {
 	if (ismbchar(*s)) {
@@ -2838,6 +2839,7 @@ rb_str_capitalize_bang(str)
     char *s, *send;
     int modify = 0;
 
+    rb_str_modify(str);
     if (RSTRING(str)->len == 0 || !RSTRING(str)->ptr) return Qnil;
     s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
     if (ISLOWER(*s)) {
@@ -2895,6 +2897,7 @@ rb_str_swapcase_bang(str)
     char *s, *send;
     int modify = 0;
 
+    rb_str_modify(str);
     s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
     while (s < send) {
 	if (ismbchar(*s)) {
Index: test/ruby/test_stringchar.rb
===================================================================
RCS file: /src/ruby/test/ruby/test_stringchar.rb,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 test_stringchar.rb
--- test/ruby/test_stringchar.rb	18 Feb 2004 13:21:10 -0000	1.4.2.1
+++ test/ruby/test_stringchar.rb	18 Nov 2004 09:47:36 -0000
@@ -113,4 +113,54 @@ EOS
     }
     assert_equal(0, a.size)
   end
+
+  def test_bang
+    s = "aBc"
+    s.upcase
+    assert_equal("aBc", s)
+    s.upcase!
+    assert_equal("ABC", s)
+
+    s = "aBc"
+    s.downcase
+    assert_equal("aBc", s)
+    s.downcase!
+    assert_equal("abc", s)
+
+    s = "aBc"
+    s.swapcase
+    assert_equal("aBc", s)
+    s.swapcase!
+    assert_equal("AbC", s)
+
+    s = "aBc"
+    s.capitalize
+    assert_equal("aBc", s)
+    s.capitalize!
+    assert_equal("Abc", s)
+
+    s = "aBc"
+    s.tr("a-z", "A-Z")
+    assert_equal("aBc", s)
+    s.tr!("a-z", "A-Z")
+    assert_equal("ABC", s)
+
+    s = "aaBBcc"
+    s.tr_s("a-z", "A-Z")
+    assert_equal("aaBBcc", s)
+    s.tr_s!("a-z", "A-Z")
+    assert_equal("ABBC", s)
+
+    s = "aaBBcc"
+    s.squeeze("a-z")
+    assert_equal("aaBBcc", s)
+    s.squeeze!("a-z")
+    assert_equal("aBBc", s)
+
+    s = "aaBBcc"
+    s.delete("a-z")
+    assert_equal("aaBBcc", s)
+    s.delete!("a-z")
+    assert_equal("BB", s)
+  end
 end


-- 
|ZnZ(ゼット エヌ ゼット)
|西山和広(Kazuhiro NISHIYAMA)


In This Thread

Prev Next