зеркало из https://github.com/github/ruby.git
* transcode.c (str_transcode0): String#encode without argument now
behave as if :undef => :replace, :invalid => :replace specified. * transcode.c (rb_econv_prepare_opts): should preserve options in any case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7de38fadc0
Коммит
5ef37965fc
|
@ -3,6 +3,14 @@ Fri Oct 17 18:07:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
* test/rubygems/gemutilities.rb (RubyGemTestCase#build_rake_in):
|
* test/rubygems/gemutilities.rb (RubyGemTestCase#build_rake_in):
|
||||||
get rid of interference with other tests.
|
get rid of interference with other tests.
|
||||||
|
|
||||||
|
Fri Oct 17 18:06:39 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* transcode.c (str_transcode0): String#encode without argument now
|
||||||
|
behave as if :undef => :replace, :invalid => :replace specified.
|
||||||
|
|
||||||
|
* transcode.c (rb_econv_prepare_opts): should preserve options in
|
||||||
|
any case.
|
||||||
|
|
||||||
Fri Oct 17 11:48:18 2008 Shugo Maeda <shugo@ruby-lang.org>
|
Fri Oct 17 11:48:18 2008 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* ext/socket/socket.c (init_sock): sockets should be binmode.
|
* ext/socket/socket.c (init_sock): sockets should be binmode.
|
||||||
|
|
32
transcode.c
32
transcode.c
|
@ -2307,28 +2307,27 @@ rb_econv_prepare_opts(VALUE opthash, VALUE *opts)
|
||||||
{
|
{
|
||||||
int ecflags;
|
int ecflags;
|
||||||
VALUE newhash = Qnil;
|
VALUE newhash = Qnil;
|
||||||
|
VALUE v;
|
||||||
|
|
||||||
if (NIL_P(opthash)) {
|
if (NIL_P(opthash)) {
|
||||||
*opts = Qnil;
|
*opts = Qnil;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ecflags = econv_opts(opthash);
|
ecflags = econv_opts(opthash);
|
||||||
|
v = rb_hash_aref(opthash, sym_replace);
|
||||||
if ((ecflags & ECONV_INVALID_MASK) == ECONV_INVALID_REPLACE ||
|
if (!NIL_P(v)) {
|
||||||
(ecflags & ECONV_UNDEF_MASK) == ECONV_UNDEF_REPLACE) {
|
StringValue(v);
|
||||||
VALUE v = rb_hash_aref(opthash, sym_replace);
|
if (rb_enc_str_coderange(v) == ENC_CODERANGE_BROKEN) {
|
||||||
if (!NIL_P(v)) {
|
VALUE dumped = rb_str_dump(v);
|
||||||
StringValue(v);
|
rb_raise(rb_eArgError, "replacement string is broken: %s as %s",
|
||||||
if (rb_enc_str_coderange(v) == ENC_CODERANGE_BROKEN) {
|
StringValueCStr(dumped),
|
||||||
VALUE dumped = rb_str_dump(v);
|
rb_enc_name(rb_enc_get(v)));
|
||||||
rb_raise(rb_eArgError, "replacement string is broken: %s as %s",
|
}
|
||||||
StringValueCStr(dumped),
|
v = rb_str_new_frozen(v);
|
||||||
rb_enc_name(rb_enc_get(v)));
|
newhash = rb_hash_new();
|
||||||
}
|
rb_hash_aset(newhash, sym_replace, v);
|
||||||
v = rb_str_new_frozen(v);
|
|
||||||
newhash = rb_hash_new();
|
|
||||||
rb_hash_aset(newhash, sym_replace, v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NIL_P(newhash))
|
if (!NIL_P(newhash))
|
||||||
rb_hash_freeze(newhash);
|
rb_hash_freeze(newhash);
|
||||||
*opts = newhash;
|
*opts = newhash;
|
||||||
|
@ -2444,6 +2443,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
|
||||||
if (NIL_P(arg1)) {
|
if (NIL_P(arg1)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
ecflags |= ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arg1 = argv[0];
|
arg1 = argv[0];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче