ruby-changes:2612
From: ko1@a...
Date: 4 Dec 2007 19:57:06 +0900
Subject: [ruby-changes:2612] nobu - Ruby:r14103 (trunk): * ext/iconv/iconv.c (iconv_convert): should not set encoding unless
nobu 2007-12-04 19:56:44 +0900 (Tue, 04 Dec 2007)
New Revision: 14103
Modified files:
trunk/ChangeLog
trunk/ext/iconv/iconv.c
Log:
* ext/iconv/iconv.c (iconv_convert): should not set encoding unless
the target encoding is supported. [ruby-dev:32451]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/iconv/iconv.c?r1=14103&r2=14102
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14103&r2=14102
Index: ChangeLog
===================================================================
--- ChangeLog (revision 14102)
+++ ChangeLog (revision 14103)
@@ -1,3 +1,8 @@
+Tue Dec 4 19:56:42 2007 Nobuyoshi Nakada <nobu@r...>
+
+ * ext/iconv/iconv.c (iconv_convert): should not set encoding unless
+ the target encoding is supported. [ruby-dev:32451]
+
Tue Dec 4 17:34:17 2007 NARUSE, Yui <naruse@r...>
* ext/nkf/lib/kconv.rb (tojis, tosjis, toeuc, toutf8):
Index: ext/iconv/iconv.c
===================================================================
--- ext/iconv/iconv.c (revision 14102)
+++ ext/iconv/iconv.c (revision 14103)
@@ -336,10 +336,13 @@
char buffer[BUFSIZ];
char *outptr;
size_t outlen;
+ int toidx = -1;
if (cd == (iconv_t)-1)
rb_raise(rb_eArgError, "closed iconv");
+ if (env) toidx = env->toidx;
+
if (NIL_P(str)) {
/* Reset output pointer or something. */
inptr = "";
@@ -402,7 +405,7 @@
{
if (NIL_P(str)) {
ret = rb_str_new(buffer, outlen);
- if (env) rb_enc_associate_index(ret, env->toidx);
+ if (toidx >= 0) rb_enc_associate_index(ret, toidx);
}
else {
if (ret) {
@@ -410,7 +413,7 @@
}
else {
ret = rb_str_new(instart, tmpstart - instart);
- if (env) rb_enc_associate_index(ret, env->toidx);
+ if (toidx >= 0) rb_enc_associate_index(ret, toidx);
OBJ_INFECT(ret, str);
}
ret = rb_str_buf_cat(ret, buffer, outlen);
@@ -432,7 +435,7 @@
if (!ret) {
ret = rb_str_derive(str, instart, inptr - instart);
- if (env) rb_enc_associate_index(ret, env->toidx);
+ if (toidx >= 0) rb_enc_associate_index(ret, toidx);
}
else if (inptr > instart) {
rb_str_cat(ret, instart, inptr - instart);
@@ -458,7 +461,7 @@
if (!ret) {
ret = rb_str_derive(str, instart, inptr - instart);
- if (env) rb_enc_associate_index(ret, env->toidx);
+ if (toidx >= 0) rb_enc_associate_index(ret, toidx);
}
else if (inptr > instart) {
rb_str_cat(ret, instart, inptr - instart);
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml