diff options
Diffstat (limited to 'Source/kwsys/CommandLineArguments.cxx')
-rw-r--r-- | Source/kwsys/CommandLineArguments.cxx | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 5498377..5792da9 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -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); |