summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2010-10-13 17:50:07 +0200
committerBram Moolenaar <bram@vim.org>2010-10-13 17:50:07 +0200
commitbd5a78654a96e7f50bffa3b01bd438fdb37e6ac6 (patch)
treea67455d959add2260e389fe8db1e9e8842733880
parent1f319d3166b5bbe85a3b7677fe29a252bfd4097c (diff)
downloadvim-bd5a78654a96e7f50bffa3b01bd438fdb37e6ac6.tar.gz
updated for version 7.3.025v7.3.025v7-3-025
Problem: ":mksession" does not square brackets escape file name properly. Solution: Improve escapging of file names. (partly by Peter Odding)
-rw-r--r--src/ex_docmd.c59
-rw-r--r--src/version.c2
2 files changed, 23 insertions, 38 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 0940ad86..fe1bfe74 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -10708,7 +10708,7 @@ ses_fname(fd, buf, flagp)
* Write a file name to the session file.
* Takes care of the "slash" option in 'sessionoptions' and escapes special
* characters.
- * Returns FAIL if writing fails.
+ * Returns FAIL if writing fails or out of memory.
*/
static int
ses_put_fname(fd, name, flagp)
@@ -10717,49 +10717,32 @@ ses_put_fname(fd, name, flagp)
unsigned *flagp;
{
char_u *sname;
+ char_u *p;
int retval = OK;
- int c;
sname = home_replace_save(NULL, name);
- if (sname != NULL)
- name = sname;
- while (*name != NUL)
- {
-#ifdef FEAT_MBYTE
- {
- int l;
+ if (sname == NULL)
+ return FAIL;
- if (has_mbyte && (l = (*mb_ptr2len)(name)) > 1)
- {
- /* copy a multibyte char */
- while (--l >= 0)
- {
- if (putc(*name, fd) != *name)
- retval = FAIL;
- ++name;
- }
- continue;
- }
- }
-#endif
- c = *name++;
- if (c == '\\' && (*flagp & SSOP_SLASH))
- /* change a backslash to a forward slash */
- c = '/';
- else if ((vim_strchr(escape_chars, c) != NULL
-#ifdef BACKSLASH_IN_FILENAME
- && c != '\\'
-#endif
- ) || c == '#' || c == '%')
- {
- /* escape a special character with a backslash */
- if (putc('\\', fd) != '\\')
- retval = FAIL;
- }
- if (putc(c, fd) != c)
- retval = FAIL;
+ if (*flagp & SSOP_SLASH)
+ {
+ /* change all backslashes to forward slashes */
+ for (p = sname; *p != NUL; mb_ptr_adv(p))
+ if (*p == '\\')
+ *p = '/';
}
+
+ /* escapse special characters */
+ p = vim_strsave_fnameescape(sname, FALSE);
vim_free(sname);
+ if (p == NULL)
+ return FAIL;
+
+ /* write the result */
+ if (fputs((char *)p, fd) < 0)
+ retval = FAIL;
+
+ vim_free(p);
return retval;
}
diff --git a/src/version.c b/src/version.c
index 882f9a14..9959c79d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 25,
+/**/
24,
/**/
23,