summaryrefslogtreecommitdiffstats
path: root/transcode.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-04 16:45:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-04 16:45:31 +0000
commit7e225bfc6f61c77af3c8dc0aa1516801d6581d30 (patch)
treea8b5d81cd5c8267f098fec591fd27679ecd3d118 /transcode.c
parenta550f4991a5b7d8b5506171edd411328a045ef2b (diff)
downloadruby-7e225bfc6f61c77af3c8dc0aa1516801d6581d30.tar.gz
ruby-7e225bfc6f61c77af3c8dc0aa1516801d6581d30.tar.xz
ruby-7e225bfc6f61c77af3c8dc0aa1516801d6581d30.zip
* transcode.c (make_econv_exception): refine error message for
undefined conversion. [ruby-core:21828] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/transcode.c b/transcode.c
index 032059051..1c4b997fc 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2026,17 +2026,27 @@ make_econv_exception(rb_econv_t *ec)
}
if (dumped == Qnil)
dumped = rb_str_dump(bytes);
- mesg = rb_sprintf("%s from %s to %s",
- StringValueCStr(dumped),
- ec->last_error.source_encoding,
- ec->last_error.destination_encoding);
if (strcmp(ec->last_error.source_encoding,
- ec->source_encoding_name) != 0 ||
+ ec->source_encoding_name) == 0 &&
strcmp(ec->last_error.destination_encoding,
- ec->destination_encoding_name) != 0) {
- rb_str_catf(mesg, " in conversion from %s to %s",
- ec->source_encoding_name,
- ec->destination_encoding_name);
+ ec->destination_encoding_name) == 0) {
+ mesg = rb_sprintf("%s from %s to %s",
+ StringValueCStr(dumped),
+ ec->last_error.source_encoding,
+ ec->last_error.destination_encoding);
+ }
+ else {
+ int i;
+ mesg = rb_sprintf("%s to %s in conversion from %s",
+ StringValueCStr(dumped),
+ ec->last_error.destination_encoding,
+ ec->source_encoding_name);
+ for (i = 0; i < ec->num_trans; i++) {
+ const rb_transcoder *tr = ec->elems[i].tc->transcoder;
+ if (!DECORATOR_P(tr->src_encoding, tr->dst_encoding))
+ rb_str_catf(mesg, " to %s",
+ ec->elems[i].tc->transcoder->dst_encoding);
+ }
}
exc = rb_exc_new3(rb_eUndefinedConversionError, mesg);
idx = rb_enc_find_index(ec->last_error.source_encoding);