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

Message ID 20150806191857.32159.87692.stgit@valrhona.uglyboxes.com
State New, archived
Headers

Commit Message

Keith Seitz Aug. 6, 2015, 7:19 p.m. UTC
  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(-)
  

Comments

Doug Evans Aug. 23, 2015, 4:09 a.m. UTC | #1
Keith Seitz <keiths@redhat.com> writes:
> 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.

LGTM
  

Patch

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;