diff options
author | Jurica Bradaric <jbradaric@gmail.com> | 2019-09-23 21:19:26 +0200 |
---|---|---|
committer | Jurica Bradaric <jbradaric@gmail.com> | 2019-10-07 14:14:13 +0200 |
commit | 0586a4b512b2495d32f20c46946d35a0d403bd52 (patch) | |
tree | 6d63e31135bb1e2221e8e528b5dac9498a48a617 /src | |
parent | c84b39150f3f5e12e042777f61ca9adf13be09d8 (diff) | |
download | rneovim-0586a4b512b2495d32f20c46946d35a0d403bd52.tar.gz rneovim-0586a4b512b2495d32f20c46946d35a0d403bd52.tar.bz2 rneovim-0586a4b512b2495d32f20c46946d35a0d403bd52.zip |
vim-patch:8.1.1588: in :let-heredoc line continuation is recognized
Problem: In :let-heredoc line continuation is recognized.
Solution: Do not consume line continuation. (Ozaki Kiichi, closes vim/vim#4580)
https://github.com/vim/vim/commit/e96a2498f9a2d3e93ac07431f6d4afd77f30afdf
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/digraph.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 13 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 6 | ||||
-rw-r--r-- | src/nvim/ex_cmds_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 52 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 23 | ||||
-rw-r--r-- | src/nvim/fileio.c | 10 | ||||
-rw-r--r-- | src/nvim/getchar.c | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 10 |
11 files changed, 68 insertions, 58 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 5a07137831..65d95ff158 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1887,7 +1887,7 @@ void ex_loadkeymap(exarg_T *eap) // Get each line of the sourced file, break at the end. for (;;) { - line = eap->getline(0, eap->cookie, 0); + line = eap->getline(0, eap->cookie, 0, true); if (line == NULL) { break; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6d706939a1..c18d687cc1 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1561,7 +1561,7 @@ heredoc_get(exarg_T *eap, char_u *cmd) for (;;) { int i = 0; - char_u *theline = eap->getline(NUL, eap->cookie, 0); + char_u *theline = eap->getline(NUL, eap->cookie, 0, false); if (theline != NULL && indent_len > 0) { // trim the indent matching the first line if (STRNCMP(theline, *eap->cmdlinep, indent_len) == 0) { @@ -8734,7 +8734,7 @@ typedef struct { const listitem_T *li; } GetListLineCookie; -static char_u *get_list_line(int c, void *cookie, int indent) +static char_u *get_list_line(int c, void *cookie, int indent, bool do_concat) { GetListLineCookie *const p = (GetListLineCookie *)cookie; @@ -21279,6 +21279,7 @@ void ex_function(exarg_T *eap) hashitem_T *hi; int sourcing_lnum_off; bool show_block = false; + bool do_concat = true; /* * ":function" without argument: list functions. @@ -21548,9 +21549,9 @@ void ex_function(exarg_T *eap) } else { xfree(line_to_free); if (eap->getline == NULL) { - theline = getcmdline(':', 0L, indent); + theline = getcmdline(':', 0L, indent, do_concat); } else { - theline = eap->getline(':', eap->cookie, indent); + theline = eap->getline(':', eap->cookie, indent, do_concat); } line_to_free = theline; } @@ -21580,6 +21581,7 @@ void ex_function(exarg_T *eap) if (STRCMP(p, skip_until) == 0) { XFREE_CLEAR(skip_until); XFREE_CLEAR(trimmed); + do_concat = true; } } } else { @@ -21699,6 +21701,7 @@ void ex_function(exarg_T *eap) } else { skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p)); } + do_concat = false; } } @@ -23522,7 +23525,7 @@ char_u *get_return_cmd(void *rettv) * Called by do_cmdline() to get the next line. * Returns allocated string, or NULL for end of function. */ -char_u *get_func_line(int c, void *cookie, int indent) +char_u *get_func_line(int c, void *cookie, int indent, bool do_concat) { funccall_T *fcp = (funccall_T *)cookie; ufunc_T *fp = fcp->func; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b2d7ded6be..00de7a3d66 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2767,7 +2767,7 @@ void ex_append(exarg_T *eap) State = CMDLINE; theline = eap->getline( eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, indent); + NUL, eap->cookie, indent, true); State = save_State; } lines_left = Rows - 1; @@ -3630,7 +3630,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, for (; i <= (long)ec; ++i) msg_putchar('^'); - resp = getexmodeline('?', NULL, 0); + resp = getexmodeline('?', NULL, 0, true); if (resp != NULL) { typed = *resp; xfree(resp); diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 87eae2dd4f..272c81e29b 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3218,7 +3218,7 @@ int do_source(char_u *fname, int check_other, int is_vimrc) cookie.conv.vc_type = CONV_NONE; // no conversion // Read the first line so we can check for a UTF-8 BOM. - firstline = getsourceline(0, (void *)&cookie, 0); + firstline = getsourceline(0, (void *)&cookie, 0, true); if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef && firstline[1] == 0xbb && firstline[2] == 0xbf) { // Found BOM; setup conversion, skip over BOM and recode the line. @@ -3381,7 +3381,7 @@ void free_scriptnames(void) /// /// @return pointer to the line in allocated memory, or NULL for end-of-file or /// some error. -char_u *getsourceline(int c, void *cookie, int indent) +char_u *getsourceline(int c, void *cookie, int indent, bool do_concat) { struct source_cookie *sp = (struct source_cookie *)cookie; char_u *line; @@ -3412,7 +3412,7 @@ char_u *getsourceline(int c, void *cookie, int indent) // Only concatenate lines starting with a \ when 'cpoptions' doesn't // contain the 'C' flag. - if (line != NULL && (vim_strchr(p_cpo, CPO_CONCAT) == NULL)) { + if (line != NULL && do_concat && (vim_strchr(p_cpo, CPO_CONCAT) == NULL)) { // compensate for the one line read-ahead sourcing_lnum--; diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 42ba1060e9..3a9fd01dd9 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -88,7 +88,7 @@ typedef struct exarg exarg_T; typedef void (*ex_func_T)(exarg_T *eap); -typedef char_u *(*LineGetter)(int, void *, int); +typedef char_u *(*LineGetter)(int, void *, int, bool); /// Structure for command definition. typedef struct cmdname { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 8d67ab5348..0da2cd67d6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -117,11 +117,11 @@ typedef struct { * reads more lines that may come from the while/for loop. */ struct loop_cookie { - garray_T *lines_gap; /* growarray with line info */ - int current_line; /* last read line from growarray */ - int repeating; /* TRUE when looping a second time */ - /* When "repeating" is FALSE use "getline" and "cookie" to get lines */ - char_u *(*getline)(int, void *, int); + garray_T *lines_gap; // growarray with line info + int current_line; // last read line from growarray + int repeating; // TRUE when looping a second time + // When "repeating" is FALSE use "getline" and "cookie" to get lines + char_u *(*getline)(int, void *, int, bool); void *cookie; }; @@ -313,8 +313,8 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, struct msglist **saved_msg_list = NULL; struct msglist *private_msg_list; - /* "fgetline" and "cookie" passed to do_one_cmd() */ - char_u *(*cmd_getline)(int, void *, int); + // "fgetline" and "cookie" passed to do_one_cmd() + char_u *(*cmd_getline)(int, void *, int, bool); void *cmd_cookie; struct loop_cookie cmd_loop_cookie; void *real_cookie; @@ -507,17 +507,20 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, * Need to set msg_didout for the first line after an ":if", * otherwise the ":if" will be overwritten. */ - if (count == 1 && getline_equal(fgetline, cookie, getexline)) - msg_didout = TRUE; - if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, - cstack.cs_idx < - 0 ? 0 : (cstack.cs_idx + 1) * 2 - )) == NULL) { - /* Don't call wait_return for aborted command line. The NULL - * returned for the end of a sourced file or executed function - * doesn't do this. */ - if (KeyTyped && !(flags & DOCMD_REPEAT)) - need_wait_return = FALSE; + if (count == 1 && getline_equal(fgetline, cookie, getexline)) { + msg_didout = true; + } + if (fgetline == NULL + || (next_cmdline = fgetline(':', cookie, + cstack.cs_idx < + 0 ? 0 : (cstack.cs_idx + 1) * 2, + true)) == NULL) { + // Don't call wait_return for aborted command line. The NULL + // returned for the end of a sourced file or executed function + // doesn't do this. + if (KeyTyped && !(flags & DOCMD_REPEAT)) { + need_wait_return = false; + } retval = FAIL; break; } @@ -951,7 +954,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, /* * Obtain a line when inside a ":while" or ":for" loop. */ -static char_u *get_loop_line(int c, void *cookie, int indent) +static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat) { struct loop_cookie *cp = (struct loop_cookie *)cookie; wcmd_T *wp; @@ -961,11 +964,12 @@ static char_u *get_loop_line(int c, void *cookie, int indent) if (cp->repeating) return NULL; /* trying to read past ":endwhile"/":endfor" */ - /* First time inside the ":while"/":for": get line normally. */ - if (cp->getline == NULL) - line = getcmdline(c, 0L, indent); - else - line = cp->getline(c, cp->cookie, indent); + // First time inside the ":while"/":for": get line normally. + if (cp->getline == NULL) { + line = getcmdline(c, 0L, indent, do_concat); + } else { + line = cp->getline(c, cp->cookie, indent, do_concat); + } if (line != NULL) { store_loop_line(cp->lines_gap, line); ++cp->current_line; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d0af8a0fdf..5235b9e648 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1991,7 +1991,8 @@ char_u * getcmdline ( int firstc, long count, // only used for incremental search - int indent // indent for inside conditionals + int indent, // indent for inside conditionals + bool do_concat // unused ) { // Be prepared for situations where cmdline can be invoked recursively. @@ -2167,17 +2168,18 @@ static void correct_screencol(int idx, int cells, int *col) * Get an Ex command line for the ":" command. */ char_u * -getexline ( - int c, /* normally ':', NUL for ":append" */ +getexline( + int c, // normally ':', NUL for ":append" void *cookie, - int indent /* indent for inside conditionals */ + int indent, // indent for inside conditionals + bool do_concat ) { /* When executing a register, remove ':' that's in front of each line. */ if (exec_from_reg && vpeekc() == ':') (void)vgetc(); - return getcmdline(c, 1L, indent); + return getcmdline(c, 1L, indent, do_concat); } /* @@ -2187,11 +2189,12 @@ getexline ( * Returns a string in allocated memory or NULL. */ char_u * -getexmodeline ( - int promptc, /* normally ':', NUL for ":append" and '?' for - :s prompt */ +getexmodeline( + int promptc, // normally ':', NUL for ":append" and '?' + // for :s prompt void *cookie, - int indent /* indent for inside conditionals */ + int indent, // indent for inside conditionals + bool do_concat ) { garray_T line_ga; @@ -6308,7 +6311,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp) for (;;) { char *const theline = (char *)eap->getline( eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, 0); + NUL, eap->cookie, 0, true); if (theline == NULL || strcmp(end_pattern, theline) == 0) { xfree(theline); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 0394639a16..58e6b2ae92 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -7100,12 +7100,10 @@ auto_next_pat( } } -/* - * Get next autocommand command. - * Called by do_cmdline() to get the next line for ":if". - * Returns allocated string, or NULL for end of autocommands. - */ -char_u *getnextac(int c, void *cookie, int indent) +/// Get next autocommand command. +/// Called by do_cmdline() to get the next line for ":if". +/// @return allocated string, or NULL for end of autocommands. +char_u *getnextac(int c, void *cookie, int indent, bool do_concat) { AutoPatCmd *acp = (AutoPatCmd *)cookie; char_u *retval; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 1f82df3241..399f0671b4 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -4419,7 +4419,7 @@ mapblock_T *get_maphash(int index, buf_T *buf) } /// Get command argument for <Cmd> key -char_u * getcmdkeycmd(int promptc, void *cookie, int indent) +char_u * getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) { garray_T line_ga; int c1 = -1, c2; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e32b738c7e..e0dc9d4f23 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5343,7 +5343,7 @@ static void nv_search(cmdarg_T *cap) // When using 'incsearch' the cursor may be moved to set a different search // start position. - cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0); + cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, true); if (cap->searchbuf == NULL) { clearop(oap); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 6f515151d6..0d27365d2b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -671,13 +671,15 @@ int get_expr_register(void) { char_u *new_line; - new_line = getcmdline('=', 0L, 0); - if (new_line == NULL) + new_line = getcmdline('=', 0L, 0, true); + if (new_line == NULL) { return NUL; - if (*new_line == NUL) /* use previous line */ + } + if (*new_line == NUL) { // use previous line xfree(new_line); - else + } else { set_expr_line(new_line); + } return '='; } |