[v2,09/18] Implement completion limiting for interpreter_completer.
Commit Message
This is another simple patch which converts interpreter_completer
to use add_completion and adds some tests to make sure that everything
is working properly.
gdb/ChangeLog
* interps.c (interpreter_completer): Use add_completion.
gdb/testsuite/ChangeLog
* gdb.base/completion.exp: Test completion limiting on
interpreter name with "interpreter-exec".
---
gdb/interps.c | 5 ++++-
gdb/testsuite/gdb.base/completion.exp | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
@@ -467,7 +467,10 @@ interpreter_completer (struct completer_data *cdata,
match[text - word] = '\0';
strcat (match, interp->name);
}
- VEC_safe_push (char_ptr, matches, match);
+
+ if (add_completion (cdata, &matches, match)
+ == ADD_COMPLETION_MAX_REACHED)
+ break;
}
}
@@ -1021,3 +1021,19 @@ if {$num_signals > $max_completions} {
append msg "limiting in signal_handler ($num_signals)"
untested $msg
}
+
+# Test interpreter_completer. There are only four completions
+# available for this, so temporarily set max-completions to 3.
+with_test_prefix "interpreter_completer" {
+ set old_max $max_completions
+ set max_completions 3
+ gdb_test_no_output "set max-completions $max_completions"
+}
+
+test_completion_limit "interpreter-exec m" \
+ "interpreter-exec mi\[1-3\]?" $max_completions
+
+with_test_prefix "interpreter_completer reset" {
+ set max_completions $old_max
+ gdb_test_no_output "set max-completions $max_completions"
+}