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

* ext/readline/readline.c (readline_readline): do not set rl_{in,out}stream.

* ext/readline/readline.c (readline_s_set_input): new method.
* ext/readline/readline.c (readline_s_set_output): new method.
* lib/irb/input-method.rb: set Readline.input and Readline.output.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2005-06-17 16:18:56 +00:00
parent edf7bc2464
commit 4a3fffdccb
4 changed files with 45 additions and 4 deletions

View file

@ -1,3 +1,14 @@
Sat Jun 18 01:15:36 2005 Shugo Maeda <shugo@ruby-lang.org>
* ext/readline/readline.c (readline_readline): do not set
rl_{in,out}stream.
* ext/readline/readline.c (readline_s_set_input): new method.
* ext/readline/readline.c (readline_s_set_output): new method.
* lib/irb/input-method.rb: set Readline.input and Readline.output.
Fri Jun 17 13:01:40 2005 Tanaka Akira <akr@m17n.org>
* lib/time.rb (Time.parse): fix previous leap seconds support.

View file

@ -69,10 +69,6 @@ readline_readline(argc, argv, self)
if (!isatty(0) && errno == EBADF) rb_raise(rb_eIOError, "stdin closed");
GetOpenFile(rb_stdout, ofp);
rl_outstream = rb_io_stdio_file(ofp);
GetOpenFile(rb_stdin, ifp);
rl_instream = rb_io_stdio_file(ifp);
buff = (char*)rb_protect((VALUE(*)_((VALUE)))readline, (VALUE)prompt,
&status);
if (status) {
@ -99,6 +95,32 @@ readline_readline(argc, argv, self)
return result;
}
static VALUE
readline_s_set_input(self, input)
VALUE self, input;
{
OpenFile *ifp;
rb_secure(4);
Check_Type(input, T_FILE);
GetOpenFile(input, ifp);
rl_instream = rb_io_stdio_file(ifp);
return input;
}
static VALUE
readline_s_set_output(self, output)
VALUE self, output;
{
OpenFile *ofp;
rb_secure(4);
Check_Type(output, T_FILE);
GetOpenFile(output, ofp);
rl_outstream = rb_io_stdio_file(ofp);
return output;
}
static VALUE
readline_s_set_completion_proc(self, proc)
VALUE self;
@ -736,6 +758,10 @@ Init_readline()
mReadline = rb_define_module("Readline");
rb_define_module_function(mReadline, "readline",
readline_readline, -1);
rb_define_singleton_method(mReadline, "input=",
readline_s_set_input, 1);
rb_define_singleton_method(mReadline, "output=",
readline_s_set_output, 1);
rb_define_singleton_method(mReadline, "completion_proc=",
readline_s_set_completion_proc, 1);
rb_define_singleton_method(mReadline, "completion_proc",

View file

@ -94,6 +94,8 @@ module IRB
end
def gets
Readline.input = STDIN
Readline.output = STDOUT
if l = readline(@prompt, false)
HISTORY.push(l) if !l.empty?
@line[@line_no += 1] = l + "\n"

View file

@ -67,6 +67,8 @@ class TestReadline < Test::Unit::TestCase
STDIN.reopen(stdin_path, "r")
STDOUT.reopen(stdout_path, "w")
begin
Readline.input = STDIN
Readline.output = STDOUT
yield
ensure
STDIN.reopen(orig_stdin)