vim-patch:7.4.832

Problem:    $HOME in `=$HOME . '/.vimrc'` is expanded too early.
Solution:   Skip over `=expr` when expanding environment names.

be83b73ddb

---

To reproduce:

```sh
nvim -u NONE -c 'e `=$HOME . "/.vimrc"`'
```
This commit is contained in:
watiko
2016-02-12 22:59:34 +09:00
parent c8561ecf26
commit 6ea1047585
2 changed files with 19 additions and 2 deletions

View File

@@ -262,8 +262,25 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
startstr_len = (int)STRLEN(startstr);
src = skipwhite(srcp);
--dstlen; // leave one char space for "\,"
dstlen--; // leave one char space for "\,"
while (*src && dstlen > 0) {
// Skip over `=expr`.
if (src[0] == '`' && src[1] == '=') {
var = src;
src += 2;
(void)skip_expr(&src);
if (*src == '`') {
src++;
}
size_t len = (size_t)(src - var);
if (len > (size_t)dstlen) {
len = (size_t)dstlen;
}
memcpy((char *)dst, (char *)var, len);
dst += len;
dstlen -= len;
continue;
}
copy_char = true;
if ((*src == '$') || (*src == '~' && at_start)) {
mustfree = false;

View File

@@ -458,7 +458,7 @@ static int included_patches[] = {
835,
834,
833,
// 832,
832,
831,
830,
// 829 NA