[#615] [MethodIndex] <!-- hhmts ... — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

13 messages 1997/10/01

[#645] pack/unpack base64 — WATANABE Hirofumi <watanabe@...>

わたなべです.

18 messages 1997/10/06

[#654] [BUG?] ruby -r nothing-file — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

29 messages 1997/10/06
[#661] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#662] Re: [BUG?] ruby -r nothing-file — WATANABE Hirofumi <watanabe@...> 1997/10/07

わたなべです.

[#663] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#666] Re: [BUG?] ruby -r nothing-file — keiju@... (石塚圭樹 ) 1997/10/07

けいじゅ@日本ラショナルソフトウェアです.

[#667] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#669] Re: [BUG?] ruby -r nothing-file — keiju@... (石塚圭樹 ) 1997/10/07

けいじゅ@日本ラショナルソフトウェアです.

[#670] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#671] Re: [BUG?] ruby -r nothing-file — keiju@... (石塚圭樹 ) 1997/10/07

けいじゅ@日本ラショナルソフトウェアです.

[#672] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#673] Re: [BUG?] ruby -r nothing-file — WATANABE Hirofumi <watanabe@...> 1997/10/07

わたなべです.

[#674] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#675] Re: [BUG?] ruby -r nothing-file — WATANABE Hirofumi <watanabe@...> 1997/10/07

わたなべです.

[#676] Re: [BUG?] ruby -r nothing-file — keiju@... (石塚圭樹 ) 1997/10/07

けいじゅ@日本ラショナルソフトウェアです.

[#677] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#678] Re: [BUG?] ruby -r nothing-file — keiju@... (石塚圭樹 ) 1997/10/07

けいじゅ@日本ラショナルソフトウェアです.

[#679] Re: [BUG?] ruby -r nothing-file — matz@... (Yukihiro Matsumoto) 1997/10/07

まつもと ゆきひろです

[#770] printn means print and newline — HYOUDOU Kouichi /note <hyoudo@...>

兵藤です%思い付きなのですが

19 messages 1997/10/28
[#771] Re: printn means print and newline — shugo@... (Shugo Maeda) 1997/10/28

前田です。

[ruby-dev:777] [BUG] p "".chop

From: WATANABE Hirofumi <watanabe@...>
Date: 1997-10-30 07:06:52 UTC
List: ruby-dev #777
わたなべです.

p "".chop が SEGV です.

で, ついでにそういう println がありなら chomp もあってもいい
かなと思うんだけど, だめなら @@ -1948,2 +1950,39 @@ 以降を削
除してください.

Kconv#nkf もそのうち作ります. ;-)

-- 
わたなべひろふみ

--- string.c.orig	Wed Sep 24 18:16:08 1997
+++ string.c	Thu Oct 30 16:03:14 1997
@@ -1916,9 +1916,11 @@
 
-    str->len--;
-    if (str->ptr[str->len] == '\n') {
-	if (str->len > 0 && str->ptr[str->len-1] == '\r') {
-	    str->len--;
+    if (str->len > 0) {
+	str->len--;
+	if (str->ptr[str->len] == '\n') {
+	    if (str->len > 0 && str->ptr[str->len-1] == '\r') {
+		str->len--;
+	    }
 	}
+	str->ptr[str->len] = '\0';
     }
-    str->ptr[str->len] = '\0';
 
@@ -1948,2 +1950,39 @@
 static VALUE
+str_chomp_bang(str)
+    struct RString *str;
+{
+    str_modify(str);
+
+    if (str->len > 0 && str->ptr[str->len-1] == '\n') {
+	str->len--;
+	if (str->len > 0 && str->ptr[str->len-1] == '\r') {
+	    str->len--;
+	}
+	str->ptr[str->len] = '\0';
+    }
+
+    return (VALUE)str;
+}
+
+static VALUE
+str_chomp(str)
+    struct RString *str;
+{
+    return str_chomp_bang(str_dup(str));
+}
+
+static VALUE
+f_chomp_bang(str)
+    struct RString *str;
+{
+    return str_chomp_bang(uscore_get());
+}
+
+static VALUE
+f_chomp()
+{
+    return str_chomp_bang(str_dup(uscore_get()));
+}
+
+static VALUE
 str_strip_bang(str)
@@ -2264,2 +2303,3 @@
     rb_define_method(cString, "chop", str_chop, 0);
+    rb_define_method(cString, "chomp", str_chomp, 0);
     rb_define_method(cString, "strip", str_strip, 0);
@@ -2270,2 +2310,3 @@
     rb_define_method(cString, "chop!", str_chop_bang, 0);
+    rb_define_method(cString, "chomp!", str_chomp_bang, 0);
 
@@ -2295,2 +2336,5 @@
     rb_define_global_function("chop!", f_chop_bang, 0);
+
+    rb_define_global_function("chomp", f_chomp, 0);
+    rb_define_global_function("chomp!", f_chomp_bang, 0);
 

In This Thread

Prev Next