Skip to content

Commit 820605b

Browse files
committed
add tag v2_4_1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v2_4_1@58053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2 parents 44f76d0 + 7e81100 commit 820605b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ext/stringio/stringio.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,13 +767,15 @@ strio_ungetc(VALUE self, VALUE c)
767767

768768
check_modifiable(ptr);
769769
if (NIL_P(c)) return Qnil;
770-
if (FIXNUM_P(c)) {
771-
int cc = FIX2INT(c);
770+
if (RB_INTEGER_TYPE_P(c)) {
771+
int len, cc = NUM2INT(c);
772772
char buf[16];
773773

774774
enc = rb_enc_get(ptr->string);
775+
len = rb_enc_codelen(cc, enc);
776+
if (len <= 0) rb_enc_uint_chr(cc, enc);
775777
rb_enc_mbcput(cc, buf, enc);
776-
return strio_unget_bytes(ptr, buf, rb_enc_codelen(cc, enc));
778+
return strio_unget_bytes(ptr, buf, len);
777779
}
778780
else {
779781
SafeStringValue(c);

test/stringio/test_stringio.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ def test_ungetc
453453
f.ungetc("y".ord)
454454
assert_equal("y", f.getc)
455455
assert_equal("2", f.getc)
456+
457+
assert_raise(RangeError) {f.ungetc(0x1ffffff)}
458+
assert_raise(RangeError) {f.ungetc(0xffffffffffffff)}
456459
ensure
457460
f.close unless f.closed?
458461
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.4.1"
22
#define RUBY_RELEASE_DATE "2017-03-22"
3-
#define RUBY_PATCHLEVEL 110
3+
#define RUBY_PATCHLEVEL 111
44

55
#define RUBY_RELEASE_YEAR 2017
66
#define RUBY_RELEASE_MONTH 3

0 commit comments

Comments
 (0)