[v2,12/18] Implement completion limiting for sim_command_completer.
Commit Message
This patch converts sim_command_completer to use add_completion.
It does not add any tests, since the `sim' command is highly
target-dependent and unimplemented for the majority of simulators.
gdb/ChangeLog
* remote-sim.c: Include completer.h.
(sim_command_completer): Use add_completion.
---
gdb/remote-sim.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@@ -39,6 +39,7 @@
#include "arch-utils.h"
#include "readline/readline.h"
#include "gdbthread.h"
+#include "completer.h"
/* Prototypes */
@@ -1236,7 +1237,11 @@ sim_command_completer (struct completer_data *cdata,
/* Transform the array into a VEC, and then free the array. */
for (i = 0; tmp[i] != NULL; i++)
- VEC_safe_push (char_ptr, result, tmp[i]);
+ {
+ if (add_completion (cdata, &result, tmp[i])
+ == ADD_COMPLETION_MAX_REACHED)
+ break;
+ }
xfree (tmp);
return result;