X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ed9fce61aea8209a03b493a781592286ed3cbd9..520e470fdd0daef09c77938db642e4583933c90d:/src/msw/app.cpp diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 22ced1c679..7d5b43fe2c 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -10,14 +10,14 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ - #pragma implementation "app.h" +#pragma implementation "app.h" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #if defined(__BORLANDC__) - #pragma hdrstop +#pragma hdrstop #endif #ifndef WX_PRECOMP @@ -51,7 +51,8 @@ #endif // use debug CRT functions for memory leak detections in VC++ -/* This still doesn't work for me, Vadim. +/* Here we go again commenting it out. PLEASE don't + * uncomment this again. #if defined(__WXDEBUG__) && defined(_MSC_VER) // VC++ uses this macro as debug/release mode indicator #ifndef _DEBUG @@ -114,7 +115,8 @@ bool wxApp::Initialize() { wxBuffer = new char[1500]; -/* +/* PLEASE don't uncomment this again. IT DOESN'T WORK when building + * using the makefile. #if defined(__WXDEBUG__) && defined(_MSC_VER) // do check for memory leaks on program exit // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free @@ -344,87 +346,76 @@ bool wxApp::RegisterWindowClasses() //// Convert Windows to argc, argv style -// FIXME this code should be rewritten (use wxArrayString instead...) void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine) { - // Split command line into tokens, as in usual main(argc, argv) - int para,count = 0; - char *buf = new char[strlen(lpCmdLine) + 1]; - - para=0; - /* Model independent strcpy */ - unsigned int i; - for (i = 0; iSetAppName(name); + strcpy(name, wxFileNameFromPath(name)); + wxStripExtension(name); + wxTheApp->SetAppName(name); - /* Break up string */ - // Treat strings enclosed in double-quotes as single arguments - char* str = buf; - while (*str) - { -/* - if ( count == WXSIZEOF(command) ) + // Break up string + // Treat strings enclosed in double-quotes as single arguments + int i = 0; + int len = cmdLine.Length(); + while (i < len) { - wxFAIL_MSG("too many command line args."); - break; - } -*/ - while ( *str && isspace(*str) ) // skip whitespace - str++; + // Skip whitespace + while ((i < len) && isspace(cmdLine.GetChar(i))) + i ++; - if (*str == '"') - { - str++; - command[count++] = str; - while (*str && *str != '"') - str++; + if (i < len) + { + if (cmdLine.GetChar(i) == '"') // We found the start of a string + { + i ++; + int first = i; + while ((i < len) && (cmdLine.GetChar(i) != '"')) + i ++; + + wxString arg(cmdLine.Mid(first, (i - first))); + + args.Add(arg); + count ++; + + if (i < len) + i ++; // Skip past 2nd quote + } + else // Unquoted argument + { + int first = i; + while ((i < len) && !isspace(cmdLine.GetChar(i))) + i ++; + + wxString arg(cmdLine.Mid(first, (i - first))); + + args.Add(arg); + count ++; + } + } } - else if (*str) + + wxTheApp->argv = new char*[count + 1]; + for (i = 0; i < count; i++) { - command[count++] = str; - while (*str && !isspace(*str)) - str++; + wxString arg(args[i]); + wxTheApp->argv[i] = copystring((const char*)arg); } - if (*str) - *str++ = '\0'; - } - - wxTheApp->argv = new char*[count + 1]; - wxTheApp->argv[count] = NULL; /* argv[] is NULL terminated list! */ - wxTheApp->argc = count; - - for (i = 0; i < count; i++) - wxTheApp->argv[i] = copystring(command[i]); - -#if !defined(__GNUWIN32__) -// use copystring than delete this pointer - delete [] command[0]; -#endif - - delete [] command; - delete [] buf; + wxTheApp->argv[count] = NULL; // argv[] is a NULL-terminated list + wxTheApp->argc = count; } //// Cleans up any wxWindows internal structures left lying around @@ -684,7 +675,7 @@ wxApp::~wxApp() { delete[] argv[i]; } - delete argv; + delete[] argv; } bool wxApp::Initialized()