summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 06:37:27 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 06:37:27 +0000
commit7587eb706a593f1728fcc0f3c4480856159e5d2a (patch)
tree9317224b226db60a0341ac0b70b970b8ca6690e6 /io.c
parent0a8f047a983deaf853e8ddc9f70da78f3a83f9ef (diff)
* io.c (rb_io_ungetc): use unsigned int for GB18030.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/io.c b/io.c
index 7625796b2b..cb1997a486 100644
--- a/io.c
+++ b/io.c
@@ -3229,12 +3229,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);
}