mirror of
https://github.com/frida/tinycc
synced 2025-01-03 02:24:24 +03:00
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.
This commit is contained in:
parent
6f1860e200
commit
faa9744f5d
@ -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);
|
||||
}
|
||||
|
||||
// =============================================
|
||||
|
@ -33,31 +33,25 @@ int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int glob
|
||||
int _twinstart(void)
|
||||
{
|
||||
__TRY__
|
||||
_TCHAR *szCmd;
|
||||
_TCHAR *szCmd, *p;
|
||||
STARTUPINFO startinfo;
|
||||
_startupinfo start_info_con = {0};
|
||||
int fShow;
|
||||
int ret;
|
||||
|
||||
__set_app_type(__GUI_APP);
|
||||
_controlfp(0x10000, 0x30000);
|
||||
|
||||
szCmd = GetCommandLine();
|
||||
if (szCmd) {
|
||||
while (__T(' ') == *szCmd)
|
||||
szCmd++;
|
||||
if (__T('\"') == *szCmd) {
|
||||
while (*++szCmd)
|
||||
if (__T('\"') == *szCmd) {
|
||||
szCmd++;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
while (*szCmd && __T(' ') != *szCmd)
|
||||
szCmd++;
|
||||
}
|
||||
while (__T(' ') == *szCmd)
|
||||
szCmd++;
|
||||
}
|
||||
start_info_con.newmode = 0;
|
||||
__tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con);
|
||||
|
||||
p = GetCommandLine();
|
||||
if (__argc > 1)
|
||||
szCmd = _tcsstr(p, __targv[1]);
|
||||
if (NULL == szCmd)
|
||||
szCmd = __T("");
|
||||
else if (szCmd > p && szCmd[-1] == __T('\"'))
|
||||
--szCmd;
|
||||
|
||||
GetStartupInfo(&startinfo);
|
||||
fShow = startinfo.wShowWindow;
|
||||
@ -73,22 +67,23 @@ int _runtwinmain(int argc, /* as tcc passed in */ char **argv)
|
||||
_TCHAR *szCmd, *p;
|
||||
|
||||
#ifdef UNICODE
|
||||
int wargc;
|
||||
_TCHAR **wargv, **wenv;
|
||||
_startupinfo start_info = {0};
|
||||
|
||||
__tgetmainargs(&wargc, &wargv, &wenv, 0, &start_info);
|
||||
if (argc < wargc)
|
||||
wargv += wargc - argc;
|
||||
else
|
||||
argc = wargc;
|
||||
#define argv wargv
|
||||
__tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info);
|
||||
/* may be wrong when tcc has received wildcards (*.c) */
|
||||
if (argc < __argc) {
|
||||
__targv += __argc - argc;
|
||||
__argc = argc;
|
||||
}
|
||||
#else
|
||||
__argc = argc;
|
||||
__targv = argv;
|
||||
#endif
|
||||
|
||||
p = GetCommandLine();
|
||||
szCmd = NULL;
|
||||
if (argc > 1)
|
||||
szCmd = _tcsstr(p, argv[1]);
|
||||
szCmd = _tcsstr(p, __targv[1]);
|
||||
if (NULL == szCmd)
|
||||
szCmd = __T("");
|
||||
else if (szCmd > p && szCmd[-1] == __T('\"'))
|
||||
|
Loading…
Reference in New Issue
Block a user