ruby-changes:14642
From: yugui <ko1@a...>
Date: Sat, 30 Jan 2010 21:48:24 +0900 (JST)
Subject: [ruby-changes:14642] Ruby:r26487 (ruby_1_9_1): merges r25343 from trunk into ruby_1_9_1.
yugui 2010-01-30 21:48:07 +0900 (Sat, 30 Jan 2010) New Revision: 26487 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26487 Log: merges r25343 from trunk into ruby_1_9_1. -- * ext/iconv/iconv.c (iconv_create): cannot retry with given block. [ruby-dev:39487] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/ext/iconv/iconv.c branches/ruby_1_9_1/test/iconv/test_basic.rb branches/ruby_1_9_1/test/iconv/test_option.rb branches/ruby_1_9_1/test/iconv/test_partial.rb branches/ruby_1_9_1/version.h Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 26486) +++ ruby_1_9_1/ChangeLog (revision 26487) @@ -1,3 +1,8 @@ +Thu Oct 15 14:20:58 2009 Nobuyoshi Nakada <nobu@r...> + + * ext/iconv/iconv.c (iconv_create): cannot retry with given block. + [ruby-dev:39487] + Thu Oct 15 09:25:07 2009 NAKAMURA Usaku <usa@r...> * ext/socket/init.c (rsock_init_sock): mswin doesn't have S_IFSOCK Index: ruby_1_9_1/ext/iconv/iconv.c =================================================================== --- ruby_1_9_1/ext/iconv/iconv.c (revision 26486) +++ ruby_1_9_1/ext/iconv/iconv.c (revision 26487) @@ -106,6 +106,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)); @@ -231,8 +232,8 @@ s = RSTRING_PTR(msg); rb_str_set_len(msg, 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)); } } @@ -372,7 +373,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); rb_set_errinfo(error); return rb_yield(failed); @@ -418,7 +425,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_LEN(rescue) > 0 ? RARRAY_PTR(rescue)[0] : Qnil; } @@ -502,7 +509,7 @@ 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_LEN(rescue)) > 0) rb_str_concat(ret, RARRAY_PTR(rescue)[0]); Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 26486) +++ ruby_1_9_1/version.h (revision 26487) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 392 +#define RUBY_PATCHLEVEL 393 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_1/test/iconv/test_basic.rb =================================================================== --- ruby_1_9_1/test/iconv/test_basic.rb (revision 26486) +++ ruby_1_9_1/test/iconv/test_basic.rb (revision 26487) @@ -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 @@ -52,5 +52,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_9_1/test/iconv/test_option.rb =================================================================== --- ruby_1_9_1/test/iconv/test_option.rb (revision 26486) +++ ruby_1_9_1/test/iconv/test_option.rb (revision 26487) @@ -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_9_1/test/iconv/test_partial.rb =================================================================== --- ruby_1_9_1/test/iconv/test_partial.rb (revision 26486) +++ ruby_1_9_1/test/iconv/test_partial.rb (revision 26487) @@ -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/