From: Daniel Carl <danielcarl@gmx.de>
Date: Sun, 13 Oct 2013 18:52:02 +0000 (+0200)
Subject: Allow to have commands with bang.
X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=7a0d7cbc5de1b9627d1bb4140a544723c029760b;p=vimb.git

Allow to have commands with bang.
---

diff --git a/src/ex.c b/src/ex.c
index 4ea5859..90efb9f 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -93,6 +93,7 @@ static void input_activate(void);
 static gboolean parse(const char **input, ExArg *arg);
 static gboolean parse_count(const char **input, ExArg *arg);
 static gboolean parse_command_name(const char **input, ExArg *arg);
+static gboolean parse_bang(const char **input, ExArg *arg);
 static gboolean parse_lhs(const char **input, ExArg *arg);
 static gboolean parse_rhs(const char **input, ExArg *arg);
 static void skip_whitespace(const char **input);
@@ -438,6 +439,11 @@ static gboolean parse(const char **input, ExArg *arg)
     /* get the command and it's flags to decide what to parse */
     cmd = &(commands[arg->idx]);
 
+    /* parse the bang if this is allowed */
+    if (cmd->flags & EX_FLAG_BANG) {
+        parse_bang(input, arg);
+    }
+
     /* parse the lhs if this is available */
     skip_whitespace(input);
     if (cmd->flags & EX_FLAG_LHS) {
@@ -502,7 +508,7 @@ static gboolean parse_command_name(const char **input, ExArg *arg)
             }
         }
         (*input)++;
-    } while (matches > 0 && **input && **input != ' ');
+    } while (matches > 0 && **input && **input != ' ' && **input != '!');
 
     if (!matches) {
         /* TODO show readable error message */
@@ -516,6 +522,18 @@ static gboolean parse_command_name(const char **input, ExArg *arg)
     return true;
 }
 
+/**
+ * Parse a single bang ! after the command.
+ */
+static gboolean parse_bang(const char **input, ExArg *arg)
+{
+    if (*input && **input == '!') {
+        arg->bang = true;
+        (*input)++;
+    }
+    return true;
+}
+
 /**
  * Parse a single word left hand side of a command arg.
  */