win32 argc fix

fix a problem when NetHack directory contains spaces.
This commit is contained in:
nethack.allison
2002-02-08 02:37:08 +00:00
parent 6b75832e51
commit 80a0fbd62b

View File

@@ -44,7 +44,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
int argc; int argc;
char* argv[MAX_CMDLINE_PARAM]; char* argv[MAX_CMDLINE_PARAM];
size_t len; size_t len;
TCHAR* p; TCHAR *p, *p2;
TCHAR wbuf[BUFSZ]; TCHAR wbuf[BUFSZ];
char buf[BUFSZ]; char buf[BUFSZ];
@@ -79,8 +79,15 @@ int APIENTRY WinMain(HINSTANCE hInstance,
} }
/* get command line parameters */ /* get command line parameters */
p = _tcstok(GetCommandLine(), TEXT(" ")); argc = 0;
for( argc=0; p && argc<MAX_CMDLINE_PARAM; argc++ ) { p = GetCommandLine();
if (p && *p == _T('"')) {
p2 = _tcschr(p + 1, _T('"'));
p = p2 + 2;
argc = 1;
}
p = _tcstok(p, TEXT(" "));
for( ; p && argc<MAX_CMDLINE_PARAM; argc++ ) {
len = _tcslen(p); len = _tcslen(p);
if( len>0 ) { if( len>0 ) {
argv[argc] = _strdup( NH_W2A(p, buf, BUFSZ) ); argv[argc] = _strdup( NH_W2A(p, buf, BUFSZ) );