[PATCH v3 12/19] Implement completion limiting for sim_command_completer.

Keith Seitz
2015-08-06T19:20:37Z

There are no revisions in this version.

--

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(-)

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 0a8997a..c29d3c5 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -40,6 +40,7 @@
#include "arch-utils.h"
#include "readline/readline.h"
#include "gdbthread.h"
+#include "completer.h"

/* Prototypes */

@@ -1242,7 +1243,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], NULL, NULL)
+ == ADD_COMPLETION_MAX_REACHED)
+ break;
+ }
xfree (tmp);

return result;