mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (str_replace_shared): shared target must be frozen.
[ruby-core:23727] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e03cafe16c
commit
7915aed875
3 changed files with 16 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jun 12 02:41:21 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (str_replace_shared): shared target must be frozen.
|
||||
[ruby-core:23727]
|
||||
|
||||
Thu Jun 11 21:05:09 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* lib/cmath.rb (exp): omitted redundant function call.
|
||||
|
|
11
string.c
11
string.c
|
@ -14,6 +14,7 @@
|
|||
#include "ruby/ruby.h"
|
||||
#include "ruby/re.h"
|
||||
#include "ruby/encoding.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define BEG(no) regs->beg[no]
|
||||
#define END(no) regs->end[no]
|
||||
|
@ -599,6 +600,7 @@ str_replace_shared(VALUE str2, VALUE str)
|
|||
}
|
||||
else {
|
||||
FL_SET(str2, STR_NOEMBED);
|
||||
str = rb_str_new_frozen(str);
|
||||
RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
|
||||
RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
|
||||
RSTRING(str2)->as.heap.aux.shared = str;
|
||||
|
@ -643,8 +645,10 @@ str_new4(VALUE klass, VALUE str)
|
|||
RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
|
||||
RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
|
||||
if (STR_SHARED_P(str)) {
|
||||
VALUE shared = RSTRING(str)->as.heap.aux.shared;
|
||||
assert(OBJ_FROZEN(shared));
|
||||
FL_SET(str2, ELTS_SHARED);
|
||||
RSTRING(str2)->as.heap.aux.shared = RSTRING(str)->as.heap.aux.shared;
|
||||
RSTRING(str2)->as.heap.aux.shared = shared;
|
||||
}
|
||||
else {
|
||||
FL_SET(str, ELTS_SHARED);
|
||||
|
@ -664,6 +668,7 @@ rb_str_new_frozen(VALUE orig)
|
|||
klass = rb_obj_class(orig);
|
||||
if (STR_SHARED_P(orig) && (str = RSTRING(orig)->as.heap.aux.shared)) {
|
||||
long ofs;
|
||||
assert(OBJ_FROZEN(str));
|
||||
ofs = RSTRING_LEN(str) - RSTRING_LEN(orig);
|
||||
if ((ofs > 0) || (klass != RBASIC(str)->klass) ||
|
||||
(!OBJ_TAINTED(str) && OBJ_TAINTED(orig))) {
|
||||
|
@ -824,12 +829,14 @@ str_replace(VALUE str, VALUE str2)
|
|||
str2 = rb_str_new4(str2);
|
||||
}
|
||||
if (STR_SHARED_P(str2)) {
|
||||
VALUE shared = RSTRING(str2)->as.heap.aux.shared;
|
||||
assert(OBJ_FROZEN(shared));
|
||||
STR_SET_NOEMBED(str);
|
||||
RSTRING(str)->as.heap.len = len;
|
||||
RSTRING(str)->as.heap.ptr = RSTRING_PTR(str2);
|
||||
FL_SET(str, ELTS_SHARED);
|
||||
FL_UNSET(str, STR_ASSOC);
|
||||
RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
|
||||
RSTRING(str)->as.heap.aux.shared = shared;
|
||||
}
|
||||
else {
|
||||
str_replace_shared(str, str2);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#define RUBY_VERSION "1.9.2"
|
||||
#define RUBY_RELEASE_DATE "2009-06-11"
|
||||
#define RUBY_RELEASE_DATE "2009-06-12"
|
||||
#define RUBY_PATCHLEVEL -1
|
||||
#define RUBY_BRANCH_NAME "trunk"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
|||
#define RUBY_VERSION_TEENY 1
|
||||
#define RUBY_RELEASE_YEAR 2009
|
||||
#define RUBY_RELEASE_MONTH 6
|
||||
#define RUBY_RELEASE_DAY 11
|
||||
#define RUBY_RELEASE_DAY 12
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue