| tex: handle spaces in shell commands - neatvi - [fork] simple vi-type editor wi… | |
| git clone git://src.adamsgaard.dk/neatvi | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit aae3a82a9f44f2b7fe2b6babb9390ad23517172a | |
| parent 49e4029728927afb1a22864698be10cf445413aa | |
| Author: Ali Gholami Rudi <[email protected]> | |
| Date: Mon, 27 Jul 2020 19:03:45 +0430 | |
| ex: handle spaces in shell commands | |
| Diffstat: | |
| M ex.c | 14 +++++++------- | |
| 1 file changed, 7 insertions(+), 7 deletions(-) | |
| --- | |
| diff --git a/ex.c b/ex.c | |
| t@@ -169,12 +169,12 @@ static char *ex_arg(char *s, char *arg) | |
| } | |
| /* read ex file argument */ | |
| -static char *ex_filearg(char *s, char *arg) | |
| +static char *ex_filearg(char *s, char *arg, int spaceallowed) | |
| { | |
| s = ex_cmd(s, arg); | |
| while (isspace((unsigned char) *s)) | |
| s++; | |
| - while (*s && !isspace((unsigned char) *s)) { | |
| + while (*s && (spaceallowed || !isspace((unsigned char) *s))) { | |
| int c = (unsigned char) *s++; | |
| if (c == '%') { | |
| if (!bufs[0].path || !bufs[0].path[0]) { | |
| t@@ -368,7 +368,7 @@ static int ec_edit(char *ec) | |
| char path[EXLEN]; | |
| int fd; | |
| ex_cmd(ec, cmd); | |
| - if (!ex_filearg(ec, path)) | |
| + if (!ex_filearg(ec, path, 0)) | |
| return 1; | |
| if (!strchr(cmd, '!')) | |
| if (xb && ex_modifiedbuffer("buffer modified\n")) | |
| t@@ -416,7 +416,7 @@ static int ec_read(char *ec) | |
| return 1; | |
| if (arg[0] == '!') { | |
| int pos = MIN(xrow + 1, lbuf_len(xb)); | |
| - if (!ex_filearg(ec, arg)) | |
| + if (!ex_filearg(ec, arg, 1)) | |
| return 1; | |
| obuf = cmd_pipe(arg + 1, NULL, 0, 1); | |
| if (obuf) | |
| t@@ -463,7 +463,7 @@ static int ec_write(char *ec) | |
| end = lbuf_len(xb); | |
| } | |
| if (arg[0] == '!') { | |
| - if (!ex_filearg(ec, arg)) | |
| + if (!ex_filearg(ec, arg, 1)) | |
| return 1; | |
| ibuf = lbuf_cp(xb, beg, end); | |
| ex_print(NULL); | |
| t@@ -747,7 +747,7 @@ static int ec_exec(char *ec) | |
| char *rep; | |
| ex_modifiedbuffer(NULL); | |
| ex_loc(ec, loc); | |
| - if (!ex_filearg(ec, arg)) | |
| + if (!ex_filearg(ec, arg, 1)) | |
| return 1; | |
| if (!loc[0]) { | |
| ex_print(NULL); | |
| t@@ -769,7 +769,7 @@ static int ec_make(char *ec) | |
| char arg[EXLEN]; | |
| char make[EXLEN]; | |
| ex_modifiedbuffer(NULL); | |
| - if (!ex_filearg(ec, arg)) | |
| + if (!ex_filearg(ec, arg, 1)) | |
| return 1; | |
| sprintf(make, "make %s", arg); | |
| ex_print(NULL); |