* [PATCH/RFA] Fix operate-and-get-next when history list is full
@ 2002-08-17 3:03 Mark Kettenis
2002-08-17 17:02 ` Elena Zannoni
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2002-08-17 3:03 UTC (permalink / raw)
To: ezannoni; +Cc: gdb-patches
Hi Elena,
The attached patch fixes a problem with operate-and-get-next when the
history list is full. In that case, when executing a command, the
oldest entry is removed from the history, all other entries are moved
"up", and a new entry is put at the end of the list. In that case we
shouldn't increase the current line by one the find the next line.
bash contains similar code as my patch adds.
OK to apply?
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* top.c (gdb_rl_operate_and_get_next): Make sure
operate-and-get-next functions correctly even when the history
list is completely filled.
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.65
diff -u -p -r1.65 top.c
--- top.c 24 Jul 2002 17:58:46 -0000 1.65
+++ top.c 17 Aug 2002 09:58:17 -0000
@@ -1082,6 +1082,8 @@ gdb_rl_operate_and_get_next_completion (
static int
gdb_rl_operate_and_get_next (int count, int key)
{
+ int where;
+
if (event_loop_p)
{
/* Use the async hook. */
@@ -1094,8 +1096,20 @@ gdb_rl_operate_and_get_next (int count,
rl_pre_input_hook = (Function *) gdb_rl_operate_and_get_next_completion;
}
- /* Add 1 because we eventually want the next line. */
- operate_saved_history = where_history () + 1;
+ /* Find the current line, and find the next line to use. */
+ where = where_history();
+
+ /* FIXME: kettenis/20020817: max_input_history is renamed into
+ history_max_entries in readline-4.2. When we do a new readline
+ import, we should probably change it here too, even though
+ readline maintains backwards compatibility for now by still
+ defining max_input_history. */
+ if ((history_is_stifled () && (history_length >= max_input_history)) ||
+ (where >= history_length - 1))
+ operate_saved_history = where;
+ else
+ operate_saved_history = where + 1;
+
return rl_newline (1, key);
}
\f
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH/RFA] Fix operate-and-get-next when history list is full
2002-08-17 3:03 [PATCH/RFA] Fix operate-and-get-next when history list is full Mark Kettenis
@ 2002-08-17 17:02 ` Elena Zannoni
2002-08-18 5:39 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Elena Zannoni @ 2002-08-17 17:02 UTC (permalink / raw)
To: Mark Kettenis; +Cc: ezannoni, gdb-patches
Mark Kettenis writes:
> Hi Elena,
>
> The attached patch fixes a problem with operate-and-get-next when the
> history list is full. In that case, when executing a command, the
> oldest entry is removed from the history, all other entries are moved
> "up", and a new entry is put at the end of the list. In that case we
> shouldn't increase the current line by one the find the next line.
> bash contains similar code as my patch adds.
>
> OK to apply?
>
Sure.
Elena
> Mark
>
>
> Index: ChangeLog
> from Mark Kettenis <kettenis@gnu.org>
>
> * top.c (gdb_rl_operate_and_get_next): Make sure
> operate-and-get-next functions correctly even when the history
> list is completely filled.
>
> Index: top.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/top.c,v
> retrieving revision 1.65
> diff -u -p -r1.65 top.c
> --- top.c 24 Jul 2002 17:58:46 -0000 1.65
> +++ top.c 17 Aug 2002 09:58:17 -0000
> @@ -1082,6 +1082,8 @@ gdb_rl_operate_and_get_next_completion (
> static int
> gdb_rl_operate_and_get_next (int count, int key)
> {
> + int where;
> +
> if (event_loop_p)
> {
> /* Use the async hook. */
> @@ -1094,8 +1096,20 @@ gdb_rl_operate_and_get_next (int count,
> rl_pre_input_hook = (Function *) gdb_rl_operate_and_get_next_completion;
> }
>
> - /* Add 1 because we eventually want the next line. */
> - operate_saved_history = where_history () + 1;
> + /* Find the current line, and find the next line to use. */
> + where = where_history();
> +
> + /* FIXME: kettenis/20020817: max_input_history is renamed into
> + history_max_entries in readline-4.2. When we do a new readline
> + import, we should probably change it here too, even though
> + readline maintains backwards compatibility for now by still
> + defining max_input_history. */
> + if ((history_is_stifled () && (history_length >= max_input_history)) ||
> + (where >= history_length - 1))
> + operate_saved_history = where;
> + else
> + operate_saved_history = where + 1;
> +
> return rl_newline (1, key);
> }
> \f
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH/RFA] Fix operate-and-get-next when history list is full
2002-08-17 17:02 ` Elena Zannoni
@ 2002-08-18 5:39 ` Mark Kettenis
0 siblings, 0 replies; 3+ messages in thread
From: Mark Kettenis @ 2002-08-18 5:39 UTC (permalink / raw)
To: ezannoni; +Cc: gdb-patches
From: Elena Zannoni <ezannoni@redhat.com>
Date: Sat, 17 Aug 2002 20:00:11 -0400
Mark Kettenis writes:
> Hi Elena,
>
> The attached patch fixes a problem with operate-and-get-next when the
> history list is full. In that case, when executing a command, the
> oldest entry is removed from the history, all other entries are moved
> "up", and a new entry is put at the end of the list. In that case we
> shouldn't increase the current line by one the find the next line.
> bash contains similar code as my patch adds.
>
> OK to apply?
>
Sure.
Done.
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-08-18 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-17 3:03 [PATCH/RFA] Fix operate-and-get-next when history list is full Mark Kettenis
2002-08-17 17:02 ` Elena Zannoni
2002-08-18 5:39 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox