* 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:
matz 2008-10-17 09:13:04 +00:00
Родитель 7de38fadc0
Коммит 5ef37965fc
2 изменённых файлов: 24 добавлений и 16 удалений

Просмотреть файл

@ -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):
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>
* ext/socket/socket.c (init_sock): sockets should be binmode.

Просмотреть файл

@ -2307,28 +2307,27 @@ rb_econv_prepare_opts(VALUE opthash, VALUE *opts)
{
int ecflags;
VALUE newhash = Qnil;
VALUE v;
if (NIL_P(opthash)) {
*opts = Qnil;
return 0;
}
ecflags = econv_opts(opthash);
if ((ecflags & ECONV_INVALID_MASK) == ECONV_INVALID_REPLACE ||
(ecflags & ECONV_UNDEF_MASK) == ECONV_UNDEF_REPLACE) {
VALUE v = rb_hash_aref(opthash, sym_replace);
if (!NIL_P(v)) {
StringValue(v);
if (rb_enc_str_coderange(v) == ENC_CODERANGE_BROKEN) {
VALUE dumped = rb_str_dump(v);
rb_raise(rb_eArgError, "replacement string is broken: %s as %s",
StringValueCStr(dumped),
rb_enc_name(rb_enc_get(v)));
}
v = rb_str_new_frozen(v);
newhash = rb_hash_new();
rb_hash_aset(newhash, sym_replace, v);
}
v = rb_hash_aref(opthash, sym_replace);
if (!NIL_P(v)) {
StringValue(v);
if (rb_enc_str_coderange(v) == ENC_CODERANGE_BROKEN) {
VALUE dumped = rb_str_dump(v);
rb_raise(rb_eArgError, "replacement string is broken: %s as %s",
StringValueCStr(dumped),
rb_enc_name(rb_enc_get(v)));
}
v = rb_str_new_frozen(v);
newhash = rb_hash_new();
rb_hash_aset(newhash, sym_replace, v);
}
if (!NIL_P(newhash))
rb_hash_freeze(newhash);
*opts = newhash;
@ -2444,6 +2443,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
if (NIL_P(arg1)) {
return -1;
}
ecflags |= ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE;
}
else {
arg1 = argv[0];