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

ruby-changes:45209

From: nobu <ko1@a...>
Date: Sun, 8 Jan 2017 08:02:34 +0900 (JST)
Subject: [ruby-changes:45209] nobu:r57282 (trunk): console.c: unpaired size

nobu	2017-01-08 08:02:29 +0900 (Sun, 08 Jan 2017)

  New Revision: 57282

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57282

  Log:
    console.c: unpaired size
    
    * ext/io/console/console.c (console_set_winsize): reject unpaired
      pixel size.

  Modified files:
    trunk/ext/io/console/console.c
    trunk/test/io/console/test_io_console.rb
Index: test/io/console/test_io_console.rb
===================================================================
--- test/io/console/test_io_console.rb	(revision 57281)
+++ test/io/console/test_io_console.rb	(revision 57282)
@@ -257,6 +257,7 @@ defined?(PTY) and defined?(IO.console) a https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L257
         else
           assert(false, "winsize on #{path} succeed: #{s.inspect}")
         end
+        assert_raise(ArgumentError) {io.winsize = [0, 0, 0]}
       end
     end
   end
Index: ext/io/console/console.c
===================================================================
--- ext/io/console/console.c	(revision 57281)
+++ ext/io/console/console.c	(revision 57282)
@@ -535,11 +535,15 @@ console_set_winsize(VALUE io, VALUE size https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L535
     VALUE row, col, xpixel, ypixel;
     const VALUE *sz;
     int fd;
-    int sizelen;
+    long sizelen;
 
     GetOpenFile(io, fptr);
     size = rb_Array(size);
-    rb_check_arity(sizelen = RARRAY_LENINT(size), 2, 4);
+    if ((sizelen = RARRAY_LEN(size)) != 2 && sizelen != 4) {
+	rb_raise(rb_eArgError,
+		 "wrong number of arguments (given %ld, expected 2 or 4)",
+		 sizelen);
+    }
     sz = RARRAY_CONST_PTR(size);
     row = sz[0], col = sz[1], xpixel = ypixel = Qnil;
     if (sizelen == 4) xpixel = sz[2], ypixel = sz[3];

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

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