Subversion Repositories eduke32

Compare Revisions

Ignore whitespace Rev 4982 → Rev 4983

/polymer/eduke32/build/include/winbits.h
30,3 → 30,4
extern int32_t addsearchpath_ProgramFiles(const char *p);
 
extern int32_t G_GetVersionFromWebsite(char *buffer);
extern int32_t win_buildargs(char **argvbuf);
/polymer/eduke32/build/src/sdlayer.c
327,7 → 327,11
}
}
 
#ifdef _WIN32
int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int32_t nCmdShow)
#else
int32_t main(int32_t argc, char *argv[])
#endif
{
int32_t r;
 
346,6 → 350,11
signal(SIGFPE, sighandler);
 
#ifdef _WIN32
UNREFERENCED_PARAMETER(hInst);
UNREFERENCED_PARAMETER(hPrevInst);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
 
win_open();
 
if (!CheckWinVersion())
366,7 → 375,23
maybe_redirect_outputs();
baselayer_init();
 
#ifdef _WIN32
char *argvbuf;
int32_t buildargc = win_buildargs(&argvbuf);
const char **buildargv = (const char **) Bmalloc(sizeof(char *)*(buildargc+1));
char *wp = argvbuf;
 
for (int i=0; i<buildargc; i++, wp++)
{
buildargv[i] = wp;
while (*wp) wp++;
}
buildargv[buildargc] = NULL;
 
r = app_main(buildargc, (const char **)buildargv);
#else
r = app_main(argc, (const char **)argv);
#endif
 
startwin_close();
 
/polymer/eduke32/build/src/winbits.c
303,7 → 303,70
return returncode;
}
 
int32_t win_buildargs(char **argvbuf)
{
int32_t buildargc = 0;
 
*argvbuf = Bstrdup(GetCommandLine());
 
if (*argvbuf)
{
char quoted = 0, instring = 0, swallownext = 0;
char *wp;
for (const char *p = wp = *argvbuf; *p; p++)
{
if (*p == ' ')
{
if (instring)
{
if (!quoted)
{
// end of a string
*(wp++) = 0;
instring = 0;
}
else
*(wp++) = *p;
}
}
else if (*p == '"' && !swallownext)
{
if (instring)
{
if (quoted && p[1] == ' ')
{
// end of a string
*(wp++) = 0;
instring = 0;
}
quoted = !quoted;
}
else
{
instring = 1;
quoted = 1;
buildargc++;
}
}
else if (*p == '\\' && p[1] == '"' && !swallownext)
swallownext = 1;
else
{
if (!instring)
buildargc++;
 
instring = 1;
*(wp++) = *p;
swallownext = 0;
}
}
*wp = 0;
}
 
return buildargc;
}
 
 
// Workaround for a bug in mingwrt-4.0.0 and up where a function named main() in misc/src/libcrt/gdtoa/qnan.c takes precedence over the proper one in src/libcrt/crt/main.c.
#if (defined __MINGW32__ && EDUKE32_GCC_PREREQ(4,8)) || EDUKE32_CLANG_PREREQ(3,4)
# undef main