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

ruby-changes:37343

From: usa <ko1@a...>
Date: Tue, 27 Jan 2015 17:01:59 +0900 (JST)
Subject: [ruby-changes:37343] usa:r49424 (ruby_2_0_0): merge revision(s) 49244: [Backport #6232]

usa	2015-01-27 17:01:44 +0900 (Tue, 27 Jan 2015)

  New Revision: 49424

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

  Log:
    merge revision(s) 49244: [Backport #6232]
    
    * ext/readline/readline.c (readline_s_refresh_line): initialize
      before rl_refresh_line(), as some function make the internal
      state non-clean but rl_refresh_line() does not re-initialize it.
      [ruby-core:43957] [Bug #6232]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/readline/readline.c
    branches/ruby_2_0_0/test/readline/test_readline.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 49423)
+++ ruby_2_0_0/ChangeLog	(revision 49424)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Tue Jan 27 16:49:07 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/readline/readline.c (readline_s_refresh_line): initialize
+	  before rl_refresh_line(), as some function make the internal
+	  state non-clean but rl_refresh_line() does not re-initialize it.
+	  [ruby-core:43957] [Bug #6232]
+
 Tue Jan 27 16:41:33 2015  Seiei Higa  <hanachin@g...>
 
 	* vm_method.c (rb_export_method): bail out if the original method
Index: ruby_2_0_0/ext/readline/readline.c
===================================================================
--- ruby_2_0_0/ext/readline/readline.c	(revision 49423)
+++ ruby_2_0_0/ext/readline/readline.c	(revision 49424)
@@ -288,6 +288,34 @@ readline_get(VALUE prompt) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/readline/readline.c#L288
     return (VALUE)readline((char *)prompt);
 }
 
+static void
+prepare_readline(void)
+{
+    static int initialized = 0;
+    if (!initialized) {
+	rl_initialize();
+	initialized = 1;
+    }
+
+    if (readline_instream) {
+        rb_io_t *ifp;
+        rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
+        if (ifp->fd < 0) {
+            clear_rl_instream();
+            rb_raise(rb_eIOError, "closed readline input");
+        }
+    }
+
+    if (readline_outstream) {
+        rb_io_t *ofp;
+        rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
+        if (ofp->fd < 0) {
+            clear_rl_outstream();
+            rb_raise(rb_eIOError, "closed readline output");
+        }
+    }
+}
+
 /*
  * call-seq:
  *   Readline.readline(prompt = "", add_hist = false) -> string or nil
@@ -392,14 +420,7 @@ readline_readline(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/readline/readline.c#L420
 	prompt = RSTRING_PTR(tmp);
     }
 
-    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");
-	}
-    }
+    prepare_readline();
 
 #ifdef _WIN32
     rl_prep_terminal(1);
@@ -1455,6 +1476,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/readline/readline.c#L1476
 readline_s_refresh_line(VALUE self)
 {
     rb_secure(4);
+    prepare_readline();
     rl_refresh_line(0, 0);
     return Qnil;
 }
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 49423)
+++ ruby_2_0_0/version.h	(revision 49424)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2015-01-27"
-#define RUBY_PATCHLEVEL 619
+#define RUBY_PATCHLEVEL 620
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 1
Index: ruby_2_0_0/test/readline/test_readline.rb
===================================================================
--- ruby_2_0_0/test/readline/test_readline.rb	(revision 49423)
+++ ruby_2_0_0/test/readline/test_readline.rb	(revision 49424)
@@ -439,6 +439,18 @@ class TestReadline < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/readline/test_readline.rb#L439
     Readline::HISTORY.clear
   end if !/EditLine/n.match(Readline::VERSION)
 
+  def test_refresh_line
+    bug6232 = '[ruby-core:43957] [Bug #6232] refresh_line after set_screen_size'
+    with_temp_stdio do |stdin, stdout|
+      replace_stdio(stdin.path, stdout.path) do
+        assert_ruby_status(%w[-rreadline -], <<-'end;', bug6232)
+          Readline.set_screen_size(40, 80)
+          Readline.refresh_line
+        end;
+      end
+    end
+  end if Readline.respond_to?(:refresh_line)
+
   private
 
   def replace_stdio(stdin_path, stdout_path)

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49244


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

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