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)
18471847
18481848 return offset + is_dir_sep (path [offset ]);
18491849}
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);
363363extern CRITICAL_SECTION pinfo_cs ;
364364
365365/*
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.
368367 */
369368
369+ void mingw_startup ();
370370#define main (c ,v ) dummy_decl_mingw_main(); \
371371static int mingw_main(c,v); \
372372int main(int argc, char **argv) \
373373{ \
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); \
382376} \
383377static int mingw_main(c,v)
384378
You can’t perform that action at this time.
0 commit comments