This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3 00/19] New completer API


* Keith Seitz <keiths@redhat.com> [2015-08-06 12:14:29 -0700]:

> Currently completer functions are not required to implement completion-
> limiting.  These functions will compute all possible completions and then
> rely on complete_line to limit the result.
> 
> The main goal of this patchset is to require completer functions to
> implement proper completion-limiting using maybe_add_completion.  This
> actually cleans up the completer API significantly and fixes at least one
> serious bug (an assertion failure, gdb/17960).
> 
> The new API requires all completions to be added to the completion
> list using maybe_add_completion:

I think that the above text is out of date w.r.t. the example below,
in the above you talk about maybe_add_completion, but in the example
below you use the add_completion wrapper.  A small detail and
unimportant detail; unless I'm missing something, in which case
... I'm confused!

> void
> my_completer_function (struct completer_data *cdata,
>                        struct cmd_list_element *cmd,
>                        const char *text, const char *word)
> {
>     while (/* there are more completions to look for */)
>     {
>       char *match = xstrdup (a_completion_match);
> 
>       if (add_completion (cdata, match, text /* or NULL */,
>                           word /* or NULL */))
>           == ADD_COMPLETION_MAX_REACHED)
> 	return;
>     }
> }

This pattern of calling add_completion and comparing to
ADD_COMPLETION_MAX_REACHED is repeated throughout the patch set.

I wonder, looking at add_completion, do users _care_ about the reason?
Of all the possible return codes from add_completion, I think we can
classify them as either "stop trying to add completions please", or
"feel free to add more completions".

Could the add_completion interface be simplified to simply return a
bool, true if more completions can be added, false if not?

Just a thought.

Thanks,
Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]