poke-devel
[Top][All Lists]
Advanced

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

[COMMITTED] Fix subject of test "tab-completion-subcommand-1"


From: John Darrington
Subject: [COMMITTED] Fix subject of test "tab-completion-subcommand-1"
Date: Sun, 12 Apr 2020 13:19:26 +0200

The recently added test "tab-completion-subcommand-1" failed because the
thing it tested was  broken.  This change fixes it.
---
 ChangeLog    |  5 +++++
 src/pk-set.c | 19 ++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index be8fd387..98c7b1d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-12  John Darrington <address@hidden>
+
+       * src/pk-set.c (set_completion_function): Fix bug which was
+       exposed by recent test: tab-completion-subcommand-1.
+
 2020-04-12  Jose E. Marchesi  <address@hidden>
 
        * testsuite/poke.repl/repl.exp (tab-completion-subcommand-1): Use
diff --git a/src/pk-set.c b/src/pk-set.c
index 8f05d892..2600ebfd 100644
--- a/src/pk-set.c
+++ b/src/pk-set.c
@@ -488,12 +488,21 @@ set_completion_function (const char *x, int state)
   else
     ++idx;
 
-  for (const struct pk_cmd **c = set_cmds + idx;
-       *c != &null_cmd;
-       idx++)
+  int len = strlen (x);
+  for (;;)
     {
-      if (STREQ ((*c)->name, x))
-        return xstrdup ((*c)->name);
+      const struct pk_cmd *c = set_cmds[idx];
+      if (c == &null_cmd)
+       break;
+
+      int match = strncmp (c->name, x, len);
+      if (match != 0)
+       {
+         idx++;
+         continue;
+       }
+
+      return xstrdup (c->name);
     }
 
   return NULL;
-- 
2.20.1




reply via email to

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