poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Fix the .close completer and use the same one for the .ios c


From: John Darrington
Subject: [PATCH 2/2] Fix the .close completer and use the same one for the .ios command.
Date: Sat, 22 Feb 2020 10:38:19 +0100

---
 ChangeLog    |  9 +++++++++
 src/pk-ios.c | 33 ++++++++++++---------------------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b07ae34..b4e58585 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-22  John Darrington <address@hidden>
+
+       * src/pk-ios.c (count_io_spaces): delete.
+       * src/pk-ios.c (close_completion_function): Rename
+       to ios_completion_function.
+       * src/pk-ios.c (ios_completion_function): Do not
+       assume that IO tags are consecutive integers.
+       * src/pk-ios.c (ios_cmd): Add new completer.
+
 2020-02-22  John Darrington <address@hidden>
 
        * src/ios.c (ios_begin): New function.
diff --git a/src/pk-ios.c b/src/pk-ios.c
index afc7d86f..4b37f1f5 100644
--- a/src/pk-ios.c
+++ b/src/pk-ios.c
@@ -34,41 +34,32 @@
 #  include "pk-hserver.h"
 #endif
 
-static void
-count_io_spaces (ios io, void *data)
-{
-  int *i = (int *) data;
-  if (i == NULL)
-    return;
-  (*i)++;
-}
-
 static char *
-close_completion_function (const char *x, int state)
+ios_completion_function (const char *x, int state)
 {
-  static int idx = 0;
-  static int n_ids = 0;
+  static ios io;
   if (state == 0)
     {
-      idx = 0;
-      n_ids = 0;
-      ios_map (count_io_spaces, &n_ids);
+      io = ios_begin ();
     }
   else
-    ++idx;
+    {
+      io = ios_next (io);
+    }
 
   int len  = strlen (x);
   while (1)
     {
-      if (idx >= n_ids)
+      if (ios_end (io))
        break;
+
       char buf[16];
-      snprintf (buf, 16, "#%d", idx);
+      snprintf (buf, 16, "#%d", ios_get_id (io));
 
       int match = strncmp (buf, x, len);
       if (match != 0)
        {
-         idx++;
+         io = ios_next (io);
          continue;
        }
 
@@ -340,7 +331,7 @@ pk_cmd_mem (int argc, struct pk_cmd_arg argv[], uint64_t 
uflags)
 }
 
 struct pk_cmd ios_cmd =
-  {"ios", "t", "", 0, NULL, pk_cmd_ios, "ios #ID", NULL};
+  {"ios", "t", "", 0, NULL, pk_cmd_ios, "ios #ID", ios_completion_function};
 
 struct pk_cmd file_cmd =
   {"file", "f", "", 0, NULL, pk_cmd_file, "file FILENAME", 
rl_filename_completion_function};
@@ -349,7 +340,7 @@ struct pk_cmd mem_cmd =
   {"mem", "ts", "", 0, NULL, pk_cmd_mem, "mem NAME", NULL};
 
 struct pk_cmd close_cmd =
-  {"close", "?t", "", PK_CMD_F_REQ_IO, NULL, pk_cmd_close, "close [#ID]", 
close_completion_function};
+  {"close", "?t", "", PK_CMD_F_REQ_IO, NULL, pk_cmd_close, "close [#ID]", 
ios_completion_function};
 
 struct pk_cmd info_ios_cmd =
   {"ios", "", "", 0, NULL, pk_cmd_info_ios, "info ios", NULL};
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]