aboutsummaryrefslogtreecommitdiffstats
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-19 16:59:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-19 16:59:22 +0000
commit91e5ba1cb865a2385d3e1cbfacd824496898e098 (patch)
tree7009858c75da37a1b66ae7c9e53f3da744e8c498 /sprintf.c
parent2510c468fff22b436f85381fe4ebe1485ab9a0ae (diff)
downloadruby-91e5ba1cb865a2385d3e1cbfacd824496898e098.tar.gz
* encoding.c (rb_enc_codepoint_len): combine rb_enc_codepoint()
and rb_enc_codelen() in one function to reduce calls. * encoding.c (rb_enc_codepoint): compatibility function. * sprintf.c (rb_str_format): use rb_enc_codepoint_len(). * string.c (rb_str_inspect, rb_str_upcase_bang, rb_str_downcase_bang, rb_str_capitalize_bang, rb_str_swapcase_bang, trnext, tr_trans, rb_str_delete_bang, rb_str_squeeze_bang, rb_str_count, rb_str_split_m, rb_str_each_line, rb_str_each_codepoint, rb_str_lstrip_bang, sym_printable): ditto. * transcode.c (make_econv_exception): use rb_enc_mbc_to_codepoint() git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index 5de2e45833..6cb024fdd2 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -625,12 +625,12 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
if (rb_enc_strlen(RSTRING_PTR(tmp),RSTRING_END(tmp),enc) != 1) {
rb_raise(rb_eArgError, "%%c requires a character");
}
- c = rb_enc_codepoint(RSTRING_PTR(tmp), RSTRING_END(tmp), enc);
+ c = rb_enc_codepoint_len(RSTRING_PTR(tmp), RSTRING_END(tmp), &n, enc);
}
else {
c = NUM2INT(val);
+ n = rb_enc_codelen(c, enc);
}
- n = rb_enc_codelen(c, enc);
if (n <= 0) {
rb_raise(rb_eArgError, "invalid character");
}