public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pedro Alves <palves@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix latent bug with custom word point completers
Date: Wed, 12 Jun 2019 23:28:00 -0000	[thread overview]
Message-ID: <20190612232803.27875.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3844e605e61777555aed09ab8ce88db2da95bc0b

commit 3844e605e61777555aed09ab8ce88db2da95bc0b
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jun 13 00:06:52 2019 +0100

    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:
    2019-06-13  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.

Diff:
---
 gdb/ChangeLog   | 9 +++++++++
 gdb/completer.c | 5 ++++-
 gdb/completer.h | 2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 19b2a7d..cd81cfe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2019-06-13  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.
+
+2019-06-13  Pedro Alves  <palves@redhat.com>
+
 	* completer.c (advance_to_completion_word): Handle delimiters.
 
 2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>
diff --git a/gdb/completer.c b/gdb/completer.c
index 03d0d0e..5dd9a99 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 38a0132..27371b6 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.  */


                 reply	other threads:[~2019-06-12 23:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190612232803.27875.qmail@sourceware.org \
    --to=palves@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).