Module Name: src
Committed By: christos
Date: Sun May 8 20:15:00 UTC 2016
Modified Files:
src/lib/libedit: readline.c
Log Message:
In stiffle_history(), trim excessive entries from the history and advance
history_base like the GNU implementation does. (from Bastian Maerkisch)
To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/lib/libedit/readline.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.129 src/lib/libedit/readline.c:1.130
--- src/lib/libedit/readline.c:1.129 Fri May 6 17:01:19 2016
+++ src/lib/libedit/readline.c Sun May 8 16:15:00 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.129 2016/05/06 21:01:19 christos Exp $ */
+/* $NetBSD: readline.c,v 1.130 2016/05/08 20:15:00 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.129 2016/05/06 21:01:19 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.130 2016/05/08 20:15:00 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -1168,12 +1168,24 @@ void
stifle_history(int max)
{
HistEvent ev;
+ HIST_ENTRY *he;
+ int i, len;
if (h == NULL || e == NULL)
rl_initialize();
- if (history(h, &ev, H_SETSIZE, max) == 0)
+ len = history_length;
+ if (history(h, &ev, H_SETSIZE, max) == 0) {
max_input_history = max;
+ if (max < len)
+ history_base += len - max;
+ for (i = 0; i < len - max; i++) {
+ he = remove_history(i);
+ el_free(he->data);
+ el_free((void *)(unsigned long)he->line);
+ el_free(he);
+ }
+ }
}