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