ruby-changes:26977
From: nobu <ko1@a...>
Date: Sun, 3 Feb 2013 16:54:29 +0900 (JST)
Subject: [ruby-changes:26977] nobu:r39029 (trunk): console.c: fix unit of min
nobu 2013-02-03 16:54:18 +0900 (Sun, 03 Feb 2013) New Revision: 39029 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39029 Log: console.c: fix unit of min * ext/io/console/console.c (rawmode_opt): min is minimum characters, not tenths. Modified files: trunk/ChangeLog trunk/ext/io/console/console.c trunk/test/io/console/test_io_console.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39028) +++ ChangeLog (revision 39029) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Feb 3 16:54:15 2013 Nobuyoshi Nakada <nobu@r...> + + * ext/io/console/console.c (rawmode_opt): min is minimum characters, + not tenths. + Sun Feb 3 16:13:00 2013 Charlie Somerville <charlie@c...> * doc/security.rdoc: add first cut at a Ruby security document Index: ext/io/console/console.c =================================================================== --- ext/io/console/console.c (revision 39028) +++ ext/io/console/console.c (revision 39029) @@ -105,13 +105,12 @@ rawmode_opt(int argc, VALUE *argv, rawmo https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L105 if (!NIL_P(vopts)) { VALUE vmin = rb_hash_aref(vopts, ID2SYM(rb_intern("min"))); VALUE vtime = rb_hash_aref(vopts, ID2SYM(rb_intern("time"))); - VALUE v10 = INT2FIX(10); if (!NIL_P(vmin)) { - vmin = rb_funcall3(vmin, '*', 1, &v10); opts->vmin = NUM2INT(vmin); optp = opts; } if (!NIL_P(vtime)) { + VALUE v10 = INT2FIX(10); vtime = rb_funcall3(vtime, '*', 1, &v10); opts->vtime = NUM2INT(vtime); optp = opts; Index: test/io/console/test_io_console.rb =================================================================== --- test/io/console/test_io_console.rb (revision 39028) +++ test/io/console/test_io_console.rb (revision 39029) @@ -25,6 +25,38 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L25 } end + def test_raw_minchar + len = 0 + th = nil + helper {|m, s| + th = Thread.start { + m.print("a") + len += 1 + sleep 2 + m.print("1234567890") + len += 10 + } + assert_equal(["a", 1], [s.getch(min: 1), len]) + } + ensure + th.kill if th and th.alive? + end + + def test_raw_timeout + len = 0 + th = nil + helper {|m, s| + th = Thread.start { + sleep 2 + m.print("a") + len += 1 + } + assert_equal([nil, 0], [s.getch(time: 0.1), len]) + } + ensure + th.kill if th and th.alive? + end + def test_cooked helper {|m, s| assert_send([s, :echo?]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/