summaryrefslogtreecommitdiff
path: root/ext/readline
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-03 16:23:58 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-03 16:23:58 +0000
commitb2f90f4d511082c219ba446afce59d55d26d8280 (patch)
tree4f11e6161eba50e78cc1acdf5292aabe2e0e3437 /ext/readline
parent21ab6bc3fa7f586a4605778e30730df21ce0b691 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/readline')
-rw-r--r--ext/readline/readline.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index e34ee1e..e0f0d1c 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -69,6 +69,7 @@ static ID id_orig_prompt, id_last_prompt;
#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 @@ hist_set(VALUE self, VALUE index, VALUE str)
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 @@ Init_readline()
*/
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 @@ Init_readline()
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
{