зеркало из https://github.com/github/ruby.git
* re.c (rb_reg_regsub): should copy encoding.
* string.c (rb_str_sub_bang, str_gsub): should check and copy encoding to be replaced. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
65a30eb3e7
Коммит
ad72efa269
|
@ -1,3 +1,10 @@
|
|||
Wed Dec 12 12:11:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* re.c (rb_reg_regsub): should copy encoding.
|
||||
|
||||
* string.c (rb_str_sub_bang, str_gsub): should check and copy encoding
|
||||
to be replaced.
|
||||
|
||||
Tue Dec 11 23:04:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* pack.c (pack_pack): RDoc update. a patch from Gary Wright
|
||||
|
|
1
re.c
1
re.c
|
@ -2796,6 +2796,7 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
|
|||
rb_str_buf_cat(val, p, e-p);
|
||||
}
|
||||
if (!val) return str;
|
||||
rb_enc_copy(val, str);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
|
9
string.c
9
string.c
|
@ -2370,15 +2370,19 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
|
|||
|
||||
if (iter) {
|
||||
char *p = RSTRING_PTR(str); long len = RSTRING_LEN(str);
|
||||
rb_encoding *enc;
|
||||
|
||||
rb_match_busy(match);
|
||||
repl = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
|
||||
enc = rb_enc_check(str, repl);
|
||||
str_mod_check(str, p, len);
|
||||
str_frozen_check(str);
|
||||
rb_backref_set(match);
|
||||
rb_enc_associate(str, enc);
|
||||
}
|
||||
else {
|
||||
repl = rb_reg_regsub(repl, str, regs, pat);
|
||||
rb_enc_copy(str, repl);
|
||||
}
|
||||
rb_str_modify(str);
|
||||
if (OBJ_TAINTED(repl)) tainted = 1;
|
||||
|
@ -2490,17 +2494,22 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
|
|||
match = rb_backref_get();
|
||||
regs = RMATCH(match)->regs;
|
||||
if (iter) {
|
||||
rb_encoding *enc;
|
||||
|
||||
rb_match_busy(match);
|
||||
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
|
||||
enc = rb_enc_check(str, val);
|
||||
str_mod_check(str, sp, slen);
|
||||
if (bang) str_frozen_check(str);
|
||||
if (val == dest) { /* paranoid chack [ruby-dev:24827] */
|
||||
rb_raise(rb_eRuntimeError, "block should not cheat");
|
||||
}
|
||||
rb_backref_set(match);
|
||||
rb_enc_associate(str, enc);
|
||||
}
|
||||
else {
|
||||
val = rb_reg_regsub(repl, str, regs, pat);
|
||||
rb_enc_copy(str, val);
|
||||
}
|
||||
if (OBJ_TAINTED(val)) tainted = 1;
|
||||
len = (bp - buf) + (beg - offset) + RSTRING_LEN(val) + 3;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2007-12-11"
|
||||
#define RUBY_RELEASE_DATE "2007-12-12"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20071211
|
||||
#define RUBY_RELEASE_CODE 20071212
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 12
|
||||
#define RUBY_RELEASE_DAY 11
|
||||
#define RUBY_RELEASE_DAY 12
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
Загрузка…
Ссылка в новой задаче