summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-05-30 20:40:12 +0100
committerPedro Alves <palves@redhat.com>2019-06-04 22:52:41 +0100
commitb099b8390d1988c5cd8e206637c8a48ee910ac2d (patch)
treec7be124ced5af50318aa60c4ba2ea521860dad6e
parent0918ebba4bacc0f7d7795b932331a126d15acb72 (diff)
downloadbinutils-gdb-b099b8390d1988c5cd8e206637c8a48ee910ac2d.tar.gz
Fix latent bug with custom word point completers
Completion routines that use a custom word point, and that then recurse into complete_line (e.g., if we make "thread apply" a custom word point completer, and complete on the command passed as argument), we stumble on this latent bug: (gdb) thread apply all pri[TAB] (gdb) thread apply all priprint The problem is that there's a spot in complete_line_internal_1 that rewinds the completion word but does not reflect that change in the custom word point in the tracker. This patch fixes it. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * completer.c (complete_line_internal_1): Rewind completion word point. (completion_tracker::advance_custom_word_point_by): Change parameter type to int. * completer.h (completion_tracker::advance_custom_word_point_by): Likewise.
-rw-r--r--gdb/completer.c5
-rw-r--r--gdb/completer.h2
2 files changed, 5 insertions, 2 deletions
diff --git a/gdb/completer.c b/gdb/completer.c
index 03d0d0e5dbd..5dd9a99f2a2 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1403,6 +1403,9 @@ complete_line_internal_1 (completion_tracker &tracker,
break;
}
+ /* Move the custom word point back too. */
+ tracker.advance_custom_word_point_by (q - p);
+
if (reason != handle_brkchars)
complete_on_cmdlist (result_list, tracker, q, word,
ignore_help_classes);
@@ -1972,7 +1975,7 @@ completion_tracker::recompute_lowest_common_denominator
/* See completer.h. */
void
-completion_tracker::advance_custom_word_point_by (size_t len)
+completion_tracker::advance_custom_word_point_by (int len)
{
m_custom_word_point += len;
}
diff --git a/gdb/completer.h b/gdb/completer.h
index 38a0132ca4d..27371b63a57 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -357,7 +357,7 @@ public:
{ m_custom_word_point = point; }
/* Advance the custom word point by LEN. */
- void advance_custom_word_point_by (size_t len);
+ void advance_custom_word_point_by (int len);
/* Whether to tell readline to skip appending a whitespace after the
completion. See m_suppress_append_ws. */