diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-17 16:18:56 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-17 16:18:56 +0000 |
commit | 4a3fffdccbfbf348d23d2192c81b81b3fe5b5405 (patch) | |
tree | c5ad114e73db2ac4f933c59a424c7c87f6883385 /ext/readline/readline.c | |
parent | edf7bc24641f9ba9bc9f2fa58f2012d179cb78f3 (diff) | |
download | ruby-4a3fffdccbfbf348d23d2192c81b81b3fe5b5405.tar.gz |
* 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
Diffstat (limited to 'ext/readline/readline.c')
-rw-r--r-- | ext/readline/readline.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 970a4afa26..0102ddc4cd 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -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) { @@ -100,6 +96,32 @@ readline_readline(argc, argv, self) } 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; VALUE proc; @@ -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", |