]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/cmdline.cpp
mac methodname fixed, so all use the same now
[wxWidgets.git] / src / common / cmdline.cpp
index c1c1f2a5305954b567e8baf1accfc4a48d441de0..dd154cbaeed91e366278377b91836cc87025b811 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        common/cmdline.cpp
+// Name:        src/common/cmdline.cpp
 // Purpose:     wxCmdLineParser implementation
 // Author:      Vadim Zeitlin
 // Modified by:
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "cmdline.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
     #pragma hdrstop
 #endif
 
-#include "wx/cmdline.h"
-
-#if wxUSE_CMDLINE_PARSER
-
 #ifndef WX_PRECOMP
+    #include "wx/dynarray.h"
     #include "wx/string.h"
     #include "wx/log.h"
     #include "wx/intl.h"
     #include "wx/app.h"
-    #include "wx/dynarray.h"
-    #include "wx/filefn.h"
 #endif //WX_PRECOMP
 
+#include "wx/cmdline.h"
+
+#if wxUSE_CMDLINE_PARSER
+
 #include <ctype.h>
 
 #include "wx/datetime.h"
 #include "wx/msgout.h"
+#include "wx/filename.h"
 
 // ----------------------------------------------------------------------------
 // private functions
@@ -124,7 +120,7 @@ struct wxCmdLineOption
     void SetStrVal(const wxString& val)
         { Check(wxCMD_LINE_VAL_STRING); m_strVal = val; m_hasVal = true; }
 #if wxUSE_DATETIME
-    void SetDateVal(const wxDateTime val)
+    void SetDateVal(const wxDateTime& val)
         { Check(wxCMD_LINE_VAL_DATE); m_dateVal = val; m_hasVal = true; }
 #endif // wxUSE_DATETIME
 
@@ -170,8 +166,8 @@ WX_DECLARE_OBJARRAY(wxCmdLineParam, wxArrayParams);
 
 #include "wx/arrimpl.cpp"
 
-WX_DEFINE_OBJARRAY(wxArrayOptions);
-WX_DEFINE_OBJARRAY(wxArrayParams);
+WX_DEFINE_OBJARRAY(wxArrayOptions)
+WX_DEFINE_OBJARRAY(wxArrayParams)
 
 // the parser internal state
 struct wxCmdLineParserData
@@ -245,7 +241,10 @@ void wxCmdLineParserData::SetArguments(const wxString& cmdLine)
 {
     m_arguments.clear();
 
-    m_arguments.push_back(wxTheApp->GetAppName());
+    if(wxTheApp && wxTheApp->argc > 0)
+        m_arguments.push_back(wxTheApp->argv[0]);
+    else
+        m_arguments.push_back(wxEmptyString);
 
     wxArrayString args = wxCmdLineParser::ConvertStringToArgs(cmdLine);
 
@@ -929,14 +928,15 @@ void wxCmdLineParser::Usage()
 
 wxString wxCmdLineParser::GetUsageString()
 {
-    wxString appname = wxTheApp->GetAppName();
-    if ( !appname )
+    wxString appname;
+    if ( m_data->m_arguments.empty() )
     {
-        wxCHECK_MSG( m_data->m_arguments.size() != 0, wxEmptyString,
-                     _T("no program name") );
-
-        appname = wxFileNameFromPath(m_data->m_arguments[0]);
-        wxStripExtension(appname);
+        if ( wxTheApp )
+            appname = wxTheApp->GetAppName();
+    }
+    else // use argv[0]
+    {
+        appname = wxFileName(m_data->m_arguments[0]).GetName();
     }
 
     // we construct the brief cmd line desc on the fly, but not the detailed
@@ -1223,4 +1223,3 @@ wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p)
 
     return args;
 }
-