diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-07-21 14:14:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-07-21 14:14:26 +0200 |
commit | 24582007294b0db3be9669d3b583ea45fc4f19b8 (patch) | |
tree | bc9d1f58df11d4ec6e1c5afc0a495b81c3bb196f | |
parent | 61343f0c44c8e71df04918d033e0a744c0b7f8aa (diff) | |
download | vim-git-24582007294b0db3be9669d3b583ea45fc4f19b8.tar.gz |
patch 8.1.1723: heredoc assignment has no room for new featuresv8.1.1723
Problem: Heredoc assignment has no room for new features. (FUJIWARA Takuya)
Solution: Require the marker does not start with a lower case character.
(closes #4705)
-rw-r--r-- | runtime/doc/eval.txt | 6 | ||||
-rw-r--r-- | src/eval.c | 12 | ||||
-rw-r--r-- | src/testdir/test_let.vim | 34 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 39 insertions, 15 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 1fa42b393..6a44c9f3a 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -11386,7 +11386,8 @@ This does NOT work: > Like above, but append/add/subtract the value for each |List| item. - *:let=<<* *:let-heredoc* *E990* *E991* + *:let=<<* *:let-heredoc* + *E990* *E991* *E172* *E221* :let {var-name} =<< [trim] {marker} text... text... @@ -11394,11 +11395,10 @@ text... Set internal variable {var-name} to a List containing the lines of text bounded by the string {marker}. {marker} must not contain white space. + {marker} cannot start with a lower case character. The last line should end only with the {marker} string without any other character. Watch out for white space after {marker}! - If {marker} is not supplied, then "." is used as the - default marker. Without "trim" any white space characters in the lines of text are preserved. If "trim" is specified before diff --git a/src/eval.c b/src/eval.c index d633f4502..5a4ed677d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1283,7 +1283,7 @@ heredoc_get(exarg_T *eap, char_u *cmd) text_indent_len = -1; } - // The marker is the next word. Default marker is "." + // The marker is the next word. if (*cmd != NUL && *cmd != '"') { marker = skipwhite(cmd); @@ -1294,9 +1294,17 @@ heredoc_get(exarg_T *eap, char_u *cmd) return NULL; } *p = NUL; + if (vim_islower(*marker)) + { + emsg(_("E221: Marker cannot start with lower case letter")); + return NULL; + } } else - marker = (char_u *)"."; + { + emsg(_("E172: Missing marker")); + return NULL; + } l = list_alloc(); if (l == NULL) diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim index f9c0d0d1b..36900821b 100644 --- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -164,14 +164,28 @@ func Test_let_heredoc_fails() call assert_fails('source XheredocFail', 'E126:') call delete('XheredocFail') - let text =<< trim END + let text =<< trim CodeEnd func MissingEnd() let v =<< END endfunc - END + CodeEnd call writefile(text, 'XheredocWrong') call assert_fails('source XheredocWrong', 'E126:') call delete('XheredocWrong') + + let text =<< trim TEXTend + let v =<< " comment + TEXTend + call writefile(text, 'XheredocNoMarker') + call assert_fails('source XheredocNoMarker', 'E172:') + call delete('XheredocNoMarker') + + let text =<< trim TEXTend + let v =<< text + TEXTend + call writefile(text, 'XheredocBadMarker') + call assert_fails('source XheredocBadMarker', 'E221:') + call delete('XheredocBadMarker') endfunc " Test for the setting a variable using the heredoc syntax @@ -184,9 +198,9 @@ END call assert_equal(["Some sample text", "\tText with indent", " !@#$%^&*()-+_={}|[]\\~`:\";'<>?,./"], var1) - let var2 =<< + let var2 =<< XXX Editor -. +XXX call assert_equal(['Editor'], var2) let var3 =<<END @@ -218,9 +232,9 @@ END !!! call assert_equal(['Line1', ' line2', "\tLine3", '!!!',], var1) - let var1 =<< trim + let var1 =<< trim XX Line1 - . + XX call assert_equal(['Line1'], var1) " ignore "endfunc" @@ -260,16 +274,16 @@ END call assert_equal(['something', 'python << xx'], var1) " ignore "append" - let var1 =<< + let var1 =<< E something app -. +E call assert_equal(['something', 'app'], var1) " ignore "append" with trim - let var1 =<< trim + let var1 =<< trim END something app - . + END call assert_equal(['something', 'app'], var1) endfunc diff --git a/src/version.c b/src/version.c index 36a777947..5dc4d0ca5 100644 --- a/src/version.c +++ b/src/version.c @@ -778,6 +778,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1723, +/**/ 1722, /**/ 1721, |