summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-10-02 04:25:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-10-02 04:25:53 +0000
commit3ab5d775b737f681225864200c893b68b7b8f546 (patch)
treea7d8d79fba4dd4bf11bcd80d66ab41679049fec3 /string.c
parente431908527e19099572492a08742c9529f3d32ab (diff)
downloadruby-3ab5d775b737f681225864200c893b68b7b8f546.tar.gz
* ext/socket/socket.c (unix_addr): getsockname(2) may result len = 0.
* ext/socket/socket.c (unix_peeraddr): getpeername(2) may result len = 0. * eval.c (POP_BLOCK): rb_gc_force_recycle() was called too much. Should not be called if SCOPE_DONT_RECYCLE is set. * string.c (rb_str_substr): should return an instance of receiver's class. * string.c (rb_str_succ): ditto. * array.c (rb_ary_subseq): ditto. * string.c (rb_str_reverse): should return an instance of reciever's class. * string.c (rb_str_times): ditto. * array.c (rb_ary_times): ditto * string.c (str_gsub): ditto. * string.c (rb_str_ljust): ditto. * string.c (rb_str_rjust): ditto. * string.c (rb_str_center): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/string.c b/string.c
index bb0201c1c3..519dbbe31e 100644
--- a/string.c
+++ b/string.c
@@ -306,9 +306,8 @@ rb_str_times(str, times)
}
RSTRING(str2)->ptr[RSTRING(str2)->len] = '\0';
- if (OBJ_TAINTED(str)) {
- OBJ_TAINT(str2);
- }
+ OBJ_INFECT(str2, str);
+ RBASIC(str2)->klass = rb_obj_class(str);
return str2;
}
@@ -354,6 +353,7 @@ rb_str_substr(str, beg, len)
if (len == 0) return rb_str_new(0,0);
str2 = rb_str_new(RSTRING(str)->ptr+beg, len);
+ RBASIC(str2)->klass = rb_obj_class(str);
if (OBJ_TAINTED(str)) OBJ_TAINT(str2);
return str2;
@@ -807,6 +807,7 @@ rb_str_succ(orig)
int n = 0;
str = rb_str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
+ RBASIC(str)->klass = rb_obj_class(orig);
OBJ_INFECT(str, orig);
if (RSTRING(str)->len == 0) return str;
@@ -1288,6 +1289,7 @@ str_gsub(argc, argv, str, bang)
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
OBJ_INFECT(dup, str);
+ RBASIC(dup)->klass = rb_obj_class(str);
str = (VALUE)dup;
dup->orig = 0;
}
@@ -1432,6 +1434,8 @@ rb_str_reverse(str)
while (e >= s) {
*p++ = *e--;
}
+ OBJ_INFECT(obj, str);
+ RBASIC(obj)->klass = rb_obj_class(str);
return obj;
}
@@ -2718,6 +2722,7 @@ rb_str_ljust(str, w)
if (width < 0 || RSTRING(str)->len >= width) return str;
res = rb_str_new(0, width);
+ RBASIC(res)->klass = rb_obj_class(str);
memcpy(RSTRING(res)->ptr, RSTRING(str)->ptr, RSTRING(str)->len);
p = RSTRING(res)->ptr + RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
while (p < pend) {
@@ -2738,6 +2743,7 @@ rb_str_rjust(str, w)
if (width < 0 || RSTRING(str)->len >= width) return str;
res = rb_str_new(0, width);
+ RBASIC(res)->klass = rb_obj_class(str);
p = RSTRING(res)->ptr; pend = p + width - RSTRING(str)->len;
while (p < pend) {
*p++ = ' ';
@@ -2759,6 +2765,7 @@ rb_str_center(str, w)
if (width < 0 || RSTRING(str)->len >= width) return str;
res = rb_str_new(0, width);
+ RBASIC(res)->klass = rb_obj_class(str);
n = (width - RSTRING(str)->len)/2;
p = RSTRING(res)->ptr; pend = p + n;
while (p < pend) {