1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* transcode.c (enc_arg): revert last change. too early exception

raising.

* transcode.c (enc_arg): need not to take pointer argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-09-18 08:27:17 +00:00
parent b7c95b923a
commit 45ee7d2e78
2 changed files with 30 additions and 9 deletions

View file

@ -1,3 +1,10 @@
Thu Sep 18 17:18:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* transcode.c (enc_arg): revert last change. too early exception
raising.
* transcode.c (enc_arg): need not to take pointer argument.
Sun Jun 8 21:50:27 2008 Yusuke Endoh <mame@tsg.ne.jp>
* test/bigdecimal/test_bigdecimal.rb: add tests to achieve over 90%

View file

@ -2387,12 +2387,26 @@ rb_econv_open_opts(const char *source_encoding, const char *destination_encoding
}
static int
enc_arg(volatile VALUE *arg, const char **name_p, rb_encoding **enc_p)
enc_arg(VALUE arg, const char **name_p, rb_encoding **enc_p)
{
rb_encoding *enc = rb_to_encoding(*arg);
*name_p = rb_enc_name(enc);
rb_encoding *enc;
const char *n;
int encidx;
if ((encidx = rb_to_encoding_index(arg)) < 0) {
enc = NULL;
encidx = 0;
n = StringValueCStr(arg);
}
else {
enc = rb_enc_from_index(encidx);
n = rb_enc_name(enc);
}
*name_p = n;
*enc_p = enc;
return rb_enc_to_index(enc);
return encidx;
}
static int
@ -2404,7 +2418,7 @@ str_transcode_enc_args(VALUE str, volatile VALUE *arg1, volatile VALUE *arg2,
const char *sname, *dname;
int sencidx, dencidx;
dencidx = enc_arg(arg1, &dname, &denc);
dencidx = enc_arg(*arg1, &dname, &denc);
if (NIL_P(*arg2)) {
sencidx = rb_enc_get_index(str);
@ -2412,7 +2426,7 @@ str_transcode_enc_args(VALUE str, volatile VALUE *arg1, volatile VALUE *arg2,
sname = rb_enc_name(senc);
}
else {
sencidx = enc_arg(arg2, &sname, &senc);
sencidx = enc_arg(*arg2, &sname, &senc);
}
*sname_p = sname;
@ -2656,7 +2670,7 @@ econv_s_asciicompat_encoding(VALUE klass, VALUE arg)
const char *arg_name, *result_name;
rb_encoding *arg_enc, *result_enc;
enc_arg(&arg, &arg_name, &arg_enc);
enc_arg(arg, &arg_name, &arg_enc);
result_name = rb_econv_asciicompat_encoding(arg_name);
@ -2867,9 +2881,9 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
if (RARRAY_LEN(pair) != 2)
rb_raise(rb_eArgError, "not a 2-element array in convpath");
snamev = rb_ary_entry(pair, 0);
enc_arg(&snamev, &sname, &senc);
enc_arg(snamev, &sname, &senc);
dnamev = rb_ary_entry(pair, 1);
enc_arg(&dnamev, &dname, &denc);
enc_arg(dnamev, &dname, &denc);
}
else {
sname = "";