From df44ade694ffa28e8c72c7f8b699e3aa0af2c9a3 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 17 Dec 2007 05:01:47 +0000 Subject: * string.c (tr_find): wrong condition fixed. * sprintf.c (rb_str_format): check encoding based on result, not the format string. * string.c (rb_str_upto): add encoding check. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sprintf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sprintf.c') diff --git a/sprintf.c b/sprintf.c index 0835dab3d..f005ad6af 100644 --- a/sprintf.c +++ b/sprintf.c @@ -296,6 +296,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) blen = 0; bsiz = 120; result = rb_str_buf_new(bsiz); + rb_enc_copy(result, fmt); buf = RSTRING_PTR(result); for (; p < end; p++) { @@ -459,7 +460,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) str = rb_obj_as_string(arg); if (OBJ_TAINTED(str)) tainted = 1; len = RSTRING_LEN(str); - enc = rb_enc_check(fmt, str); + enc = rb_enc_check(result, str); if (flags&(FPREC|FWIDTH)) { slen = rb_enc_strlen(RSTRING_PTR(str),RSTRING_END(str),enc); if (slen < 0) { @@ -497,6 +498,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) } } PUSH(RSTRING_PTR(str), len); + rb_enc_associate(result, enc); } break; -- cgit