comparison src/ex_docmd.c @ 17178:40c4cb095d53 v8.1.1588

patch 8.1.1588: in :let-heredoc line continuation is recognized commit https://github.com/vim/vim/commit/e96a2498f9a2d3e93ac07431f6d4afd77f30afdf Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 25 04:12:16 2019 +0200 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 https://github.com/vim/vim/issues/4580)
author Bram Moolenaar <Bram@vim.org>
date Tue, 25 Jun 2019 04:15:08 +0200
parents af861fccc309
children 81705f4d9e03
comparison
equal deleted inserted replaced
17177:b58feb1a84f0 17178:40c4cb095d53
18 #ifndef FEAT_PRINTER 18 #ifndef FEAT_PRINTER
19 # define ex_hardcopy ex_ni 19 # define ex_hardcopy ex_ni
20 #endif 20 #endif
21 21
22 #ifdef FEAT_EVAL 22 #ifdef FEAT_EVAL
23 static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int), void *cookie); 23 static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int, int), void *cookie);
24 #else 24 #else
25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int), void *cookie); 25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie);
26 static int if_level = 0; /* depth in :if */ 26 static int if_level = 0; /* depth in :if */
27 #endif 27 #endif
28 static void free_cmdmod(void); 28 static void free_cmdmod(void);
29 static void append_command(char_u *cmd); 29 static void append_command(char_u *cmd);
30 static char_u *find_command(exarg_T *eap, int *full); 30 static char_u *find_command(exarg_T *eap, int *full);
429 { 429 {
430 garray_T *lines_gap; /* growarray with line info */ 430 garray_T *lines_gap; /* growarray with line info */
431 int current_line; /* last read line from growarray */ 431 int current_line; /* last read line from growarray */
432 int repeating; /* TRUE when looping a second time */ 432 int repeating; /* TRUE when looping a second time */
433 /* When "repeating" is FALSE use "getline" and "cookie" to get lines */ 433 /* When "repeating" is FALSE use "getline" and "cookie" to get lines */
434 char_u *(*getline)(int, void *, int); 434 char_u *(*getline)(int, void *, int, int);
435 void *cookie; 435 void *cookie;
436 }; 436 };
437 437
438 static char_u *get_loop_line(int c, void *cookie, int indent); 438 static char_u *get_loop_line(int c, void *cookie, int indent, int do_concat);
439 static int store_loop_line(garray_T *gap, char_u *line); 439 static int store_loop_line(garray_T *gap, char_u *line);
440 static void free_cmdlines(garray_T *gap); 440 static void free_cmdlines(garray_T *gap);
441 441
442 /* Struct to save a few things while debugging. Used in do_cmdline() only. */ 442 /* Struct to save a few things while debugging. Used in do_cmdline() only. */
443 struct dbg_stuff 443 struct dbg_stuff
617 * return FAIL if cmdline could not be executed, OK otherwise 617 * return FAIL if cmdline could not be executed, OK otherwise
618 */ 618 */
619 int 619 int
620 do_cmdline( 620 do_cmdline(
621 char_u *cmdline, 621 char_u *cmdline,
622 char_u *(*fgetline)(int, void *, int), 622 char_u *(*fgetline)(int, void *, int, int),
623 void *cookie, /* argument for fgetline() */ 623 void *cookie, /* argument for fgetline() */
624 int flags) 624 int flags)
625 { 625 {
626 char_u *next_cmdline; /* next cmd to execute */ 626 char_u *next_cmdline; /* next cmd to execute */
627 char_u *cmdline_copy = NULL; /* copy of cmd line */ 627 char_u *cmdline_copy = NULL; /* copy of cmd line */
642 int initial_trylevel; 642 int initial_trylevel;
643 struct msglist **saved_msg_list = NULL; 643 struct msglist **saved_msg_list = NULL;
644 struct msglist *private_msg_list; 644 struct msglist *private_msg_list;
645 645
646 /* "fgetline" and "cookie" passed to do_one_cmd() */ 646 /* "fgetline" and "cookie" passed to do_one_cmd() */
647 char_u *(*cmd_getline)(int, void *, int); 647 char_u *(*cmd_getline)(int, void *, int, int);
648 void *cmd_cookie; 648 void *cmd_cookie;
649 struct loop_cookie cmd_loop_cookie; 649 struct loop_cookie cmd_loop_cookie;
650 void *real_cookie; 650 void *real_cookie;
651 int getline_is_func; 651 int getline_is_func;
652 #else 652 #else
892 #ifdef FEAT_EVAL 892 #ifdef FEAT_EVAL
893 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 893 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
894 #else 894 #else
895 0 895 0
896 #endif 896 #endif
897 )) == NULL) 897 , TRUE)) == NULL)
898 { 898 {
899 /* Don't call wait_return for aborted command line. The NULL 899 /* Don't call wait_return for aborted command line. The NULL
900 * returned for the end of a sourced file or executed function 900 * returned for the end of a sourced file or executed function
901 * doesn't do this. */ 901 * doesn't do this. */
902 if (KeyTyped && !(flags & DOCMD_REPEAT)) 902 if (KeyTyped && !(flags & DOCMD_REPEAT))
1422 #ifdef FEAT_EVAL 1422 #ifdef FEAT_EVAL
1423 /* 1423 /*
1424 * Obtain a line when inside a ":while" or ":for" loop. 1424 * Obtain a line when inside a ":while" or ":for" loop.
1425 */ 1425 */
1426 static char_u * 1426 static char_u *
1427 get_loop_line(int c, void *cookie, int indent) 1427 get_loop_line(int c, void *cookie, int indent, int do_concat)
1428 { 1428 {
1429 struct loop_cookie *cp = (struct loop_cookie *)cookie; 1429 struct loop_cookie *cp = (struct loop_cookie *)cookie;
1430 wcmd_T *wp; 1430 wcmd_T *wp;
1431 char_u *line; 1431 char_u *line;
1432 1432
1435 if (cp->repeating) 1435 if (cp->repeating)
1436 return NULL; /* trying to read past ":endwhile"/":endfor" */ 1436 return NULL; /* trying to read past ":endwhile"/":endfor" */
1437 1437
1438 /* First time inside the ":while"/":for": get line normally. */ 1438 /* First time inside the ":while"/":for": get line normally. */
1439 if (cp->getline == NULL) 1439 if (cp->getline == NULL)
1440 line = getcmdline(c, 0L, indent); 1440 line = getcmdline(c, 0L, indent, do_concat);
1441 else 1441 else
1442 line = cp->getline(c, cp->cookie, indent); 1442 line = cp->getline(c, cp->cookie, indent, do_concat);
1443 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) 1443 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK)
1444 ++cp->current_line; 1444 ++cp->current_line;
1445 1445
1446 return line; 1446 return line;
1447 } 1447 }
1485 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals 1485 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals
1486 * "func". * Otherwise return TRUE when "fgetline" equals "func". 1486 * "func". * Otherwise return TRUE when "fgetline" equals "func".
1487 */ 1487 */
1488 int 1488 int
1489 getline_equal( 1489 getline_equal(
1490 char_u *(*fgetline)(int, void *, int), 1490 char_u *(*fgetline)(int, void *, int, int),
1491 void *cookie UNUSED, /* argument for fgetline() */ 1491 void *cookie UNUSED, /* argument for fgetline() */
1492 char_u *(*func)(int, void *, int)) 1492 char_u *(*func)(int, void *, int, int))
1493 { 1493 {
1494 #ifdef FEAT_EVAL 1494 #ifdef FEAT_EVAL
1495 char_u *(*gp)(int, void *, int); 1495 char_u *(*gp)(int, void *, int, int);
1496 struct loop_cookie *cp; 1496 struct loop_cookie *cp;
1497 1497
1498 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the 1498 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the
1499 * function that's originally used to obtain the lines. This may be 1499 * function that's originally used to obtain the lines. This may be
1500 * nested several levels. */ 1500 * nested several levels. */
1515 * If "fgetline" is get_loop_line(), return the cookie used by the original 1515 * If "fgetline" is get_loop_line(), return the cookie used by the original
1516 * getline function. Otherwise return "cookie". 1516 * getline function. Otherwise return "cookie".
1517 */ 1517 */
1518 void * 1518 void *
1519 getline_cookie( 1519 getline_cookie(
1520 char_u *(*fgetline)(int, void *, int) UNUSED, 1520 char_u *(*fgetline)(int, void *, int, int) UNUSED,
1521 void *cookie) /* argument for fgetline() */ 1521 void *cookie) /* argument for fgetline() */
1522 { 1522 {
1523 #ifdef FEAT_EVAL 1523 #ifdef FEAT_EVAL
1524 char_u *(*gp)(int, void *, int); 1524 char_u *(*gp)(int, void *, int, int);
1525 struct loop_cookie *cp; 1525 struct loop_cookie *cp;
1526 1526
1527 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the 1527 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the
1528 * cookie that's originally used to obtain the lines. This may be nested 1528 * cookie that's originally used to obtain the lines. This may be nested
1529 * several levels. */ 1529 * several levels. */
1652 char_u **cmdlinep, 1652 char_u **cmdlinep,
1653 int sourcing, 1653 int sourcing,
1654 #ifdef FEAT_EVAL 1654 #ifdef FEAT_EVAL
1655 struct condstack *cstack, 1655 struct condstack *cstack,
1656 #endif 1656 #endif
1657 char_u *(*fgetline)(int, void *, int), 1657 char_u *(*fgetline)(int, void *, int, int),
1658 void *cookie) /* argument for fgetline() */ 1658 void *cookie) /* argument for fgetline() */
1659 { 1659 {
1660 char_u *p; 1660 char_u *p;
1661 linenr_T lnum; 1661 linenr_T lnum;
1662 long n; 1662 long n;