ruby-changes:21577
From: naruse <ko1@a...>
Date: Fri, 4 Nov 2011 01:24:09 +0900 (JST)
Subject: [ruby-changes:21577] naruse:r33626 (trunk): * ext/readline/readline.c (Init_readline): like r18313, libedit's
naruse 2011-11-04 01:23:58 +0900 (Fri, 04 Nov 2011) New Revision: 33626 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33626 Log: * ext/readline/readline.c (Init_readline): like r18313, libedit's replace_history_entry may use offset instead of which. so introduce history_replace_offset_func and initialize it. * ext/readline/readline.c (hist_set): use history_replace_offset_func. Modified files: trunk/ChangeLog trunk/ext/readline/readline.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33625) +++ ChangeLog (revision 33626) @@ -1,3 +1,11 @@ +Fri Nov 4 01:04:48 2011 NARUSE, Yui <naruse@r...> + + * ext/readline/readline.c (Init_readline): like r18313, libedit's + replace_history_entry may use offset instead of which. + so introduce history_replace_offset_func and initialize it. + + * ext/readline/readline.c (hist_set): use history_replace_offset_func. + Fri Nov 4 00:53:35 2011 NARUSE, Yui <naruse@r...> * ext/readline/readline.c (Init_readline): fix wrong condition. Index: ext/readline/readline.c =================================================================== --- ext/readline/readline.c (revision 33625) +++ ext/readline/readline.c (revision 33626) @@ -69,6 +69,7 @@ #endif static int (*history_get_offset_func)(int); +static int (*history_replace_offset_func)(int); static char **readline_attempted_completion_function(const char *text, int start, int end); @@ -1299,7 +1300,7 @@ i += history_length; } if (i >= 0) { - entry = replace_history_entry(i, RSTRING_PTR(str), NULL); + entry = replace_history_entry(history_replace_offset_func(i), RSTRING_PTR(str), NULL); } if (entry == NULL) { rb_raise(rb_eIndexError, "invalid index"); @@ -1604,6 +1605,7 @@ */ rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp); history_get_offset_func = history_get_offset_history_base; + history_replace_offset_func = history_get_offset_0; #if defined HAVE_RL_LIBRARY_VERSION version = rb_str_new_cstr(rl_library_version); #if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY @@ -1613,7 +1615,12 @@ if (history_get(history_get_offset_func(0)) == NULL) { history_get_offset_func = history_get_offset_0; } -#if defined HAVE_CLEAR_HISTORY +#ifdef HAVE_REPLACE_HISTORY_ENTRY + if (replace_history_entry(0, "a", NULL) == NULL) { + history_replace_offset_func = history_get_offset_history_base; + } +#endif +#ifdef HAVE_CLEAR_HISTORY clear_history(); #else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/