Skip to content
Snippets Groups Projects
Commit ef0ad34d authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'CmdLineArgs-strings'


88d4dd4b CommandLineArguments: use std::string in GenerateHelp()

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !60
parents 7890c0cc 88d4dd4b
No related branches found
No related tags found
No related merge requests found
......@@ -529,10 +529,7 @@ void CommandLineArguments::GenerateHelp()
}
}
// Create format for that string
char format[80];
sprintf(format, " %%-%us ", static_cast<unsigned int>(maxlen));
CommandLineArguments::Internal::String::size_type maxstrlen = maxlen;
maxlen += 4; // For the space before and after the option
// Print help for each option
......@@ -540,27 +537,24 @@ void CommandLineArguments::GenerateHelp()
CommandLineArguments::Internal::SetOfStrings::iterator sit;
for (sit = mpit->second.begin(); sit != mpit->second.end(); sit++) {
str << std::endl;
char argument[100];
sprintf(argument, "%s", sit->c_str());
std::string argument = *sit;
switch (this->Internals->Callbacks[*sit].ArgumentType) {
case CommandLineArguments::NO_ARGUMENT:
break;
case CommandLineArguments::CONCAT_ARGUMENT:
strcat(argument, "opt");
argument += "opt";
break;
case CommandLineArguments::SPACE_ARGUMENT:
strcat(argument, " opt");
argument += " opt";
break;
case CommandLineArguments::EQUAL_ARGUMENT:
strcat(argument, "=opt");
argument += "=opt";
break;
case CommandLineArguments::MULTI_ARGUMENT:
strcat(argument, " opt opt ...");
argument += " opt opt ...";
break;
}
char buffer[80];
sprintf(buffer, format, argument);
str << buffer;
str << " " << argument.substr(0, maxstrlen) << " ";
}
const char* ptr = this->Internals->Callbacks[mpit->first].Help;
size_t len = strlen(ptr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment