aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-31 19:56:15 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-01-01 04:30:55 -0500
commitf3c242c13cc9aaefd29f750d211fff76e1fada68 (patch)
tree5096f59f4d61c1493d37456fb8cb890f8a281d1e /src/nvim/ex_cmds.c
parentcf3a8610172feec1fb8ab2863bdad69eb1296f28 (diff)
downloadrneovim-f3c242c13cc9aaefd29f750d211fff76e1fada68.tar.gz
rneovim-f3c242c13cc9aaefd29f750d211fff76e1fada68.tar.bz2
rneovim-f3c242c13cc9aaefd29f750d211fff76e1fada68.zip
vim-patch:8.1.1241: Ex command info contains confusing information
Problem: Ex command info contains confusing information. Solution: When using the NOTADR flag use ADDR_OTHER for the address type. Cleanup code using NOTADR. Check for errors in create_cmdidxs.vim. Adjust Makefile to see the errors. https://github.com/vim/vim/commit/b731689e85b4153af7edc8f0a6b9f99d36d8b011 Use Lua's "assert()" to make an invalid command definition a compilation error. Misc changes: Remove 'RESTRICT' flag. Neovim does not support "restricted" mode since commit 7777532cebcfa9abc5ab2c7beae77f386feed3ca. TODO: Do not generate files before Lua assertions so that CMake always runs the generator script if the previous build has an invalid command definition.
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index ae389a6727..9e9b50827e 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1032,14 +1032,15 @@ void free_prev_shellcmd(void)
* Bangs in the argument are replaced with the previously entered command.
* Remember the argument.
*/
-void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
+void do_bang(int addr_count, exarg_T *eap, bool forceit,
+ bool do_in, bool do_out)
+ FUNC_ATTR_NONNULL_ALL
{
- char_u *arg = eap->arg; /* command */
- linenr_T line1 = eap->line1; /* start of range */
- linenr_T line2 = eap->line2; /* end of range */
- char_u *newcmd = NULL; /* the new command */
- int free_newcmd = FALSE; /* need to free() newcmd */
- int ins_prevcmd;
+ char_u *arg = eap->arg; // command
+ linenr_T line1 = eap->line1; // start of range
+ linenr_T line2 = eap->line2; // end of range
+ char_u *newcmd = NULL; // the new command
+ bool free_newcmd = false; // need to free() newcmd
char_u *t;
char_u *p;
char_u *trailarg;
@@ -1064,7 +1065,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
* Try to find an embedded bang, like in :!<cmd> ! [args]
* (:!! is indicated by the 'forceit' variable)
*/
- ins_prevcmd = forceit;
+ bool ins_prevcmd = forceit;
trailarg = arg;
do {
len = (int)STRLEN(trailarg) + 1;
@@ -1101,7 +1102,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
else {
trailarg = p;
*trailarg++ = NUL;
- ins_prevcmd = TRUE;
+ ins_prevcmd = true;
break;
}
}
@@ -1131,7 +1132,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
STRCPY(newcmd, p_shq);
STRCAT(newcmd, prevcmd);
STRCAT(newcmd, p_shq);
- free_newcmd = TRUE;
+ free_newcmd = true;
}
if (addr_count == 0) { /* :! */
/* echo the command */
@@ -1164,15 +1165,15 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
// do this.
// Alternatively, if on Unix and redirecting input or output, but not both,
// and the 'shelltemp' option isn't set, use pipes.
-// We use input redirection if do_in is TRUE.
-// We use output redirection if do_out is TRUE.
+// We use input redirection if do_in is true.
+// We use output redirection if do_out is true.
static void do_filter(
linenr_T line1,
linenr_T line2,
exarg_T *eap, /* for forced 'ff' and 'fenc' */
char_u *cmd,
- int do_in,
- int do_out)
+ bool do_in,
+ bool do_out)
{
char_u *itmp = NULL;
char_u *otmp = NULL;
@@ -1669,10 +1670,17 @@ void ex_update(exarg_T *eap)
*/
void ex_write(exarg_T *eap)
{
- if (eap->usefilter) /* input lines to shell command */
- do_bang(1, eap, FALSE, TRUE, FALSE);
- else
+ if (eap->cmdidx == CMD_saveas) {
+ // :saveas does not take a range, uses all lines.
+ eap->line1 = 1;
+ eap->line2 = curbuf->b_ml.ml_line_count;
+ }
+
+ if (eap->usefilter) { // input lines to shell command
+ do_bang(1, eap, false, true, false);
+ } else {
(void)do_write(eap);
+ }
}
/*