ruby-changes:10497
From: akr <ko1@a...>
Date: Thu, 5 Feb 2009 01:45:46 +0900 (JST)
Subject: [ruby-changes:10497] Ruby:r22049 (trunk): * transcode.c (make_econv_exception): refine error message for
akr 2009-02-05 01:45:31 +0900 (Thu, 05 Feb 2009) New Revision: 22049 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22049 Log: * transcode.c (make_econv_exception): refine error message for undefined conversion. [ruby-core:21828] Modified files: trunk/ChangeLog trunk/transcode.c Index: ChangeLog =================================================================== --- ChangeLog (revision 22048) +++ ChangeLog (revision 22049) @@ -1,3 +1,8 @@ +Thu Feb 5 01:44:02 2009 Tanaka Akira <akr@f...> + + * transcode.c (make_econv_exception): refine error message for + undefined conversion. [ruby-core:21828] + Thu Feb 5 01:18:25 2009 Tanaka Akira <akr@f...> * ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional. Index: transcode.c =================================================================== --- transcode.c (revision 22048) +++ transcode.c (revision 22049) @@ -2026,18 +2026,28 @@ } 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); if (0 <= idx) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/