[PATCH 08/13] vsh: Remove unused infrastructure for command completion

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

 



Remove the old helpers which were used previously to pick which field to
complete.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tools/virsh.c      |  4 ++--
 tools/virt-admin.c |  4 ++--
 tools/vsh.c        | 20 +++-----------------
 tools/vsh.h        |  4 +---
 4 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 58ebb493fc..a958f2b82f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -770,7 +770,7 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
         ctl->imode = false;
         if (argc - optind == 1) {
             vshDebug(ctl, VSH_ERR_INFO, "commands: \"%s\"\n", argv[optind]);
-            return vshCommandStringParse(ctl, argv[optind], NULL, 0);
+            return vshCommandStringParse(ctl, argv[optind], NULL);
         } else {
             return vshCommandArgvParse(ctl, argc - optind, argv + optind);
         }
@@ -908,7 +908,7 @@ main(int argc, char **argv)
             if (*ctl->cmdstr) {
                 vshReadlineHistoryAdd(ctl->cmdstr);

-                if (vshCommandStringParse(ctl, ctl->cmdstr, NULL, 0))
+                if (vshCommandStringParse(ctl, ctl->cmdstr, NULL))
                     vshCommandRun(ctl, ctl->cmd);
             }
             VIR_FREE(ctl->cmdstr);
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index a996923094..1805618035 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -1331,7 +1331,7 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **argv)
         ctl->imode = false;
         if (argc - optind == 1) {
             vshDebug(ctl, VSH_ERR_INFO, "commands: \"%s\"\n", argv[optind]);
-            return vshCommandStringParse(ctl, argv[optind], NULL, 0);
+            return vshCommandStringParse(ctl, argv[optind], NULL);
         } else {
             return vshCommandArgvParse(ctl, argc - optind, argv + optind);
         }
@@ -1558,7 +1558,7 @@ main(int argc, char **argv)
             if (*ctl->cmdstr) {
                 vshReadlineHistoryAdd(ctl->cmdstr);

-                if (vshCommandStringParse(ctl, ctl->cmdstr, NULL, 0))
+                if (vshCommandStringParse(ctl, ctl->cmdstr, NULL))
                     vshCommandRun(ctl, ctl->cmd);
             }
             VIR_FREE(ctl->cmdstr);
diff --git a/tools/vsh.c b/tools/vsh.c
index e9ed7c0794..1d8aecc41b 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1430,7 +1430,6 @@ struct _vshCommandParser {
                                  char **, bool);
     /* vshCommandStringGetArg() */
     char *pos;
-    const char *originalLine;
     size_t point;
     /* vshCommandArgvGetArg() */
     char **arg_pos;
@@ -1543,9 +1542,6 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                             arg->data = g_steal_pointer(&tkdata);
                             arg->next = NULL;

-                            if (parser->pos - parser->originalLine == parser->point - 1)
-                                arg->completeThis = true;
-
                             if (!first)
                                 first = arg;
                             if (last)
@@ -1596,9 +1592,6 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                 arg->data = g_steal_pointer(&tkdata);
                 arg->next = NULL;

-                if (parser->pos - parser->originalLine == parser->point)
-                    arg->completeThis = true;
-
                 if (!first)
                     first = arg;
                 if (last)
@@ -1812,23 +1805,18 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandParser *parser, char **res,
  * @ctl virsh control structure
  * @cmdstr: string to parse
  * @partial: store partially parsed command here
- * @point: position of cursor (rl_point)
  *
  * Parse given string @cmdstr as a command and store it under
  * @ctl->cmd. For readline completion, if @partial is not NULL on
  * the input then errors in parsing are ignored (because user is
  * still in progress of writing the command string) and partially
  * parsed command is stored at *@partial (caller has to free it
- * afterwards). Among with @partial, caller must set @point which
- * is the position of cursor in @cmdstr (offset, numbered from 1).
- * Parser will then set @completeThis attribute to true for the
- * vshCmdOpt that appeared under the cursor.
+ * afterwards).
  */
 bool
 vshCommandStringParse(vshControl *ctl,
                       char *cmdstr,
-                      vshCmd **partial,
-                      size_t point)
+                      vshCmd **partial)
 {
     vshCommandParser parser = { 0 };

@@ -1836,8 +1824,6 @@ vshCommandStringParse(vshControl *ctl,
         return false;

     parser.pos = cmdstr;
-    parser.originalLine = cmdstr;
-    parser.point = point;
     parser.getNextArg = vshCommandStringGetArg;
     return vshCommandParse(ctl, &parser, partial);
 }
@@ -2844,7 +2830,7 @@ vshReadlineParse(const char *text, int state)

         *(line + rl_point) = '\0';

-        vshCommandStringParse(NULL, line, &partial, rl_point);
+        vshCommandStringParse(NULL, line, &partial);

         if (partial) {
             cmd = partial->def;
diff --git a/tools/vsh.h b/tools/vsh.h
index 4576c286fe..a9c5b674bb 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -149,8 +149,6 @@ struct _vshCmdOpt {
     char *data;                 /* allocated data, or NULL for bool option */
     const char **argv;          /* for VSH_OT_ARGV, the list of options */
     char *argvstr;              /* space-joined @argv */
-    bool completeThis;          /* true if this is the option user's wishing to
-                                   autocomplete */
     vshCmdOpt *next;
 };

@@ -292,7 +290,7 @@ int vshBlockJobOptionBandwidth(vshControl *ctl,
 bool vshCommandOptBool(const vshCmd *cmd, const char *name);
 bool vshCommandRun(vshControl *ctl, const vshCmd *cmd);
 bool vshCommandStringParse(vshControl *ctl, char *cmdstr,
-                           vshCmd **partial, size_t point);
+                           vshCmd **partial);

 const char **
 vshCommandOptArgv(const vshCmd *cmd,
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux