[PATCH v3 11/19] Implement completion limiting for reg_or_group_completer.

Keith Seitz
2015-08-06T22:03:34Z

There are no revisions in this version.

--

This patch converts reg_or_group_completer to use add_completion
and adds tests for this new behavior.

gdb/ChangeLog

* completer.c (reg_or_group_completer): Use add_completion.

gdb/testsuite/ChangeLog

* gdb.base/completion.exp: Add tests for limit completing
"info reigsters".
---
gdb/completer.c | 12 ++++++++++--
gdb/testsuite/gdb.base/completion.exp | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gdb/completer.c b/gdb/completer.c
index bf85efe..7ede0f9 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1092,7 +1092,11 @@ reg_or_group_completer_1 (struct completer_data *cdata,
i++)
{
if (*name != '\0' && strncmp (word, name, len) == 0)
- VEC_safe_push (char_ptr, result, xstrdup (name));
+ {
+ if (add_completion (cdata, &result, name, NULL, NULL)
+ == ADD_COMPLETION_MAX_REACHED)
+ return result;
+ }
}
}

@@ -1106,7 +1110,11 @@ reg_or_group_completer_1 (struct completer_data *cdata,
{
name = reggroup_name (group);
if (strncmp (word, name, len) == 0)
- VEC_safe_push (char_ptr, result, xstrdup (name));
+ {
+ if (add_completion (cdata, &result, name, NULL, NULL)
+ == ADD_COMPLETION_MAX_REACHED)
+ return result;
+ }
}
}

diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 41323d2..3f56a13 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -1038,6 +1038,10 @@ with_test_prefix "interpreter_completer reset" {
gdb_test_no_output "set max-completions $max_completions"
}

+# Test reg_or_group_completer.
+test_completion_limit "info registers " \
+ "info registers \[a-zA-Z0-9\]+" $max_completions
+
#
# Test TUI completions
#