File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -1847,3 +1847,18 @@ int mingw_offset_1st_component(const char *path)
1847
1847
1848
1848
return offset + is_dir_sep (path [offset ]);
1849
1849
}
1850
+
1851
+ void mingw_startup ()
1852
+ {
1853
+ /* copy executable name to argv[0] */
1854
+ __argv [0 ] = xstrdup (_pgmptr );
1855
+
1856
+ /* initialize critical section for waitpid pinfo_t list */
1857
+ InitializeCriticalSection (& pinfo_cs );
1858
+
1859
+ /* set up default file mode and file modes for stdin/out/err */
1860
+ _fmode = _O_BINARY ;
1861
+ _setmode (_fileno (stdin ), _O_BINARY );
1862
+ _setmode (_fileno (stdout ), _O_BINARY );
1863
+ _setmode (_fileno (stderr ), _O_BINARY );
1864
+ }
Original file line number Diff line number Diff line change @@ -363,22 +363,16 @@ void free_environ(char **env);
363
363
extern CRITICAL_SECTION pinfo_cs ;
364
364
365
365
/*
366
- * A replacement of main() that ensures that argv[0] has a path
367
- * and that default fmode and std(in|out|err) are in binary mode
366
+ * A replacement of main() that adds win32 specific initialization.
368
367
*/
369
368
369
+ void mingw_startup ();
370
370
#define main (c ,v ) dummy_decl_mingw_main(); \
371
371
static int mingw_main(c,v); \
372
372
int main(int argc, char **argv) \
373
373
{ \
374
- extern CRITICAL_SECTION pinfo_cs; \
375
- _fmode = _O_BINARY; \
376
- _setmode(_fileno(stdin), _O_BINARY); \
377
- _setmode(_fileno(stdout), _O_BINARY); \
378
- _setmode(_fileno(stderr), _O_BINARY); \
379
- argv[0] = xstrdup(_pgmptr); \
380
- InitializeCriticalSection(&pinfo_cs); \
381
- return mingw_main(argc, argv); \
374
+ mingw_startup(); \
375
+ return mingw_main(__argc, (void *)__argv); \
382
376
} \
383
377
static int mingw_main(c,v)
384
378
You can’t perform that action at this time.
0 commit comments