From: Vadim Zeitlin Date: Sat, 20 Oct 2007 21:08:38 +0000 (+0000) Subject: accept "--opt val" and "--opt:val" syntax in addition to "--opt=val" as X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/bdee3769afe1cd8218568acbe16a31bf0df39aee accept "--opt val" and "--opt:val" syntax in addition to "--opt=val" as documented (patch 1786465) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49275 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index 88d22ca184..45246ccb10 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -716,58 +716,44 @@ int wxCmdLineParser::Parse(bool showUsage) } else // it's an option. not a switch { - // get the value - if ( isLong ) + switch ( (*p).GetValue() ) { - if ( *p++ != _T('=') ) - { - errorMsg << wxString::Format(_("Option '%s' requires a value, '=' expected."), name.c_str()) - << _T('\n'); - - ok = false; - } - } - else // short option - { - switch ( (*p).GetValue() ) - { - case _T('='): - case _T(':'): - // the value follows - ++p; - break; - - case 0: - // the value is in the next argument - if ( ++n == count ) - { - // ... but there is none - errorMsg << wxString::Format(_("Option '%s' requires a value."), - name.c_str()) - << _T('\n'); - - ok = false; - } - else - { - // ... take it from there - p = m_data->m_arguments[n].begin(); - end = m_data->m_arguments[n].end(); - } - break; + case _T('='): + case _T(':'): + // the value follows + ++p; + break; - default: - // the value is right here: this may be legal or - // not depending on the option style - if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR ) - { - errorMsg << wxString::Format(_("Separator expected after the option '%s'."), - name.c_str()) - << _T('\n'); + case 0: + // the value is in the next argument + if ( ++n == count ) + { + // ... but there is none + errorMsg << wxString::Format(_("Option '%s' requires a value."), + name.c_str()) + << _T('\n'); + + ok = false; + } + else + { + // ... take it from there + p = m_data->m_arguments[n].begin(); + end = m_data->m_arguments[n].end(); + } + break; - ok = false; - } - } + default: + // the value is right here: this may be legal or + // not depending on the option style + if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR ) + { + errorMsg << wxString::Format(_("Separator expected after the option '%s'."), + name.c_str()) + << _T('\n'); + + ok = false; + } } if ( ok )