summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.025
blob: 0fb3bee6582da5a05f08c84c60c8a4ea38985374 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
To: vim-dev@vim.org
Subject: Patch 7.3.025
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.025
Problem:    ":mksession" does not square brackets escape file name properly.
Solution:   Improve escapging of file names. (partly by Peter Odding)
Files:	    src/ex_docmd.c


*** ../vim-7.3.024/src/ex_docmd.c	2010-09-21 16:56:29.000000000 +0200
--- src/ex_docmd.c	2010-10-13 17:39:17.000000000 +0200
***************
*** 10708,10714 ****
   * 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.
   */
      static int
  ses_put_fname(fd, name, flagp)
--- 10708,10714 ----
   * 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 or out of memory.
   */
      static int
  ses_put_fname(fd, name, flagp)
***************
*** 10717,10765 ****
      unsigned	*flagp;
  {
      char_u	*sname;
      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 (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;
      }
      vim_free(sname);
      return retval;
  }
  
--- 10717,10748 ----
      unsigned	*flagp;
  {
      char_u	*sname;
+     char_u	*p;
      int		retval = OK;
  
      sname = home_replace_save(NULL, name);
!     if (sname == NULL)
! 	return 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;
  }
  
*** ../vim-7.3.024/src/version.c	2010-10-13 16:44:17.000000000 +0200
--- src/version.c	2010-10-13 17:49:15.000000000 +0200
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     25,
  /**/

-- 
"Time flies like an arrow".  So I put an arrow on my desk, now
awaiting one of these time flies showing up.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///