summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2011-08-17 15:23:23 +0200
committerBram Moolenaar <Bram@vim.org>2011-08-17 15:23:23 +0200
commitdc93555c0feee4f52e1535784b9cb02023888d8c (patch)
tree20bfb331e6b75458970d9b950e92b51f7314b0e5 /src/eval.c
parentc95e32635c24465e618b67c312bcd0a038632759 (diff)
updated for version 7.3.281v7.3.281
Problem: After using "expand('%:8')" the buffer name is changed. Solution: Make a copy of the file name before shortening it.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/eval.c b/src/eval.c
index 22779e3b16..e9ab0359a8 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -23205,6 +23205,7 @@ modify_fname(src, usedlen, fnamep, bufp, fnamelen)
int c;
int has_fullname = 0;
#ifdef WIN3264
+ char_u *fname_start = *fnamep;
int has_shortname = 0;
#endif
@@ -23379,24 +23380,25 @@ repeat:
}
#ifdef WIN3264
- /* Check shortname after we have done 'heads' and before we do 'tails'
+ /*
+ * Handle ":8" after we have done 'heads' and before we do 'tails'.
*/
if (has_shortname)
{
- pbuf = NULL;
- /* Copy the string if it is shortened by :h */
- if (*fnamelen < (int)STRLEN(*fnamep))
+ /* Copy the string if it is shortened by :h and when it wasn't copied
+ * yet, because we are going to change it in place. Avoids changing
+ * the buffer name for "%:8". */
+ if (*fnamelen < (int)STRLEN(*fnamep) || *fnamep == fname_start)
{
p = vim_strnsave(*fnamep, *fnamelen);
- if (p == 0)
+ if (p == NULL)
return -1;
vim_free(*bufp);
*bufp = *fnamep = p;
}
/* Split into two implementations - makes it easier. First is where
- * there isn't a full name already, second is where there is.
- */
+ * there isn't a full name already, second is where there is. */
if (!has_fullname && !vim_isAbsName(*fnamep))
{
if (shortpath_for_partial(fnamep, bufp, fnamelen) == FAIL)
@@ -23404,18 +23406,16 @@ repeat:
}
else
{
- int l;
+ int l = *fnamelen;
- /* Simple case, already have the full-name
+ /* Simple case, already have the full-name.
* Nearly always shorter, so try first time. */
- l = *fnamelen;
if (get_short_pathname(fnamep, bufp, &l) == FAIL)
return -1;
if (l == 0)
{
- /* Couldn't find the filename.. search the paths.
- */
+ /* Couldn't find the filename, search the paths. */
l = *fnamelen;
if (shortpath_for_invalid_fname(fnamep, bufp, &l) == FAIL)
return -1;