* ext/iconv/iconv.c (iconv_convert): should not set encoding unless
the target encoding is supported. [ruby-dev:32451] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6ccd9e0372
commit
398cdd3825
@ -1,3 +1,8 @@
|
|||||||
|
Tue Dec 4 19:56:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Tue Dec 4 17:34:17 2007 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/nkf/lib/kconv.rb (tojis, tosjis, toeuc, toutf8):
|
* ext/nkf/lib/kconv.rb (tojis, tosjis, toeuc, toutf8):
|
||||||
|
@ -336,10 +336,13 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
char *outptr;
|
char *outptr;
|
||||||
size_t outlen;
|
size_t outlen;
|
||||||
|
int toidx = -1;
|
||||||
|
|
||||||
if (cd == (iconv_t)-1)
|
if (cd == (iconv_t)-1)
|
||||||
rb_raise(rb_eArgError, "closed iconv");
|
rb_raise(rb_eArgError, "closed iconv");
|
||||||
|
|
||||||
|
if (env) toidx = env->toidx;
|
||||||
|
|
||||||
if (NIL_P(str)) {
|
if (NIL_P(str)) {
|
||||||
/* Reset output pointer or something. */
|
/* Reset output pointer or something. */
|
||||||
inptr = "";
|
inptr = "";
|
||||||
@ -402,7 +405,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||||||
{
|
{
|
||||||
if (NIL_P(str)) {
|
if (NIL_P(str)) {
|
||||||
ret = rb_str_new(buffer, outlen);
|
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 {
|
else {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -410,7 +413,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = rb_str_new(instart, tmpstart - instart);
|
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);
|
OBJ_INFECT(ret, str);
|
||||||
}
|
}
|
||||||
ret = rb_str_buf_cat(ret, buffer, outlen);
|
ret = rb_str_buf_cat(ret, buffer, outlen);
|
||||||
@ -432,7 +435,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = rb_str_derive(str, instart, inptr - instart);
|
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) {
|
else if (inptr > instart) {
|
||||||
rb_str_cat(ret, instart, inptr - instart);
|
rb_str_cat(ret, instart, inptr - instart);
|
||||||
@ -458,7 +461,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
|
|||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = rb_str_derive(str, instart, inptr - instart);
|
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) {
|
else if (inptr > instart) {
|
||||||
rb_str_cat(ret, instart, inptr - instart);
|
rb_str_cat(ret, instart, inptr - instart);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user