@@ -184,6 +184,26 @@ static int strip_prefix(LPWSTR str, int *len, LPCWSTR prefix)
184
184
return 0 ;
185
185
}
186
186
187
+ static void extract_first_arg (LPWSTR command_line , LPWSTR exepath , LPWSTR buf )
188
+ {
189
+ LPWSTR * wargv ;
190
+ int wargc ;
191
+
192
+ wargv = CommandLineToArgvW (command_line , & wargc );
193
+ if (wargc < 1 ) {
194
+ fwprintf (stderr , L"Invalid command-line: '%s'\n" , command_line );
195
+ exit (1 );
196
+ }
197
+ if (* wargv [0 ] == L'\\' ||
198
+ (isalpha (* wargv [0 ]) && wargv [0 ][1 ] == L':' ))
199
+ wcscpy (buf , wargv [0 ]);
200
+ else {
201
+ wcscpy (buf , exepath );
202
+ PathAppend (buf , wargv [0 ]);
203
+ }
204
+ LocalFree (wargv );
205
+ }
206
+
187
207
static int configure_via_resource (LPWSTR basename , LPWSTR exepath , LPWSTR exep ,
188
208
LPWSTR * prefix_args , int * prefix_args_len ,
189
209
int * is_git_command , LPWSTR * working_directory , int * full_path ,
@@ -264,20 +284,7 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
264
284
atat [env_len - 1 ] = save ;
265
285
}
266
286
267
- /* parse first argument */
268
- wargv = CommandLineToArgvW (buf , & wargc );
269
- if (wargc < 1 ) {
270
- fwprintf (stderr , L"Invalid command-line: '%s'\n" , buf );
271
- exit (1 );
272
- }
273
- if (* wargv [0 ] == L'\\' ||
274
- (isalpha (* wargv [0 ]) && wargv [0 ][1 ] == L':' ))
275
- wcscpy (exep , wargv [0 ]);
276
- else {
277
- wcscpy (exep , exepath );
278
- PathAppend (exep , wargv [0 ]);
279
- }
280
- LocalFree (wargv );
287
+ extract_first_arg (buf , exepath , exep );
281
288
282
289
if (_waccess (exep , 0 ) != -1 )
283
290
break ;
0 commit comments