ruby-changes:14089
From: shyouhei <ko1@a...>
Date: Tue, 24 Nov 2009 16:18:53 +0900 (JST)
Subject: [ruby-changes:14089] Ruby:r25902 (ruby_1_8_7): merge revision(s) 25343:
shyouhei 2009-11-24 16:18:40 +0900 (Tue, 24 Nov 2009) New Revision: 25902 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25902 Log: merge revision(s) 25343: * ext/iconv/iconv.c (iconv_create): cannot retry with given block. [ruby-dev:39487] Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/ext/iconv/iconv.c branches/ruby_1_8_7/test/iconv/test_basic.rb branches/ruby_1_8_7/test/iconv/test_option.rb branches/ruby_1_8_7/test/iconv/test_partial.rb branches/ruby_1_8_7/version.h Index: ruby_1_8_7/ext/iconv/iconv.c =================================================================== --- ruby_1_8_7/ext/iconv/iconv.c (revision 25901) +++ ruby_1_8_7/ext/iconv/iconv.c (revision 25902) @@ -92,6 +92,7 @@ static ID rb_success, rb_failed; static VALUE iconv_fail _((VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg)); +static VALUE iconv_fail_retry _((VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg)); static VALUE iconv_failure_initialize _((VALUE error, VALUE mesg, VALUE success, VALUE failed)); static VALUE iconv_failure_success _((VALUE self)); static VALUE iconv_failure_failed _((VALUE self)); @@ -179,8 +180,8 @@ s = RSTRING(msg)->ptr; RSTRING(msg)->len = strlen(s); if (!inval) rb_sys_fail(s); - iconv_fail(rb_eIconvInvalidEncoding, - Qnil, rb_ary_new3(2, to, from), NULL, s); + rb_exc_raise(iconv_fail(rb_eIconvInvalidEncoding, Qnil, + rb_ary_new3(2, to, from), NULL, s)); } } @@ -328,7 +329,13 @@ args[2] = rb_ary_new4(env->argc, env->argv); } } - error = rb_class_new_instance(3, args, error); + return rb_class_new_instance(3, args, error); +} + +static VALUE +iconv_fail_retry(VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg) +{ + error = iconv_fail(error, success, failed, env, mesg); if (!rb_block_given_p()) rb_exc_raise(error); ruby_errinfo = error; return rb_yield(failed); @@ -394,7 +401,7 @@ error = iconv_try(cd, &inptr, &inlen, &outptr, &outlen); if (RTEST(error)) { unsigned int i; - rescue = iconv_fail(error, Qnil, Qnil, env, 0); + rescue = iconv_fail_retry(error, Qnil, Qnil, env, 0); if (TYPE(rescue) == T_ARRAY) { str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil; } @@ -473,7 +480,7 @@ else if (inptr > instart) rb_str_cat(ret, instart, inptr - instart); str = rb_str_derive(str, inptr, inlen); - rescue = iconv_fail(error, ret, str, env, errmsg); + rescue = iconv_fail_retry(error, ret, str, env, errmsg); if (TYPE(rescue) == T_ARRAY) { if ((len = RARRAY(rescue)->len) > 0) rb_str_concat(ret, RARRAY(rescue)->ptr[0]); Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 25901) +++ ruby_1_8_7/ChangeLog (revision 25902) @@ -1,3 +1,8 @@ +Tue Nov 24 16:15:18 2009 Nobuyoshi Nakada <nobu@r...> + + * ext/iconv/iconv.c (iconv_create): cannot retry with given block. + [ruby-dev:39487] + Tue Nov 24 16:12:33 2009 Shugo Maeda <shugo@r...> * lib/net/imap.rb (resp_text_code): accepts response codes without Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 25901) +++ ruby_1_8_7/version.h (revision 25902) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2009-11-24" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20091124 -#define RUBY_PATCHLEVEL 219 +#define RUBY_PATCHLEVEL 220 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 Index: ruby_1_8_7/test/iconv/test_basic.rb =================================================================== --- ruby_1_8_7/test/iconv/test_basic.rb (revision 25901) +++ ruby_1_8_7/test/iconv/test_basic.rb (revision 25902) @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), "utils.rb") +require File.expand_path("../utils.rb", __FILE__) class TestIconv::Basic < TestIconv def test_euc2sjis @@ -45,5 +45,8 @@ def test_unknown_encoding assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") } + assert_raise(Iconv::InvalidEncoding, '[ruby-dev:39487]') { + Iconv.iconv("X-UNKNOWN-1", "X-UNKNOWN-2") {break} + } end end if defined?(TestIconv) Index: ruby_1_8_7/test/iconv/test_option.rb =================================================================== --- ruby_1_8_7/test/iconv/test_option.rb (revision 25901) +++ ruby_1_8_7/test/iconv/test_option.rb (revision 25902) @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), "utils.rb") +require File.expand_path("../utils.rb", __FILE__) class TestIconv::Option < TestIconv def test_ignore_option Index: ruby_1_8_7/test/iconv/test_partial.rb =================================================================== --- ruby_1_8_7/test/iconv/test_partial.rb (revision 25901) +++ ruby_1_8_7/test/iconv/test_partial.rb (revision 25902) @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), "utils.rb") +require File.expand_path("../utils.rb", __FILE__) class TestIconv::Partial < TestIconv def test_partial_ascii -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/