summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1060
blob: aaee41cbddc578e67bbdbecee7214adb29147282 (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1060
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1060
Problem:    MS-Windows: get_cmd_args() is no longer needed, get_cmd_argsW() is
            always used.
Solution:   Remove get_cmd_args(). (Ken Takata, closes #4171)
Files:	    src/gui_w32.c, src/os_w32exe.c


*** ../vim-8.1.1059/src/gui_w32.c	2019-03-21 20:50:08.868741864 +0100
--- src/gui_w32.c	2019-03-27 21:56:47.457072295 +0100
***************
*** 3882,4032 ****
  }
  
  
- /*
-  * Get command line arguments.
-  * Use "prog" as the name of the program and "cmdline" as the arguments.
-  * Copy the arguments to allocated memory.
-  * Return the number of arguments (including program name).
-  * Return pointers to the arguments in "argvp".  Memory is allocated with
-  * malloc(), use free() instead of vim_free().
-  * Return pointer to buffer in "tofree".
-  * Returns zero when out of memory.
-  */
-     int
- get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
- {
-     int		i;
-     char	*p;
-     char	*progp;
-     char	*pnew = NULL;
-     char	*newcmdline;
-     int		inquote;
-     int		argc;
-     char	**argv = NULL;
-     int		round;
- 
-     *tofree = NULL;
- 
-     /* Try using the Unicode version first, it takes care of conversion when
-      * 'encoding' is changed. */
-     argc = get_cmd_argsW(&argv);
-     if (argc != 0)
- 	goto done;
- 
-     /* Handle the program name.  Remove the ".exe" extension, and find the 1st
-      * non-space. */
-     p = strrchr(prog, '.');
-     if (p != NULL)
- 	*p = NUL;
-     for (progp = prog; *progp == ' '; ++progp)
- 	;
- 
-     /* The command line is copied to allocated memory, so that we can change
-      * it.  Add the size of the string, the separating NUL and a terminating
-      * NUL. */
-     newcmdline = malloc(STRLEN(cmdline) + STRLEN(progp) + 2);
-     if (newcmdline == NULL)
- 	return 0;
- 
-     /*
-      * First round: count the number of arguments ("pnew" == NULL).
-      * Second round: produce the arguments.
-      */
-     for (round = 1; round <= 2; ++round)
-     {
- 	/* First argument is the program name. */
- 	if (pnew != NULL)
- 	{
- 	    argv[0] = pnew;
- 	    strcpy(pnew, progp);
- 	    pnew += strlen(pnew);
- 	    *pnew++ = NUL;
- 	}
- 
- 	/*
- 	 * Isolate each argument and put it in argv[].
- 	 */
- 	p = cmdline;
- 	argc = 1;
- 	while (*p != NUL)
- 	{
- 	    inquote = FALSE;
- 	    if (pnew != NULL)
- 		argv[argc] = pnew;
- 	    ++argc;
- 	    while (*p != NUL && (inquote || (*p != ' ' && *p != '\t')))
- 	    {
- 		/* Backslashes are only special when followed by a double
- 		 * quote. */
- 		i = (int)strspn(p, "\\");
- 		if (p[i] == '"')
- 		{
- 		    /* Halve the number of backslashes. */
- 		    if (i > 1 && pnew != NULL)
- 		    {
- 			vim_memset(pnew, '\\', i / 2);
- 			pnew += i / 2;
- 		    }
- 
- 		    /* Even nr of backslashes toggles quoting, uneven copies
- 		     * the double quote. */
- 		    if ((i & 1) == 0)
- 			inquote = !inquote;
- 		    else if (pnew != NULL)
- 			*pnew++ = '"';
- 		    p += i + 1;
- 		}
- 		else if (i > 0)
- 		{
- 		    /* Copy span of backslashes unmodified. */
- 		    if (pnew != NULL)
- 		    {
- 			vim_memset(pnew, '\\', i);
- 			pnew += i;
- 		    }
- 		    p += i;
- 		}
- 		else
- 		{
- 		    if (pnew != NULL)
- 			*pnew++ = *p;
- 		    /* Can't use mb_* functions, because 'encoding' is not
- 		     * initialized yet here. */
- 		    if (IsDBCSLeadByte(*p))
- 		    {
- 			++p;
- 			if (pnew != NULL)
- 			    *pnew++ = *p;
- 		    }
- 		    ++p;
- 		}
- 	    }
- 
- 	    if (pnew != NULL)
- 		*pnew++ = NUL;
- 	    while (*p == ' ' || *p == '\t')
- 		++p;		    /* advance until a non-space */
- 	}
- 
- 	if (round == 1)
- 	{
- 	    argv = (char **)malloc((argc + 1) * sizeof(char *));
- 	    if (argv == NULL )
- 	    {
- 		free(newcmdline);
- 		return 0;		   /* malloc error */
- 	    }
- 	    pnew = newcmdline;
- 	    *tofree = newcmdline;
- 	}
-     }
- 
- done:
-     argv[argc] = NULL;		/* NULL-terminated list */
-     *argvp = argv;
-     return argc;
- }
- 
  #ifdef FEAT_XPM_W32
  # include "xpm_w32.h"
  #endif
--- 3882,3887 ----
*** ../vim-8.1.1059/src/os_w32exe.c	2019-02-17 17:44:36.219875473 +0100
--- src/os_w32exe.c	2019-03-27 21:56:47.457072295 +0100
***************
*** 10,16 ****
  /*
   * Windows GUI: main program (EXE) entry point:
   *
!  * Ron Aaron <ronaharon@yahoo.com> wrote this and  the DLL support code.
   */
  #include "vim.h"
  
--- 10,16 ----
  /*
   * Windows GUI: main program (EXE) entry point:
   *
!  * Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
   */
  #include "vim.h"
  
***************
*** 42,77 ****
  WinMain(
      HINSTANCE	hInstance UNUSED,
      HINSTANCE	hPrevInst UNUSED,
!     LPSTR	lpszCmdLine,
      int		nCmdShow UNUSED)
  {
      int		argc = 0;
!     char	**argv;
!     char	*tofree;
!     char	prog[256];
  #ifdef VIMDLL
      char	*p;
      HANDLE	hLib;
- #endif
  
      /* Ron: added full path name so that the $VIM variable will get set to our
       * startup path (so the .vimrc file can be found w/o a VIM env. var.) */
      GetModuleFileName(NULL, prog, 255);
  
!     argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
!     if (argc == 0)
!     {
! 	MessageBox(0, "Could not allocate memory for command line.",
! 							      "VIM Error", 0);
! 	return 0;
!     }
! 
! #ifdef DYNAMIC_GETTEXT
      /* Initialize gettext library */
      dyn_libintl_init();
! #endif
  
- #ifdef VIMDLL
      // LoadLibrary - get name of dll to load in here:
      p = strrchr(prog, '\\');
      if (p != NULL)
--- 42,66 ----
  WinMain(
      HINSTANCE	hInstance UNUSED,
      HINSTANCE	hPrevInst UNUSED,
!     LPSTR	lpszCmdLine UNUSED,
      int		nCmdShow UNUSED)
  {
      int		argc = 0;
!     char	**argv = NULL;
  #ifdef VIMDLL
+     char	prog[256];
      char	*p;
      HANDLE	hLib;
  
      /* Ron: added full path name so that the $VIM variable will get set to our
       * startup path (so the .vimrc file can be found w/o a VIM env. var.) */
      GetModuleFileName(NULL, prog, 255);
  
! # ifdef DYNAMIC_GETTEXT
      /* Initialize gettext library */
      dyn_libintl_init();
! # endif
  
      // LoadLibrary - get name of dll to load in here:
      p = strrchr(prog, '\\');
      if (p != NULL)
***************
*** 127,135 ****
      FreeLibrary(hLib);
  errout:
  #endif
-     free(argv);
-     if (tofree != NULL)
- 	free(tofree);
      free_cmd_argsW();
  
      return 0;
--- 116,121 ----
*** ../vim-8.1.1059/src/version.c	2019-03-27 21:49:10.761396675 +0100
--- src/version.c	2019-03-27 21:58:01.508417951 +0100
***************
*** 777,778 ****
--- 777,780 ----
  {   /* Add new patch number below this line */
+ /**/
+     1060,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
133. You communicate with people on other continents more than you
     do with your own neighbors.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///