mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* transcode.c (rb_str_transcode_bang): set coderange.
* transcode.c (rb_str_transcode): use rb_str_transcode_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
be36a1b138
commit
d2797c33bd
2 changed files with 18 additions and 13 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Mar 6 14:29:44 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* transcode.c (rb_str_transcode_bang): set coderange.
|
||||
|
||||
* transcode.c (rb_str_transcode): use rb_str_transcode_bang.
|
||||
|
||||
Thu Mar 6 14:00:10 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/missing.h (cbrt): add declaration.
|
||||
|
|
25
transcode.c
25
transcode.c
|
@ -409,10 +409,20 @@ rb_str_transcode_bang(int argc, VALUE *argv, VALUE str)
|
|||
{
|
||||
VALUE newstr = str;
|
||||
int encidx = str_transcode(argc, argv, &newstr);
|
||||
int cr = 0;
|
||||
|
||||
if (encidx < 0) return str;
|
||||
rb_str_shared_replace(str, newstr);
|
||||
rb_enc_associate_index(str, encidx);
|
||||
|
||||
/* transcoded string never be broken. */
|
||||
if (rb_enc_asciicompat(rb_enc_from_index(encidx))) {
|
||||
rb_str_coderange_scan_restartable(RSTRING_PTR(str), RSTRING_END(str), 0, &cr);
|
||||
}
|
||||
else {
|
||||
cr = ENC_CODERANGE_VALID;
|
||||
}
|
||||
ENC_CODERANGE_SET(str, cr);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -432,19 +442,8 @@ rb_str_transcode_bang(int argc, VALUE *argv, VALUE str)
|
|||
static VALUE
|
||||
rb_str_transcode(int argc, VALUE *argv, VALUE str)
|
||||
{
|
||||
VALUE newstr = str;
|
||||
int encidx = str_transcode(argc, argv, &newstr);
|
||||
|
||||
if (newstr == str) {
|
||||
newstr = rb_str_new3(str);
|
||||
if (encidx >= 0) rb_enc_associate_index(newstr, encidx);
|
||||
}
|
||||
else {
|
||||
RBASIC(newstr)->klass = rb_obj_class(str);
|
||||
OBJ_INFECT(newstr, str);
|
||||
rb_enc_associate_index(newstr, encidx);
|
||||
}
|
||||
return newstr;
|
||||
str = rb_str_dup(str);
|
||||
return rb_str_transcode_bang(argc, argv, str);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue