summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-22 05:54:46 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-22 05:54:46 +0000
commit820605ba3c10b9f4dafc4e5d6e09765b8b31cbea (patch)
treec64a390a1ebe2bca0d45e5b3c336978d216873cb
parent44f76d04205ef336cc9d621bcb04426034307f0e (diff)
parent7e811007e22fd8074200e7f302e14542043718a7 (diff)
add tag v2_4_1v2_4_1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v2_4_1@58053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/stringio/stringio.c8
-rw-r--r--test/stringio/test_stringio.rb3
-rw-r--r--version.h2
3 files changed, 9 insertions, 4 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index fb2eddaa7e..1e464bc9d1 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -767,13 +767,15 @@ strio_ungetc(VALUE self, VALUE c)
check_modifiable(ptr);
if (NIL_P(c)) return Qnil;
- if (FIXNUM_P(c)) {
- int cc = FIX2INT(c);
+ if (RB_INTEGER_TYPE_P(c)) {
+ int len, cc = NUM2INT(c);
char buf[16];
enc = rb_enc_get(ptr->string);
+ len = rb_enc_codelen(cc, enc);
+ if (len <= 0) rb_enc_uint_chr(cc, enc);
rb_enc_mbcput(cc, buf, enc);
- return strio_unget_bytes(ptr, buf, rb_enc_codelen(cc, enc));
+ return strio_unget_bytes(ptr, buf, len);
}
else {
SafeStringValue(c);
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index d4df7b2617..667fe3ea81 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -453,6 +453,9 @@ class TestStringIO < Test::Unit::TestCase
f.ungetc("y".ord)
assert_equal("y", f.getc)
assert_equal("2", f.getc)
+
+ assert_raise(RangeError) {f.ungetc(0x1ffffff)}
+ assert_raise(RangeError) {f.ungetc(0xffffffffffffff)}
ensure
f.close unless f.closed?
end
diff --git a/version.h b/version.h
index c62731790e..36977a1fa8 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.1"
#define RUBY_RELEASE_DATE "2017-03-22"
-#define RUBY_PATCHLEVEL 110
+#define RUBY_PATCHLEVEL 111
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3