mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
Extract shell_skip_word
from mch_call_shell
This commit is contained in:
23
src/os/shell.c
Normal file
23
src/os/shell.c
Normal file
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user