зеркало из https://github.com/github/ruby.git
* ext/readline/readline.c (readline_readline): check if outstream
is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
8397134330
Коммит
1dec79c324
|
@ -1,3 +1,9 @@
|
|||
Sat Dec 24 10:56:32 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/readline/readline.c (readline_readline): check if outstream
|
||||
is closed to get rid of a bug of readline 6. [ruby-dev:45043]
|
||||
[Bug #5803]
|
||||
|
||||
Sat Dec 24 06:59:49 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* test/readline/test_readline.rb (test_line_buffer__point): use
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
static VALUE mReadline;
|
||||
|
||||
#define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper"
|
||||
|
@ -372,6 +376,13 @@ readline_readline(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
if (!isatty(fileno(rl_instream)) && errno == EBADF) rb_raise(rb_eIOError, "closed stdin");
|
||||
if (rl_outstream) {
|
||||
struct stat stbuf;
|
||||
int fd = fileno(rl_outstream);
|
||||
if (fd < 0 || fstat(fd, &stbuf) != 0) {
|
||||
rb_raise(rb_eIOError, "closed stdout");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
rl_prep_terminal(1);
|
||||
|
|
|
@ -303,6 +303,16 @@ class TestReadline < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_closed_outstream
|
||||
bug5803 = '[ruby-dev:45043]'
|
||||
IO.pipe do |r, w|
|
||||
Readline.input = r
|
||||
Readline.output = w
|
||||
(w << "##\t").close
|
||||
assert_raise(IOError, bug5803) {Readline.readline}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def replace_stdio(stdin_path, stdout_path)
|
||||
|
|
Загрузка…
Ссылка в новой задаче