mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
merge revision(s) 25343:
* ext/iconv/iconv.c (iconv_create): cannot retry with given block. [ruby-dev:39487] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@25902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
06b911ea00
commit
a185b734fe
6 changed files with 24 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Nov 24 16:15:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/iconv/iconv.c (iconv_create): cannot retry with given block.
|
||||||
|
[ruby-dev:39487]
|
||||||
|
|
||||||
Tue Nov 24 16:12:33 2009 Shugo Maeda <shugo@ruby-lang.org>
|
Tue Nov 24 16:12:33 2009 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/imap.rb (resp_text_code): accepts response codes without
|
* lib/net/imap.rb (resp_text_code): accepts response codes without
|
||||||
|
|
|
@ -92,6 +92,7 @@ static VALUE rb_eIconvBrokenLibrary;
|
||||||
|
|
||||||
static ID rb_success, rb_failed;
|
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 _((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_initialize _((VALUE error, VALUE mesg, VALUE success, VALUE failed));
|
||||||
static VALUE iconv_failure_success _((VALUE self));
|
static VALUE iconv_failure_success _((VALUE self));
|
||||||
static VALUE iconv_failure_failed _((VALUE self));
|
static VALUE iconv_failure_failed _((VALUE self));
|
||||||
|
@ -179,8 +180,8 @@ iconv_create
|
||||||
s = RSTRING(msg)->ptr;
|
s = RSTRING(msg)->ptr;
|
||||||
RSTRING(msg)->len = strlen(s);
|
RSTRING(msg)->len = strlen(s);
|
||||||
if (!inval) rb_sys_fail(s);
|
if (!inval) rb_sys_fail(s);
|
||||||
iconv_fail(rb_eIconvInvalidEncoding,
|
rb_exc_raise(iconv_fail(rb_eIconvInvalidEncoding, Qnil,
|
||||||
Qnil, rb_ary_new3(2, to, from), NULL, s);
|
rb_ary_new3(2, to, from), NULL, s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +329,13 @@ iconv_fail
|
||||||
args[2] = rb_ary_new4(env->argc, env->argv);
|
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);
|
if (!rb_block_given_p()) rb_exc_raise(error);
|
||||||
ruby_errinfo = error;
|
ruby_errinfo = error;
|
||||||
return rb_yield(failed);
|
return rb_yield(failed);
|
||||||
|
@ -394,7 +401,7 @@ iconv_convert
|
||||||
error = iconv_try(cd, &inptr, &inlen, &outptr, &outlen);
|
error = iconv_try(cd, &inptr, &inlen, &outptr, &outlen);
|
||||||
if (RTEST(error)) {
|
if (RTEST(error)) {
|
||||||
unsigned int i;
|
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) {
|
if (TYPE(rescue) == T_ARRAY) {
|
||||||
str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil;
|
str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil;
|
||||||
}
|
}
|
||||||
|
@ -473,7 +480,7 @@ iconv_convert
|
||||||
else if (inptr > instart)
|
else if (inptr > instart)
|
||||||
rb_str_cat(ret, instart, inptr - instart);
|
rb_str_cat(ret, instart, inptr - instart);
|
||||||
str = rb_str_derive(str, inptr, inlen);
|
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 (TYPE(rescue) == T_ARRAY) {
|
||||||
if ((len = RARRAY(rescue)->len) > 0)
|
if ((len = RARRAY(rescue)->len) > 0)
|
||||||
rb_str_concat(ret, RARRAY(rescue)->ptr[0]);
|
rb_str_concat(ret, RARRAY(rescue)->ptr[0]);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require File.join(File.dirname(__FILE__), "utils.rb")
|
require File.expand_path("../utils.rb", __FILE__)
|
||||||
|
|
||||||
class TestIconv::Basic < TestIconv
|
class TestIconv::Basic < TestIconv
|
||||||
def test_euc2sjis
|
def test_euc2sjis
|
||||||
|
@ -45,5 +45,8 @@ class TestIconv::Basic < TestIconv
|
||||||
|
|
||||||
def test_unknown_encoding
|
def test_unknown_encoding
|
||||||
assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") }
|
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
|
||||||
end if defined?(TestIconv)
|
end if defined?(TestIconv)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require File.join(File.dirname(__FILE__), "utils.rb")
|
require File.expand_path("../utils.rb", __FILE__)
|
||||||
|
|
||||||
class TestIconv::Option < TestIconv
|
class TestIconv::Option < TestIconv
|
||||||
def test_ignore_option
|
def test_ignore_option
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require File.join(File.dirname(__FILE__), "utils.rb")
|
require File.expand_path("../utils.rb", __FILE__)
|
||||||
|
|
||||||
class TestIconv::Partial < TestIconv
|
class TestIconv::Partial < TestIconv
|
||||||
def test_partial_ascii
|
def test_partial_ascii
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define RUBY_RELEASE_DATE "2009-11-24"
|
#define RUBY_RELEASE_DATE "2009-11-24"
|
||||||
#define RUBY_VERSION_CODE 187
|
#define RUBY_VERSION_CODE 187
|
||||||
#define RUBY_RELEASE_CODE 20091124
|
#define RUBY_RELEASE_CODE 20091124
|
||||||
#define RUBY_PATCHLEVEL 219
|
#define RUBY_PATCHLEVEL 220
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
#define RUBY_VERSION_MINOR 8
|
#define RUBY_VERSION_MINOR 8
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue