diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-02 08:06:46 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-02 08:06:46 +0000 |
commit | 230b8b524da27baaee1ded6bfc8bdef842940400 (patch) | |
tree | 5a1dfb3ad743ee6958bb43efc437ac0ed260a8fe /io.c | |
parent | 55eecb54e79260379480dacb13272b10699ec5a8 (diff) |
merges r29446 and r29448 from trunk into ruby_1_9_2.
--
* numeric.c (rb_enc_uint_chr): split from int_chr.
* numeric.c (int_chr): use rb_enc_uint_chr.
* include/ruby/encoding.h (rb_enc_uint_chr): added.
--
* io.c (rb_io_ungetc): use unsigned int for GB18030.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -3193,12 +3193,13 @@ rb_io_ungetc(VALUE io, VALUE c) rb_io_check_char_readable(fptr); if (NIL_P(c)) return Qnil; if (FIXNUM_P(c)) { - int cc = FIX2INT(c); - rb_encoding *enc = io_read_encoding(fptr); - char buf[16]; - - c = rb_str_new(buf, rb_enc_mbcput(cc, buf, enc)); + c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr)); } +#if SIZEOF_LONG > SIZEOF_INT + else if (TYPE(c) == T_BIGNUM) { + c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr)); + } +#endif else { SafeStringValue(c); } |