]> granicus.if.org Git - nethack/commitdiff
win32 argc fix
authornethack.allison <nethack.allison>
Fri, 8 Feb 2002 02:37:08 +0000 (02:37 +0000)
committernethack.allison <nethack.allison>
Fri, 8 Feb 2002 02:37:08 +0000 (02:37 +0000)
fix a problem when NetHack directory contains spaces.

win/win32/winhack.c

index 41495fbf74c6de0db8aaa55a98c1d78215ffd34b..4de77f1364731b1029b9b733d21d68a3d0037982 100644 (file)
@@ -44,7 +44,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
        int argc;
        char* argv[MAX_CMDLINE_PARAM];
        size_t len;
-       TCHAR* p;
+       TCHAR *p, *p2;
        TCHAR wbuf[BUFSZ];
        char buf[BUFSZ];
 
@@ -79,8 +79,15 @@ int APIENTRY WinMain(HINSTANCE hInstance,
        }
 
        /* get command line parameters */       
-       p = _tcstok(GetCommandLine(), TEXT(" "));
-       for( argc=0; p && argc<MAX_CMDLINE_PARAM; argc++ ) {
+       argc = 0;
+       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);
                if( len>0 ) {
                        argv[argc] = _strdup( NH_W2A(p, buf, BUFSZ) );