summaryrefslogtreecommitdiffstats
path: root/ext/iconv
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-27 23:40:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-27 23:40:32 +0000
commit544477a7b0e4f5ecd2dda6445ad996c33b1457a8 (patch)
tree011aad2c623b3bd6cac457b48dadfcf83d6c808c /ext/iconv
parentcff45b3de1cb4268df2396be14d3d3b0b43630f9 (diff)
downloadruby-544477a7b0e4f5ecd2dda6445ad996c33b1457a8.tar.gz
ruby-544477a7b0e4f5ecd2dda6445ad996c33b1457a8.tar.xz
ruby-544477a7b0e4f5ecd2dda6445ad996c33b1457a8.zip
* ext/iconv/iconv.c (iconv_create): Iconv::Failure requires 3
arguments. (pointed out by NaHi) git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@8201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/iconv.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index ed4db1499..00db78194 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -169,14 +169,17 @@ iconv_create
}
if (cd == (iconv_t)-1) {
int inval = errno == EINVAL;
- volatile VALUE msg = rb_str_new2("iconv(\"" + (inval ? 5 : 0));
- char *s;
-
- rb_str_buf_cat2(rb_str_buf_append(msg, to), "\", \"");
- rb_str_buf_cat2(rb_str_buf_append(msg, from), "\")");
- s = StringValuePtr(msg);
+ char *s = inval ? "invalid encoding " : "iconv";
+ volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
+ RSTRING(from)->len + 8);
+
+ sprintf(RSTRING(msg)->ptr, "%s(\"%s\", \"%s\")",
+ s, RSTRING(to)->ptr, RSTRING(from)->ptr);
+ s = RSTRING(msg)->ptr;
+ RSTRING(msg)->len = strlen(s);
if (!inval) rb_sys_fail(s);
- rb_raise(rb_eIconvInvalidEncoding, "invalid encoding %s", s);
+ iconv_fail(rb_eIconvInvalidEncoding,
+ Qnil, rb_ary_new3(2, to, from), NULL, s);
}
}