diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-18 01:43:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-18 01:43:00 +0000 |
commit | e2ad92a075bdcbffcae9afbb7dab9918f690fa14 (patch) | |
tree | 93080cd931ecdee3240a3b327c482da93d15b80e /ext/readline | |
parent | 90e812e81be93946a63f613e08e99a2508e39aa2 (diff) | |
download | ruby-e2ad92a075bdcbffcae9afbb7dab9918f690fa14.tar.gz |
ext/readline/readline.c: [Bug #6601]
* ext/readline/readline.c (readline_getc): deal with ESC just followed
by ASCII as meta prefix in incremental search mode. based on the
patch from rctay (Tay Ray Chuan) at [ruby-core:45682]. [Bug #6601]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/readline')
-rw-r--r-- | ext/readline/readline.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 3b1a6c1d6a..07c9268bb5 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -130,7 +130,6 @@ static char **readline_attempted_completion_function(const char *text, #if defined HAVE_RL_GETC_FUNCTION static VALUE readline_instream; -static ID id_getbyte; #ifndef HAVE_RL_GETC #define rl_getc(f) EOF @@ -173,9 +172,19 @@ readline_getc(FILE *input) } } #endif - c = rb_funcall(readline_instream, id_getbyte, 0, 0); + c = rb_io_getbyte(readline_instream); if (NIL_P(c)) return EOF; - return NUM2CHR(c); + if (c == INT2FIX(ESC) && + RL_ISSTATE(RL_STATE_ISEARCH) && /* isn't needed in other states? */ + rb_io_read_pending(ifp)) { + int meta = 0; + c = rb_io_getbyte(readline_instream); + if (FIXNUM_P(c) && isascii(FIX2INT(c))) meta = 1; + rb_io_ungetbyte(readline_instream, c); + if (meta) rl_execute_next(ESC); + return ESC; + } + return FIX2INT(c); } #elif defined HAVE_RL_EVENT_HOOK #define BUSY_WAIT 0 @@ -1703,7 +1712,6 @@ Init_readline() /* and using_history() call rl_initialize(). */ /* This assignment should be placed before using_history() */ rl_getc_function = readline_getc; - id_getbyte = rb_intern_const("getbyte"); #elif defined HAVE_RL_EVENT_HOOK rl_event_hook = readline_event; #endif |