[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02008] Re: slice! ate my machine!

From: ts <decoux@...>
Date: 2000-03-18 16:28:23 UTC
List: ruby-talk #2008
>>>>> "Y" == Yukihiro Matsumoto <matz@netlab.co.jp> writes:

Y> -    if (len != RSTRING(val)->len) {
Y> +    if (RSTRING(val)->len != len && RSTRING(val)->len > beg + len) {
Y>  	memmove(RSTRING(str)->ptr + beg + RSTRING(val)->len,

aestivum% diff -u string.c.old string.c
--- string.c.old        Sat Mar 18 17:18:46 2000
+++ string.c    Sat Mar 18 17:19:48 2000
@@ -891,7 +891,7 @@
        REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+RSTRING(val)->len-len+1);
     }
 
-    if (len != RSTRING(val)->len) {
+    if (RSTRING(val)->len != len && RSTRING(val)->len > beg + len) {
        memmove(RSTRING(str)->ptr + beg + RSTRING(val)->len,
                RSTRING(str)->ptr + beg + len,
                RSTRING(str)->len - (beg + len));
aestivum% ./ruby -e 'a = "hello"; p a.slice!(3, 4); p a'
"lo"
"h"
aestivum% ruby -v
ruby 1.5.3 (2000-03-17) [i686-linux]
aestivum% 

 Perhaps I've not understood what do slice! , but personnaly I'll check
 RSTRING(str)->len < len + beg and adjust len in consequence, no ?


Guy Decoux

In This Thread