summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-11 13:01:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-11 13:01:16 +0000
commita5d1da5d74560c812acb8db6242e389d2f27e368 (patch)
treede68d0fc565331c8eb8cea839e2878771c65f3c4 /sprintf.c
parent51f2207fc9be8b356601b5505dfdffef2db5e5dd (diff)
* sprintf.c (rb_str_format): fix exception message encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sprintf.c b/sprintf.c
index 44b8520..b9e40f4 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -119,11 +119,11 @@ sign_bits(int base, const char *p)
#define GETNTHARG(nth) \
(((nth) >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[(nth)])
-#define GETNAMEARG(id, name, len) ( \
+#define GETNAMEARG(id, name, len, enc) ( \
posarg > 0 ? \
- (rb_raise(rb_eArgError, "named%.*s after unnumbered(%d)", (len), (name), posarg), 0) : \
+ (rb_enc_raise((enc), rb_eArgError, "named%.*s after unnumbered(%d)", (len), (name), posarg), 0) : \
posarg == -1 ? \
- (rb_raise(rb_eArgError, "named%.*s after numbered", (len), (name)), 0) : \
+ (rb_enc_raise((enc), rb_eArgError, "named%.*s after numbered", (len), (name)), 0) : \
(posarg = -2, rb_hash_lookup2(get_hash(&hash, argc, argv), (id), Qundef)))
#define GETNUM(n, val) \
@@ -578,19 +578,20 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
if ((size_t)(p - start) >= INT_MAX) {
const int message_limit = 20;
len = (int)(rb_enc_right_char_head(start, start + message_limit, p, enc) - start);
- rb_raise(rb_eArgError, "too long name (%"PRIdSIZE" bytes) - %.*s...%c",
- (size_t)(p - start - 2), len, start, term);
+ rb_enc_raise(enc, rb_eArgError,
+ "too long name (%"PRIdSIZE" bytes) - %.*s...%c",
+ (size_t)(p - start - 2), len, start, term);
}
#endif
len = (int)(p - start + 1); /* including parenthesis */
if (id) {
- rb_raise(rb_eArgError, "named%.*s after <%s>",
- len, start, rb_id2name(id));
+ rb_enc_raise(enc, rb_eArgError, "named%.*s after <%s>",
+ len, start, rb_id2name(id));
}
id = rb_intern3(start + 1, len - 2 /* without parenthesis */, enc);
- nextvalue = GETNAMEARG(ID2SYM(id), start, len);
+ nextvalue = GETNAMEARG(ID2SYM(id), start, len, enc);
if (nextvalue == Qundef) {
- rb_raise(rb_eKeyError, "key%.*s not found", len, start);
+ rb_enc_raise(enc, rb_eKeyError, "key%.*s not found", len, start);
}
if (term == '}') goto format_s;
p++;