[前][次][番号順一覧][スレッド一覧]

ruby-changes:56408

From: Nobuyoshi <ko1@a...>
Date: Wed, 10 Jul 2019 03:03:49 +0900 (JST)
Subject: [ruby-changes:56408] Nobuyoshi Nakada: cc936402eb (master): C90 for old versions

https://git.ruby-lang.org/ruby.git/commit/?id=cc936402eb

From cc936402eb60fc0ccdafd47dc1e4f6f8ae0c4b9c Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 10 Jul 2019 03:02:01 +0900
Subject: C90 for old versions


diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 4c135ef..bfe1700 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -807,25 +807,22 @@ strio_ungetbyte(VALUE self, VALUE c) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L807
     struct StringIO *ptr = readable(self);
 
     check_modifiable(ptr);
-    switch (TYPE(c)) {
-      case T_NIL:
-        return Qnil;
-      case T_FIXNUM:
-      case T_BIGNUM: ;
+    if (NIL_P(c)) return Qnil;
+    if (RB_INTEGER_TYPE_P(c)) {
         /* rb_int_and() not visible from exts */
         VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
         const char cc = NUM2INT(v) & 0xFF;
         strio_unget_bytes(ptr, &cc, 1);
-        return Qnil;
-      default:
-        SafeStringValue(c);
     }
-
-    const char *cp = RSTRING_PTR(c);
-    long cl = RSTRING_LEN(c);
-    if (cl == 0) return Qnil;
-    strio_unget_bytes(ptr, cp, cl);
-    RB_GC_GUARD(c);
+    else {
+	long cl;
+	SafeStringValue(c);
+	cl = RSTRING_LEN(c);
+	if (cl > 0) {
+	    strio_unget_bytes(ptr, RSTRING_PTR(c), cl);
+	    RB_GC_GUARD(c);
+	}
+    }
     return Qnil;
 }
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]