[v3,11/19] Implement completion limiting for reg_or_group_completer.
Commit Message
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(-)
Comments
Keith Seitz <keiths@redhat.com> writes:
> 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".
LGTM.
@@ -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;
+ }
}
}
@@ -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
#