diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-06 14:41:53 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-06 14:41:53 +0000 |
commit | c93bf465dddd8d3aa8ffd10b1c13e8d1c9ded38b (patch) | |
tree | c71474970590303e3e95a7875f05583d2b57facd | |
parent | aa6ece9fc67894c8bceb633425a72ab1866b7df1 (diff) |
* ext/iconv/iconv.c (Iconv::BrokenLibrary): exception when detected a
bug of underlying library.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/iconv/iconv.c | 17 |
2 files changed, 21 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Sun Nov 6 23:39:13 2005 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ext/iconv/iconv.c (Iconv::BrokenLibrary): exception when detected a + bug of underlying library. + Sun Nov 6 21:46:59 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> * ext/tk/stubs.c (ruby_tcl_create_ip_and_stubs_init): should touch diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 5715b8fbde..98bef9610c 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -88,6 +88,7 @@ static VALUE rb_eIconvFailure; static VALUE rb_eIconvIllegalSeq; static VALUE rb_eIconvInvalidChar; static VALUE rb_eIconvOutOfRange; +static VALUE rb_eIconvBrokenLibrary; static ID rb_success, rb_failed; static VALUE iconv_fail _((VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg)); @@ -248,7 +249,10 @@ iconv_try #else #define ICONV_INPTR_CAST (char **) #endif - size_t ret = iconv(cd, ICONV_INPTR_CAST inptr, inlen, outptr, outlen); + size_t ret; + + errno = 0; + ret = iconv(cd, ICONV_INPTR_CAST inptr, inlen, outptr, outlen); if (ret == (size_t)-1) { if (!*inlen) return Qfalse; @@ -260,6 +264,8 @@ iconv_try return rb_eIconvIllegalSeq; case EINVAL: return rb_eIconvInvalidChar; + case 0: + return rb_eIconvBrokenLibrary; default: rb_sys_fail("iconv"); } @@ -857,6 +863,13 @@ iconv_failure_inspect * Iconv library internal error. Must not occur. */ +/* + * Document-class: Iconv::BrokenLibrary + * + * Detected a bug of underlying iconv(3) libray. + * * returns an error without setting errno properly + */ + void Init_iconv _((void)) { @@ -880,10 +893,12 @@ Init_iconv _((void)) rb_eIconvIllegalSeq = rb_define_class_under(rb_cIconv, "IllegalSequence", rb_eArgError); rb_eIconvInvalidChar = rb_define_class_under(rb_cIconv, "InvalidCharacter", rb_eArgError); rb_eIconvOutOfRange = rb_define_class_under(rb_cIconv, "OutOfRange", rb_eRuntimeError); + rb_eIconvBrokenLibrary = rb_define_class_under(rb_cIconv, "BrokenLibrary", rb_eRuntimeError); rb_include_module(rb_eIconvInvalidEncoding, rb_eIconvFailure); rb_include_module(rb_eIconvIllegalSeq, rb_eIconvFailure); rb_include_module(rb_eIconvInvalidChar, rb_eIconvFailure); rb_include_module(rb_eIconvOutOfRange, rb_eIconvFailure); + rb_include_module(rb_eIconvBrokenLibrary, rb_eIconvFailure); rb_success = rb_intern("success"); rb_failed = rb_intern("failed"); |