1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

C90 for old versions

This commit is contained in:
Nobuyoshi Nakada 2019-07-10 03:02:01 +09:00
parent de4889ce5c
commit cc936402eb
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -807,25 +807,22 @@ strio_ungetbyte(VALUE self, VALUE c)
struct StringIO *ptr = readable(self); struct StringIO *ptr = readable(self);
check_modifiable(ptr); check_modifiable(ptr);
switch (TYPE(c)) { if (NIL_P(c)) return Qnil;
case T_NIL: if (RB_INTEGER_TYPE_P(c)) {
return Qnil;
case T_FIXNUM:
case T_BIGNUM: ;
/* rb_int_and() not visible from exts */ /* rb_int_and() not visible from exts */
VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff)); VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
const char cc = NUM2INT(v) & 0xFF; const char cc = NUM2INT(v) & 0xFF;
strio_unget_bytes(ptr, &cc, 1); strio_unget_bytes(ptr, &cc, 1);
return Qnil;
default:
SafeStringValue(c);
} }
else {
const char *cp = RSTRING_PTR(c); long cl;
long cl = RSTRING_LEN(c); SafeStringValue(c);
if (cl == 0) return Qnil; cl = RSTRING_LEN(c);
strio_unget_bytes(ptr, cp, cl); if (cl > 0) {
RB_GC_GUARD(c); strio_unget_bytes(ptr, RSTRING_PTR(c), cl);
RB_GC_GUARD(c);
}
}
return Qnil; return Qnil;
} }