mirror of
https://github.com/cuberite/TCLAP.git
synced 2025-09-12 05:35:08 -04:00
added length checks to strings that can otherwise break with Metroworks compilers
This commit is contained in:
parent
bb477f8d10
commit
20d8d8b531
@ -461,7 +461,7 @@ inline void CmdLine::parse(std::vector<std::string>& args)
|
||||
|
||||
inline bool CmdLine::_emptyCombined(const std::string& s)
|
||||
{
|
||||
if ( s[0] != Arg::flagStartChar() )
|
||||
if ( s.length() > 0 && s[0] != Arg::flagStartChar() )
|
||||
return false;
|
||||
|
||||
for ( int i = 1; static_cast<unsigned int>(i) < s.length(); i++ )
|
||||
|
@ -139,7 +139,8 @@ inline bool SwitchArg::getValue() { return _value; }
|
||||
inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches )
|
||||
{
|
||||
// make sure this is actually a combined switch
|
||||
if ( combinedSwitches[0] != Arg::flagStartString()[0] )
|
||||
if ( combinedSwitches.length() > 0 &&
|
||||
combinedSwitches[0] != Arg::flagStartString()[0] )
|
||||
return false;
|
||||
|
||||
// make sure it isn't a long name
|
||||
@ -154,7 +155,8 @@ inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches )
|
||||
// ok, we're not specifying a ValueArg, so we know that we have
|
||||
// a combined switch list.
|
||||
for ( unsigned int i = 1; i < combinedSwitches.length(); i++ )
|
||||
if ( combinedSwitches[i] == _flag[0] &&
|
||||
if ( _flag.length() > 0 &&
|
||||
combinedSwitches[i] == _flag[0] &&
|
||||
_flag[0] != Arg::flagStartString()[0] )
|
||||
{
|
||||
// update the combined switches so this one is no longer present
|
||||
|
Loading…
x
Reference in New Issue
Block a user