From faa9744f5d13c94c7298bf08e8d1eedca5db88a9 Mon Sep 17 00:00:00 2001 From: YX Hao Date: Sun, 8 Oct 2017 17:28:02 +0800 Subject: Win: crt, initialize global __argc, __targv and _tenviron of msvcrt _tenviron: as far as possible, not in ASC '-run' mode. __argc and __targv are shortcuts for _tWinMain, when you want to use program parameters. --- win32/lib/crt1.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'win32/lib/crt1.c') diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c index 2cb25c0..53e5545 100644 --- a/win32/lib/crt1.c +++ b/win32/lib/crt1.c @@ -44,9 +44,7 @@ int _dowildcard; void _tstart(void) { __TRY__ - int argc, ret; - _TCHAR **argv; - _TCHAR **env; + int ret; _startupinfo start_info; // Sets the current application type @@ -60,31 +58,31 @@ void _tstart(void) #endif start_info.newmode = 0; - __tgetmainargs( &argc, &argv, &env, _dowildcard, &start_info); - ret = _tmain(argc, argv, env); + __tgetmainargs( &__argc, &__targv, &_tenviron, _dowildcard, &start_info); + ret = _tmain(__argc, __targv, _tenviron); exit(ret); } int _runtmain(int argc, /* as tcc passed in */ char **argv) { #ifdef UNICODE - int wargc; - _TCHAR **wargv, **wenv; _startupinfo start_info = {0}; - __tgetmainargs(&wargc, &wargv, &wenv, _dowildcard, &start_info); + __tgetmainargs(&__argc, &__targv, &_tenviron, _dowildcard, &start_info); /* may be wrong when tcc has received wildcards (*.c) */ - if (argc < wargc) - wargv += wargc - argc; - else - argc = wargc; -#define argv wargv + if (argc < __argc) { + __targv += __argc - argc; + __argc = argc; + } +#else + __argc = argc; + __targv = argv; #endif #ifdef __i386 _controlfp(_PC_53, _MCW_PC); #endif - return _tmain(argc, argv, _tenviron); + return _tmain(__argc, __targv, _tenviron); } // ============================================= -- cgit v1.3.1