[#30995] [Bug #3523] win32 exception c0000029 on exit using fibers — B Kelly <redmine@...>

Bug #3523: win32 exception c0000029 on exit using fibers

19 messages 2010/07/02

[#31100] [rubysoc] Queue C-extension patch to come — Ricardo Panaggio <panaggio.ricardo@...>

Hello,

26 messages 2010/07/07
[#31148] Re: [rubysoc] Queue C-extension patch to come — Roger Pack <rogerdpack2@...> 2010/07/09

> As this it my first patch to Ruby, I don't know where to begin with.

[#31320] Re: [rubysoc] Queue C-extension patch to come — Ricardo Panaggio <panaggio.ricardo@...> 2010/07/16

Sorry for leaving this thread for so long. I've tried to finish the

[#31322] Re: [rubysoc] Queue C-extension patch to come — Aaron Patterson <aaron@...> 2010/07/16

On Sat, Jul 17, 2010 at 06:55:35AM +0900, Ricardo Panaggio wrote:

[#31324] Re: [rubysoc] Queue C-extension patch to come — Caleb Clausen <vikkous@...> 2010/07/17

NB: I am Ricardo's mentor for this project.

[#31331] Re: [rubysoc] Queue C-extension patch to come — Benoit Daloze <eregontp@...> 2010/07/17

On 17 July 2010 06:00, Caleb Clausen <vikkous@gmail.com> wrote:

[#31332] Re: [rubysoc] Queue C-extension patch to come — Caleb Clausen <vikkous@...> 2010/07/17

On 7/17/10, Benoit Daloze <eregontp@gmail.com> wrote:

[#31138] Why is there no standard way of creating a String from a char *? — Nikolai Weibull <now@...>

Hi!

14 messages 2010/07/08
[#31146] Re: Why is there no standard way of creating a String from a char *? — Urabe Shyouhei <shyouhei@...> 2010/07/09

(2010/07/09 7:04), Nikolai Weibull wrote:

[#31149] Re: Why is there no standard way of creating a String from a char *? — Nikolai Weibull <now@...> 2010/07/09

On Fri, Jul 9, 2010 at 06:20, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:

[#31150] Re: Why is there no standard way of creating a String from a char *? — Urabe Shyouhei <shyouhei@...> 2010/07/09

(2010/07/09 18:28), Nikolai Weibull wrote:

[#31217] [Bug #3562] regression in respond_to? — Aaron Patterson <redmine@...>

Bug #3562: regression in respond_to?

14 messages 2010/07/12

[#31269] [Bug #3566] memory leak when spawning+joining Threads in a loop — Eric Wong <redmine@...>

Bug #3566: memory leak when spawning+joining Threads in a loop

14 messages 2010/07/13

[#31399] [Backport #3595] Theres no encoding to differentiate a stream of Binary data from an 8-Bit ASCII string — Dreamcat Four <redmine@...>

Backport #3595: Theres no encoding to differentiate a stream of Binary data from an 8-Bit ASCII string

17 messages 2010/07/21

[#31459] [Bug #3607] [trunk/r28731] Gem.path has disappeared? — Ollivier Robert <redmine@...>

Bug #3607: [trunk/r28731] Gem.path has disappeared?

22 messages 2010/07/23

[#31519] [Bug #3622] Net::HTTP does not wait to send request body with Expect: 100-continue — Eric Hodel <redmine@...>

Bug #3622: Net::HTTP does not wait to send request body with Expect: 100-continue

9 messages 2010/07/28

[ruby-core:31510] Re: [Feature #3616] IRB + readline incorrectly counts non-printing characters in prompt

From: Nobuyoshi Nakada <nobu@...>
Date: 2010-07-27 01:45:45 UTC
List: ruby-core #31510
Hi,

At Tue, 27 Jul 2010 08:34:08 +0900,
Sung Pae wrote in [ruby-core:31509]:
> Yes, I agree. That is very ugly. I think it's appropriate to simply surround all
> terminal escape sequences with the special RL values. Also, \001 and \002 do not
> seem to affect libedit at all.

OK.  I'll yield this ticket to the maintainer of ext/readline.


diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 3ecea94..9b154bc 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -43,10 +43,20 @@
 static VALUE mReadline;
 
 #define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper"
+#ifndef USE_INSERT_IGNORE_ESCAPE
+# ifndef HAVE_EDITLINE_READLINE_H
+#  define USE_INSERT_IGNORE_ESCAPE 1
+# else
+#  define USE_INSERT_IGNORE_ESCAPE 0
+# endif
+#endif
 
 #define COMPLETION_PROC "completion_proc"
 #define COMPLETION_CASE_FOLD "completion_case_fold"
 static ID completion_proc, completion_case_fold;
+#if USE_INSERT_IGNORE_ESCAPE
+static ID id_orig_prompt, id_last_prompt;
+#endif
 
 #ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
 # define rl_filename_completion_function filename_completion_function
@@ -145,6 +155,81 @@ readline_event(void)
 }
 #endif
 
+#if USE_INSERT_IGNORE_ESCAPE
+static VALUE
+insert_ignore_escape(VALUE self, VALUE prompt)
+{
+    VALUE last_prompt, orig_prompt = rb_attr_get(self, id_orig_prompt);
+    int ignoring = 0;
+    const char *s0, *s, *e;
+    long len;
+    static const char ignore_code[2] = {RL_PROMPT_START_IGNORE, RL_PROMPT_END_IGNORE};
+
+    prompt = rb_str_new_shared(prompt);
+    last_prompt = rb_attr_get(self, id_last_prompt);
+    if (orig_prompt == prompt) return last_prompt;
+    len = RSTRING_LEN(prompt);
+    if (NIL_P(last_prompt)) {
+	last_prompt = rb_str_tmp_new(len);
+    }
+
+    s = s0 = RSTRING_PTR(prompt);
+    e = s0 + len;
+    rb_str_set_len(last_prompt, 0);
+    while (s < e && *s) {
+	switch (*s) {
+	  case RL_PROMPT_START_IGNORE:
+	    ignoring = -1;
+	    rb_str_cat(last_prompt, s0, ++s - s0);
+	    s0 = s;
+	    break;
+	  case RL_PROMPT_END_IGNORE:
+	    ignoring = 0;
+	    rb_str_cat(last_prompt, s0, ++s - s0);
+	    s0 = s;
+	    break;
+	  case '\033':
+	    if (++s < e && *s == '[') {
+		rb_str_cat(last_prompt, s0, s - s0 - 1);
+		s0 = s - 1;
+		while (++s < e && *s) {
+		    if (ISALPHA(*s)) {
+			if (!ignoring) {
+			    ignoring = 1;
+			    rb_str_cat(last_prompt, ignore_code+0, 1);
+			}
+			rb_str_cat(last_prompt, s0, ++s - s0);
+			s0 = s;
+			break;
+		    }
+		    else if (!('0' <= *s && *s <= '9' || *s == ';')) {
+			break;
+		    }
+		}
+	    }
+	    break;
+	  default:
+	    if (ignoring > 0) {
+		ignoring = 0;
+		rb_str_cat(last_prompt, ignore_code+1, 1);
+	    }
+	    s++;
+	    break;
+	}
+    }
+    if (ignoring > 0) {
+	ignoring = 0;
+	rb_str_cat(last_prompt, ignore_code+1, 1);
+    }
+    rb_str_cat(last_prompt, s0, s - s0);
+
+    rb_ivar_set(self, id_orig_prompt, prompt);
+    rb_ivar_set(self, id_last_prompt, last_prompt);
+
+    return last_prompt;
+}
+#endif
+
 static VALUE
 readline_get(VALUE prompt)
 {
@@ -248,6 +333,10 @@ readline_readline(int argc, VALUE *argv, VALUE self)
     rb_secure(4);
     if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
 	OutputStringValue(tmp);
+#if USE_INSERT_IGNORE_ESCAPE
+	tmp = insert_ignore_escape(self, tmp);
+	rb_str_locktmp(tmp);
+#endif
 	prompt = RSTRING_PTR(tmp);
     }
 
@@ -257,6 +346,11 @@ readline_readline(int argc, VALUE *argv, VALUE self)
     rl_prep_terminal(1);
 #endif
     buff = (char*)rb_protect(readline_get, (VALUE)prompt, &status);
+#if USE_INSERT_IGNORE_ESCAPE
+    if (prompt) {
+	rb_str_unlocktmp(tmp);
+    }
+#endif
     if (status) {
 #if defined HAVE_RL_CLEANUP_AFTER_SIGNAL
         /* restore terminal mode and signal handler*/
@@ -1381,6 +1475,11 @@ Init_readline()
     rb_define_singleton_method(mReadline, "refresh_line",
 			       readline_s_refresh_line, 0);
 
+#if USE_INSERT_IGNORE_ESCAPE
+    CONST_ID(id_orig_prompt, "orig_prompt");
+    CONST_ID(id_last_prompt, "last_prompt");
+#endif
+
     history = rb_obj_alloc(rb_cObject);
     rb_extend_object(history, rb_mEnumerable);
     rb_define_singleton_method(history,"to_s", hist_to_s, 0);


-- 
Nobu Nakada

In This Thread