From: Pedro Alves <palves@redhat.com>
To: Jan Vrany <jan.vrany@fit.cvut.cz>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 1/2] MI: extract command completion logic from complete_command()
Date: Wed, 27 Feb 2019 20:41:00 -0000 [thread overview]
Message-ID: <f6f7deb7-6bab-ae30-2041-fef01e4d5903@redhat.com> (raw)
In-Reply-To: <20190128124101.26243-2-jan.vrany@fit.cvut.cz>
Hi Jan,
Some formatting nits below.
On 01/28/2019 12:41 PM, Jan Vrany wrote:
> Extract completion logic from CLI complete_command() into a new
> helper function complete().
>
> gdb/Changelog:
>
> * completer.h (complete): New function.
> * completer.c (complete): Likewise.
> * cli/cli-cmds.c: (complete_command): Update to use new complete()
> function defined in completer.h
Missing period after "in completer.h".
> ---
> gdb/ChangeLog | 7 +++++++
> gdb/cli/cli-cmds.c | 32 ++------------------------------
> gdb/completer.c | 34 ++++++++++++++++++++++++++++++++++
> gdb/completer.h | 8 ++++++++
> 4 files changed, 51 insertions(+), 30 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 8e03dbf883..17e29a7807 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,10 @@
> +2019-01-24 Jan Vrany <jan.vrany@fit.cvut.cz>
> +
> + * completer.h (complete): New function.
> + * completer.c (complete): Likewise.
> + * cli/cli-cmds.c: (complete_command): Update to use new complete()
> + function defined in completer.h
> +
> 2019-01-22 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * event-top.c (handle_line_of_input): use unique_xmalloc_ptr for
> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
> index 57cfad441c..f2c2311e68 100644
> --- a/gdb/cli/cli-cmds.c
> +++ b/gdb/cli/cli-cmds.c
> @@ -243,41 +243,13 @@ complete_command (const char *arg, int from_tty)
> if (arg == NULL)
> arg = "";
>
> - completion_tracker tracker_handle_brkchars;
> - completion_tracker tracker_handle_completions;
> - completion_tracker *tracker;
> -
> int quote_char = '\0';
> const char *word;
> -
> - TRY
> - {
> - word = completion_find_completion_word (tracker_handle_brkchars,
> - arg, "e_char);
> -
> - /* Completers that provide a custom word point in the
> - handle_brkchars phase also compute their completions then.
> - Completers that leave the completion word handling to readline
> - must be called twice. */
> - if (tracker_handle_brkchars.use_custom_word_point ())
> - tracker = &tracker_handle_brkchars;
> - else
> - {
> - complete_line (tracker_handle_completions, word, arg, strlen (arg));
> - tracker = &tracker_handle_completions;
> - }
> - }
> - CATCH (ex, RETURN_MASK_ALL)
> - {
> - return;
> - }
> - END_CATCH
> +
> + completion_result result = complete (arg, &word, "e_char);
>
> std::string arg_prefix (arg, word - arg);
>
> - completion_result result
> - = tracker->build_completion_result (word, word - arg, strlen (arg));
> -
> if (result.number_matches != 0)
> {
> if (result.number_matches == 1)
> diff --git a/gdb/completer.c b/gdb/completer.c
> index fed815a53c..2f94932184 100644
> --- a/gdb/completer.c
> +++ b/gdb/completer.c
> @@ -1615,6 +1615,40 @@ make_completion_match_str (gdb::unique_xmalloc_ptr<char> &&match_name,
> return gdb::unique_xmalloc_ptr<char> (newobj);
> }
>
> +completion_result
> +complete (const char *line, char const **word, int *quote_char)
Add:
/* See complete.h. */
Make sure to leave an empty line between comment and function.
> +{
> + completion_tracker tracker_handle_brkchars;
> + completion_tracker tracker_handle_completions;
> + completion_tracker *tracker;
> +
> + TRY
> + {
> + *word = completion_find_completion_word (tracker_handle_brkchars,
> + line, quote_char);
> +
> + /* Completers that provide a custom word point in the
> + handle_brkchars phase also compute their completions then.
> + Completers that leave the completion word handling to readline
> + must be called twice. */
> + if (tracker_handle_brkchars.use_custom_word_point ())
> + tracker = &tracker_handle_brkchars;
> + else
> + {
> + complete_line (tracker_handle_completions, *word, line, strlen (line));
> + tracker = &tracker_handle_completions;
> + }
> + }
> + CATCH (ex, RETURN_MASK_ALL)
> + {
> + return {};
> + }
> + END_CATCH
> +
> + return tracker->build_completion_result (*word, *word - line, strlen (line));
> +}
> +
> +
> /* Generate completions all at once. Does nothing if max_completions
> is 0. If max_completions is non-negative, this will collect at
> most max_completions strings.
> diff --git a/gdb/completer.h b/gdb/completer.h
> index e81243a721..bfbead235b 100644
> --- a/gdb/completer.h
> +++ b/gdb/completer.h
> @@ -510,6 +510,14 @@ extern void complete_line (completion_tracker &tracker,
> const char *line_buffer,
> int point);
>
> +/* Complete LINE and return completion results. For completion purposes,
> + cursor position is assumed to be at the end of LINE. WORD is set to
> + the end of word to complete. QUOTE_CHAR is set to the opening quote
> + character if we found an unclosed quoted substring, '\0' otherwise.
> + */
Double space after periods ending sentences. '*/' goes at the previous line.
Like this:
/* Complete LINE and return completion results. For completion
purposes, cursor position is assumed to be at the end of LINE.
WORD is set to the end of word to complete. QUOTE_CHAR is set to
the opening quote character if we found an unclosed quoted
substring, '\0' otherwise. */
> +extern completion_result
> + complete (const char *line, char const **word, int *quote_char);
> +
> /* Find the bounds of the word in TEXT for completion purposes, and
> return a pointer to the end of the word. Calls the completion
> machinery for a handle_brkchars phase (using TRACKER) to figure out
>
Thanks,
Pedro Alves
next prev parent reply other threads:[~2019-02-27 20:41 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-03 22:30 [PATCH] MI: Add new command -complete Jan Vrany
2019-01-16 9:21 ` Jan Vrany
[not found] ` <87imynm3ia.fsf@tromey.com>
2019-01-17 21:01 ` Jan Vrany
2019-01-28 12:41 ` [PATCH v2 0/2] " Jan Vrany
2019-01-28 12:41 ` [PATCH v2 1/2] MI: extract command completion logic from complete_command() Jan Vrany
2019-02-27 20:41 ` Pedro Alves [this message]
[not found] ` <9ddd13d90ac5d77067f5690743149be8a2dcdd1a.camel@fit.cvut.cz>
2019-02-13 9:24 ` [PATCH v2 0/2] MI: Add new command -complete Jan Vrany
2019-02-19 7:33 ` Jan Vrany
2019-02-20 21:20 ` Tom Tromey
2019-02-21 16:05 ` Jan Vrany
2019-02-26 19:49 ` Tom Tromey
2019-02-27 10:41 ` Jan Vrany
2019-02-27 20:41 ` Pedro Alves
2019-02-28 10:18 ` Jan Vrany
2019-03-05 20:53 ` Pedro Alves
2019-03-06 15:09 ` Jan Vrany
2019-03-06 15:45 ` Eli Zaretskii
2019-03-06 16:37 ` Jan Vrany
2019-03-06 17:36 ` Eli Zaretskii
2019-03-04 14:52 ` [PATCH v3 1/2] MI: extract command completion logic from complete_command() Jan Vrany
2019-03-04 14:52 ` [PATCH v3 2/2] MI: Add new command -complete Jan Vrany
2019-03-04 17:35 ` Eli Zaretskii
2019-04-03 19:23 ` Pedro Alves
2019-03-04 14:52 ` [PATCH v3 0/2] " Jan Vrany
2019-04-18 11:59 ` [PATCH v4 2/2] " Jan Vrany
2019-04-18 12:51 ` Eli Zaretskii
2019-04-18 14:15 ` Pedro Alves
2019-04-18 14:55 ` Jan Vrany
2019-04-18 16:14 ` Pedro Alves
2019-05-16 11:27 ` Jan Vrany
2019-05-16 17:31 ` Tom Tromey
2019-04-18 11:59 ` [PATCH v4 0/2] " Jan Vrany
2019-04-18 14:59 ` [PATCH v5 " Jan Vrany
2019-04-18 14:59 ` [PATCH v5 2/2] " Jan Vrany
2019-04-18 15:23 ` Eli Zaretskii
2019-04-18 14:59 ` [PATCH v5 1/2] MI: extract command completion logic from complete_command() Jan Vrany
2019-04-18 11:59 ` [PATCH v4 " Jan Vrany
2019-05-30 13:49 ` [PATCH v3 3/5] Create MI commands using python Jan Vrany
2019-06-18 19:43 ` Pedro Alves
2019-05-30 13:49 ` [PATCH v3 0/5] " Jan Vrany
2019-06-10 12:20 ` Jan Vrany
2019-05-30 13:49 ` [PATCH v3 1/5] Use std::map for MI commands in mi-cmds.c Jan Vrany
2019-05-30 13:49 ` [PATCH v3 4/5] mi/python: Allow redefinition of python MI commands Jan Vrany
2019-06-18 20:03 ` Pedro Alves
2019-05-30 13:49 ` [PATCH v3 2/5] Use classes to represent MI Command instead of structures Jan Vrany
2019-06-18 19:38 ` Pedro Alves
2019-05-30 14:19 ` [PATCH v3 5/5] mi/python: Add tests for python-defined MI commands Jan Vrany
2019-06-18 20:11 ` Pedro Alves
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=f6f7deb7-6bab-ae30-2041-fef01e4d5903@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.vrany@fit.cvut.cz \
/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