* ext/nkf/nkf.c (rb_nkf_convert): suppress warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-09-14 16:07:49 +00:00
parent 00fb59f19a
commit 1aab4196fa
2 changed files with 18 additions and 9 deletions

View File

@ -1,3 +1,7 @@
Sat Sep 15 00:20:04 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf.c (rb_nkf_convert): suppress warning.
Fri Sep 14 04:05:00 2012 Zachary Scott <zzak@ruby-lang.org> Fri Sep 14 04:05:00 2012 Zachary Scott <zzak@ruby-lang.org>
* array.c (rb_ary_diff, rb_ary_uniq): * array.c (rb_ary_diff, rb_ary_uniq):

View File

@ -135,7 +135,7 @@ int nkf_split_options(const char *arg)
static VALUE static VALUE
rb_nkf_convert(VALUE obj, VALUE opt, VALUE src) rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
{ {
volatile VALUE tmp; VALUE tmp;
reinit(); reinit();
StringValue(opt); StringValue(opt);
nkf_split_options(RSTRING_PTR(opt)); nkf_split_options(RSTRING_PTR(opt));
@ -156,23 +156,28 @@ rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
StringValue(src); StringValue(src);
input = (unsigned char *)RSTRING_PTR(src); input = (unsigned char *)RSTRING_PTR(src);
i_len = RSTRING_LENINT(src); i_len = RSTRING_LENINT(src);
tmp = result = rb_str_new(0, i_len*3 + 10); tmp = rb_str_new(0, i_len*3 + 10);
output_ctr = 0; output_ctr = 0;
output = (unsigned char *)RSTRING_PTR(result); output = (unsigned char *)RSTRING_PTR(tmp);
o_len = RSTRING_LENINT(result); o_len = RSTRING_LENINT(tmp);
*output = '\0'; *output = '\0';
/* use _result_ begin*/
result = tmp;
kanji_convert(NULL); kanji_convert(NULL);
rb_str_set_len(result, output_ctr); result = Qnil;
OBJ_INFECT(result, src); /* use _result_ end */
rb_str_set_len(tmp, output_ctr);
OBJ_INFECT(tmp, src);
if (mimeout_f) if (mimeout_f)
rb_enc_associate(result, rb_usascii_encoding()); rb_enc_associate(tmp, rb_usascii_encoding());
else else
rb_enc_associate(result, rb_nkf_enc_get(nkf_enc_name(output_encoding))); rb_enc_associate(tmp, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
return result; return tmp;
} }