summaryrefslogtreecommitdiff
path: root/data/vim/patches/7.2.010
blob: 47315881e92da6ae57790213e6cf98d4122db6b0 (plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
To: vim-dev@vim.org
Subject: Patch 7.2.010
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.010
Problem:    When using "K" in Visual mode not all characters are properly
	    escaped. (Ben Schmidt)
Solution:   Use a function with the functionality of shellescape(). (Jan
	    Minar)
Files:	    src/mbyte.c, src/misc2.c, src/normal.c


*** ../vim-7.2.009/src/mbyte.c	Wed Aug  6 18:45:36 2008
--- src/mbyte.c	Wed Sep  3 22:34:48 2008
***************
*** 2540,2546 ****
      return (int)(p - q);
  }
  
- #if defined(FEAT_EVAL) || defined(PROTO)
  /*
   * Copy a character from "*fp" to "*tp" and advance the pointers.
   */
--- 2540,2545 ----
***************
*** 2555,2561 ****
      *tp += l;
      *fp += l;
  }
- #endif
  
  /*
   * Return the offset from "p" to the first byte of a character.  When "p" is
--- 2554,2559 ----
*** ../vim-7.2.009/src/misc2.c	Thu Jul 24 20:28:58 2008
--- src/misc2.c	Wed Sep  3 22:05:21 2008
***************
*** 1257,1263 ****
      return escaped_string;
  }
  
- #if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO)
  /*
   * Return TRUE when 'shell' has "csh" in the tail.
   */
--- 1257,1262 ----
***************
*** 1266,1274 ****
  {
      return (strstr((char *)gettail(p_sh), "csh") != NULL);
  }
- #endif
  
- #if defined(FEAT_EVAL) || defined(PROTO)
  /*
   * Escape "string" for use as a shell argument with system().
   * This uses single quotes, except when we know we need to use double qoutes
--- 1265,1271 ----
***************
*** 1391,1397 ****
  
      return escaped_string;
  }
- #endif
  
  /*
   * Like vim_strsave(), but make all characters uppercase.
--- 1388,1393 ----
*** ../vim-7.2.009/src/normal.c	Thu Jul 31 22:03:54 2008
--- src/normal.c	Sat Sep  6 15:06:07 2008
***************
*** 5469,5474 ****
--- 5469,5479 ----
  		STRCPY(buf, "he! ");
  	    else
  	    {
+ 		/* An external command will probably use an argument starting
+ 		 * with "-" as an option.  To avoid trouble we skip the "-". */
+ 		while (*ptr == '-')
+ 		    ++ptr;
+ 
  		/* When a count is given, turn it into a range.  Is this
  		 * really what we want? */
  		isman = (STRCMP(kp, "man") == 0);
***************
*** 5511,5547 ****
      /*
       * Now grab the chars in the identifier
       */
!     if (cmdchar == '*')
! 	aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
!     else if (cmdchar == '#')
! 	aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
!     else if (cmdchar == 'K' && !kp_help)
! 	aux_ptr = (char_u *)" \t\\\"|!";
!     else
! 	/* Don't escape spaces and Tabs in a tag with a backslash */
! 	aux_ptr = (char_u *)"\\|\"";
! 
!     p = buf + STRLEN(buf);
!     while (n-- > 0)
!     {
! 	/* put a backslash before \ and some others */
! 	if (vim_strchr(aux_ptr, *ptr) != NULL)
! 	    *p++ = '\\';
! #ifdef FEAT_MBYTE
! 	/* When current byte is a part of multibyte character, copy all bytes
! 	 * of that character. */
! 	if (has_mbyte)
  	{
! 	    int i;
! 	    int len = (*mb_ptr2len)(ptr) - 1;
! 
! 	    for (i = 0; i < len && n >= 1; ++i, --n)
! 		*p++ = *ptr++;
  	}
  #endif
! 	*p++ = *ptr++;
      }
-     *p = NUL;
  
      /*
       * Execute the command.
--- 5516,5572 ----
      /*
       * Now grab the chars in the identifier
       */
!     if (cmdchar == 'K' && !kp_help)
!     {
! 	/* Escape the argument properly for a shell command */
! 	p = vim_strsave_shellescape(ptr, TRUE);
! 	if (p == NULL)
  	{
! 	    vim_free(buf);
! 	    return;
  	}
+ 	buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
+ 	if (buf == NULL)
+ 	{
+ 	    vim_free(buf);
+ 	    vim_free(p);
+ 	    return;
+ 	}
+ 	STRCAT(buf, p);
+ 	vim_free(p);
+     }
+     else
+     {
+ 	if (cmdchar == '*')
+ 	    aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
+ 	else if (cmdchar == '#')
+ 	    aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
+ 	else
+ 	    /* Don't escape spaces and Tabs in a tag with a backslash */
+ 	    aux_ptr = (char_u *)"\\|\"\n*?[";
+ 
+ 	p = buf + STRLEN(buf);
+ 	while (n-- > 0)
+ 	{
+ 	    /* put a backslash before \ and some others */
+ 	    if (vim_strchr(aux_ptr, *ptr) != NULL)
+ 		*p++ = '\\';
+ #ifdef FEAT_MBYTE
+ 	    /* When current byte is a part of multibyte character, copy all
+ 	     * bytes of that character. */
+ 	    if (has_mbyte)
+ 	    {
+ 		int i;
+ 		int len = (*mb_ptr2len)(ptr) - 1;
+ 
+ 		for (i = 0; i < len && n >= 1; ++i, --n)
+ 		    *p++ = *ptr++;
+ 	    }
  #endif
! 	    *p++ = *ptr++;
! 	}
! 	*p = NUL;
      }
  
      /*
       * Execute the command.
*** ../vim-7.2.009/src/version.c	Mon Sep  1 17:56:05 2008
--- src/version.c	Sat Sep  6 16:26:42 2008
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     10,
  /**/

-- 
Q. What happens to programmers when they die?
A: MS-Windows programmers are reinstalled.  C++ programmers become undefined,
   anyone who refers to them will die as well.  Java programmers reincarnate
   after being garbage collected.

 /// 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    ///