From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 16/18] Make the completion API completely opaque.
Date: Mon, 13 Apr 2015 19:23:00 -0000 [thread overview]
Message-ID: <20150413192341.29172.56214.stgit@valrhona.uglyboxes.com> (raw)
In-Reply-To: <20150413192235.29172.13097.stgit@valrhona.uglyboxes.com>
Now that the completion API is passing around a structure holding
its internal data, there is no need to expose any of this data and
other settings to other modules.
This patch removes global access to max_completions and
introduces a new API function, get_maximum_completions (void), which
other modules may use to query the current completion maximum.
The API will be expanded as necessary in subsequent patches.
gdb/ChangeLog
* cli/cli-cmds.c (complete_command): Use get_maximum_completions
instead of accessing the global max_completions.
* completer.c (max_completions): Move definition earlier and
make static.
(get_maximum_completions): New function.
(throw_max_completions_reached_error): Add comment.
* completer.h (max_completions): Remove declaration.
(get_maximum_completions): New declaration.
---
gdb/cli/cli-cmds.c | 4 ++--
gdb/completer.c | 22 +++++++++++++++++-----
gdb/completer.h | 8 ++++----
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2ec2dd3..a73a655 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -248,7 +248,7 @@ complete_command (char *arg, int from_tty)
dont_repeat ();
- if (max_completions == 0)
+ if (get_maximum_completions () == 0)
{
/* Only print this for non-mi frontends. An MI frontend may not
be able to handle this. */
@@ -307,7 +307,7 @@ complete_command (char *arg, int from_tty)
xfree (prev);
VEC_free (char_ptr, completions);
- if (size == max_completions)
+ if (size == get_maximum_completions ())
{
/* ARG_PREFIX and POINT are included in the output so that emacs
will include the message in the output. */
diff --git a/gdb/completer.c b/gdb/completer.c
index 45170e3..5d06784 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -42,6 +42,13 @@
#include "completer.h"
+/* Maximum number of candidates to consider before the completer
+ bails by throwing MAX_COMPLETIONS_REACHED_ERROR. Negative values
+ disable limiting. */
+
+#define DEFAULT_MAX_COMPLETIONS 200
+static int max_completions = DEFAULT_MAX_COMPLETIONS;
+
/* Prototypes for local functions. */
static
char *line_completion_function (const char *text, int matches,
@@ -855,11 +862,6 @@ complete_line_internal (struct completer_data *cdata,
return list;
}
-/* See completer.h. */
-
-#define DEFAULT_MAX_COMPLETIONS 200
-int max_completions = DEFAULT_MAX_COMPLETIONS;
-
/* Allocate a new completer data structure. */
static struct completer_data *
@@ -887,6 +889,14 @@ free_completer_data (void *p)
/* See completer.h. */
+int
+get_maximum_completions (void)
+{
+ return max_completions;
+}
+
+/* See completer.h. */
+
enum maybe_add_completion_enum
maybe_add_completion (struct completer_data *cdata, char *name)
{
@@ -912,6 +922,8 @@ maybe_add_completion (struct completer_data *cdata, char *name)
: MAYBE_ADD_COMPLETION_OK_MAX_REACHED);
}
+/* See completer.h. */
+
void
throw_max_completions_reached_error (void)
{
diff --git a/gdb/completer.h b/gdb/completer.h
index 003c66c..67fdcad 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -122,11 +122,11 @@ extern const char *skip_quoted_chars (const char *, const char *,
extern const char *skip_quoted (const char *);
-/* Maximum number of candidates to consider before the completer
- bails by throwing MAX_COMPLETIONS_REACHED_ERROR. Negative values
- disable limiting. */
+/* Get the maximum number of completions that are permitted before the
+ completer throws a MAX_COMPLETIONS_REACHED_ERROR. Negative values
+ mean completion limiting is entirely disabled. */
-extern int max_completions;
+extern int get_maximum_completions (void);
/* Return values for maybe_add_completion. */
next prev parent reply other threads:[~2015-04-13 19:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 19:23 [PATCH 00/18] Implement full completer limiting Keith Seitz
2015-04-13 19:23 ` [PATCH 18/18] Remove the vector return result from the completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 04/18] Implement completion limiting for add_filename_to_list Keith Seitz
2015-04-13 19:23 ` [PATCH 02/18] Remove completion_tracker_t from the public completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 07/18] Implement completion limiting for filename_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 05/18] Implement completion limiting for ada_make_symbol_completion_list Keith Seitz
2015-04-13 19:23 ` [PATCH 15/18] Implement completion limiting for scmcmd_add_completion Keith Seitz
2015-04-13 19:23 ` [PATCH 08/18] Implement completion limiting for signal_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 11/18] Implement completion limiting for reg_or_group_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 12/18] Implement completion limiting for sim_command_completer Keith Seitz
2015-04-14 15:28 ` Mike Frysinger
2015-05-05 15:03 ` Keith Seitz
2015-05-05 15:34 ` Mike Frysinger
2015-05-05 15:53 ` Keith Seitz
2015-04-13 19:23 ` Keith Seitz [this message]
2015-04-13 19:23 ` [PATCH 01/18] Add struct completer_data to the completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 13/18] Implement completion limiting for complete_on_enum Keith Seitz
2015-04-13 19:23 ` [PATCH 17/18] Use the hashtable to accumulate completion results Keith Seitz
2015-04-13 19:23 ` [PATCH 03/18] Implement completion limiting for complete_on_cmdlist Keith Seitz
2015-04-13 19:23 ` [PATCH 14/18] Implement completion limiting in add_struct_fields Keith Seitz
2015-04-13 19:23 ` [PATCH 09/18] Implement completion limiting for interpreter_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 06/18] Implement completion limiting for condition_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 10/18] Implement completion limiting for cmdpy_completer Keith Seitz
2015-04-20 3:21 ` [PATCH 00/18] Implement full completer limiting Doug Evans
2015-04-29 19:19 ` Keith Seitz
2015-04-30 0:26 ` Doug Evans
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=20150413192341.29172.56214.stgit@valrhona.uglyboxes.com \
--to=keiths@redhat.com \
--cc=gdb-patches@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).