poke-devel
[Top][All Lists]
Advanced

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

[COMMITTED 1/2] Fix bug in pk_cmd_get_next_match


From: John Darrington
Subject: [COMMITTED 1/2] Fix bug in pk_cmd_get_next_match
Date: Sun, 3 May 2020 07:05:05 +0200

---
 ChangeLog     |  4 ++++
 poke/pk-cmd.c | 12 ++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6f7c7090..c6b773fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-03  John Darrington <address@hidden>
+
+       * poke/pk-cmd.c (pk_cmd_get_next_match): Fix bug in completer.
+
 2020-05-02  Jose E. Marchesi  <address@hidden>
 
        * pickles/id3v1.pk (ID3V1_Tag): Text-stylize the output of the
diff --git a/poke/pk-cmd.c b/poke/pk-cmd.c
index ece9a982..32f2d0df 100644
--- a/poke/pk-cmd.c
+++ b/poke/pk-cmd.c
@@ -707,20 +707,24 @@ pk_cmd_shutdown (void)
 }
 
 
-/*  Return the name of the next command that matches (X, LEN).
+/*  Return the name of the next dot command that matches the first
+    LEN characters of TEXT.
     Returns the name of the next command in the set, or NULL if there
-    are no more. The returned value must be freed by the caller.  */
+    are no more.  The returned value must be freed by the caller.  */
 char *
-pk_cmd_get_next_match (const char *x, size_t len)
+pk_cmd_get_next_match (const char *text, size_t len)
 {
   static int idx = 0;
 
+  if (len > 0 && text[0] != '.')
+    return NULL;
+
   /* Dot commands */
   for (const struct pk_cmd **c = dot_cmds + idx++;
        *c != &null_cmd;
        c++)
     {
-      if (len == 0 || strncmp ((*c)->name, x + 1, len - 1) == 0)
+      if (len == 0 || strncmp ((*c)->name, text + 1, len - 1) == 0)
        return pk_str_concat (".", (*c)->name, NULL);
     }
   idx = 0;
-- 
2.20.1




reply via email to

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