aboutsummaryrefslogtreecommitdiff
path: root/src/os/shell.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-03-29 10:07:38 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-31 08:07:46 -0300
commit2d28251a6e2850998f475c76a886121554c9b7e9 (patch)
tree48cf4ae9525577fd6bc7d35068f1519a44e05b37 /src/os/shell.c
parent1ab6cf47bd4218c303459efd288456e51f46033b (diff)
downloadrneovim-2d28251a6e2850998f475c76a886121554c9b7e9.tar.gz
rneovim-2d28251a6e2850998f475c76a886121554c9b7e9.tar.bz2
rneovim-2d28251a6e2850998f475c76a886121554c9b7e9.zip
Extract `shell_skip_word` from `mch_call_shell`
Diffstat (limited to 'src/os/shell.c')
-rw-r--r--src/os/shell.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/os/shell.c b/src/os/shell.c
new file mode 100644
index 0000000000..b2248541b9
--- /dev/null
+++ b/src/os/shell.c
@@ -0,0 +1,23 @@
+#include <stdbool.h>
+
+#include "os/shell.h"
+#include "types.h"
+#include "ascii.h"
+
+
+void shell_skip_word(char_u **ptr)
+{
+ char_u *p = *ptr;
+ bool inquote = false;
+
+ // Move `p` to the end of shell word by advancing the pointer it while it's
+ // inside a quote or it's a non-whitespace character
+ while (*p && (inquote || (*p != ' ' && *p != TAB))) {
+ if (*p == '"')
+ // Found a quote character, switch the `inquote` flag
+ inquote = !inquote;
+ ++p;
+ }
+
+ *ptr = p;
+}