mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* transcode.c (make_econv_exception): refine error message for
undefined conversion. [ruby-core:21828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5127799e65
commit
b916afddc9
2 changed files with 24 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Feb 5 01:44:02 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* transcode.c (make_econv_exception): refine error message for
|
||||||
|
undefined conversion. [ruby-core:21828]
|
||||||
|
|
||||||
Thu Feb 5 01:18:25 2009 Tanaka Akira <akr@fsij.org>
|
Thu Feb 5 01:18:25 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional.
|
* ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional.
|
||||||
|
|
28
transcode.c
28
transcode.c
|
@ -2026,17 +2026,27 @@ make_econv_exception(rb_econv_t *ec)
|
||||||
}
|
}
|
||||||
if (dumped == Qnil)
|
if (dumped == Qnil)
|
||||||
dumped = rb_str_dump(bytes);
|
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,
|
if (strcmp(ec->last_error.source_encoding,
|
||||||
ec->source_encoding_name) != 0 ||
|
ec->source_encoding_name) == 0 &&
|
||||||
strcmp(ec->last_error.destination_encoding,
|
strcmp(ec->last_error.destination_encoding,
|
||||||
ec->destination_encoding_name) != 0) {
|
ec->destination_encoding_name) == 0) {
|
||||||
rb_str_catf(mesg, " in conversion from %s to %s",
|
mesg = rb_sprintf("%s from %s to %s",
|
||||||
ec->source_encoding_name,
|
StringValueCStr(dumped),
|
||||||
ec->destination_encoding_name);
|
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);
|
exc = rb_exc_new3(rb_eUndefinedConversionError, mesg);
|
||||||
idx = rb_enc_find_index(ec->last_error.source_encoding);
|
idx = rb_enc_find_index(ec->last_error.source_encoding);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue