Mercurial > vim
comparison src/ex_docmd.c @ 14393:c62601adad69 v8.1.0211
patch 8.1.0211: expanding a file name "~" results in $HOME
commit https://github.com/vim/vim/commit/00136dc321586800986e8f743c2f108f5eecbf92
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 25 21:19:13 2018 +0200
patch 8.1.0211: expanding a file name "~" results in $HOME
Problem: Expanding a file name "~" results in $HOME. (Aidan Shafran)
Solution: Change "~" to "./~" before expanding. (closes https://github.com/vim/vim/issues/3072)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 25 Jul 2018 21:30:06 +0200 |
parents | 95030c543411 |
children | 289b850d2cbf |
comparison
equal
deleted
inserted
replaced
14392:3d1aca4a35f8 | 14393:c62601adad69 |
---|---|
10652 char_u *result; | 10652 char_u *result; |
10653 char_u *resultbuf = NULL; | 10653 char_u *resultbuf = NULL; |
10654 int resultlen; | 10654 int resultlen; |
10655 buf_T *buf; | 10655 buf_T *buf; |
10656 int valid = VALID_HEAD + VALID_PATH; /* assume valid result */ | 10656 int valid = VALID_HEAD + VALID_PATH; /* assume valid result */ |
10657 int tilde_file = FALSE; | |
10657 int spec_idx; | 10658 int spec_idx; |
10658 #ifdef FEAT_MODIFY_FNAME | 10659 #ifdef FEAT_MODIFY_FNAME |
10659 int skip_mod = FALSE; | 10660 int skip_mod = FALSE; |
10660 #endif | 10661 #endif |
10661 char_u strbuf[30]; | 10662 char_u strbuf[30]; |
10718 { | 10719 { |
10719 result = (char_u *)""; | 10720 result = (char_u *)""; |
10720 valid = 0; /* Must have ":p:h" to be valid */ | 10721 valid = 0; /* Must have ":p:h" to be valid */ |
10721 } | 10722 } |
10722 else | 10723 else |
10724 { | |
10723 result = curbuf->b_fname; | 10725 result = curbuf->b_fname; |
10726 tilde_file = STRCMP(result, "~") == 0; | |
10727 } | |
10724 break; | 10728 break; |
10725 | 10729 |
10726 case SPEC_HASH: /* '#' or "#99": alternate file */ | 10730 case SPEC_HASH: /* '#' or "#99": alternate file */ |
10727 if (src[1] == '#') /* "##": the argument list */ | 10731 if (src[1] == '#') /* "##": the argument list */ |
10728 { | 10732 { |
10782 { | 10786 { |
10783 result = (char_u *)""; | 10787 result = (char_u *)""; |
10784 valid = 0; /* Must have ":p:h" to be valid */ | 10788 valid = 0; /* Must have ":p:h" to be valid */ |
10785 } | 10789 } |
10786 else | 10790 else |
10791 { | |
10787 result = buf->b_fname; | 10792 result = buf->b_fname; |
10793 tilde_file = STRCMP(result, "~") == 0; | |
10794 } | |
10788 } | 10795 } |
10789 break; | 10796 break; |
10790 | 10797 |
10791 #ifdef FEAT_SEARCHPATH | 10798 #ifdef FEAT_SEARCHPATH |
10792 case SPEC_CFILE: /* file name under cursor */ | 10799 case SPEC_CFILE: /* file name under cursor */ |
10875 resultlen = (int)(s - result); | 10882 resultlen = (int)(s - result); |
10876 } | 10883 } |
10877 #ifdef FEAT_MODIFY_FNAME | 10884 #ifdef FEAT_MODIFY_FNAME |
10878 else if (!skip_mod) | 10885 else if (!skip_mod) |
10879 { | 10886 { |
10880 valid |= modify_fname(src, usedlen, &result, &resultbuf, | 10887 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
10881 &resultlen); | 10888 &resultlen); |
10882 if (result == NULL) | 10889 if (result == NULL) |
10883 { | 10890 { |
10884 *errormsg = (char_u *)""; | 10891 *errormsg = (char_u *)""; |
10885 return NULL; | 10892 return NULL; |