summaryrefslogtreecommitdiffstats
path: root/CommandLineArguments.cxx
diff options
context:
space:
mode:
authorKWSys Upstream <kwrobot@kitware.com>2017-10-12 10:59:48 (GMT)
committerBrad King <brad.king@kitware.com>2017-10-13 13:13:56 (GMT)
commite44b0cb2f0d6d0065faabd510efdcfc6359a8025 (patch)
tree44cb77d27a0ec8e7bf3643397f01f43f0ee52b94 /CommandLineArguments.cxx
parentc551ff588b48cc4c286922779651890da0f3c22c (diff)
downloadCMake-e44b0cb2f0d6d0065faabd510efdcfc6359a8025.zip
CMake-e44b0cb2f0d6d0065faabd510efdcfc6359a8025.tar.gz
CMake-e44b0cb2f0d6d0065faabd510efdcfc6359a8025.tar.bz2
KWSys 2017-10-12 (ef0ad34d)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit ef0ad34d280f0553fc4f6e7202a5e7d6241cdc9c (master). Upstream Shortlog ----------------- Rolf Eike Beer (2): 8717ac15 DynamicLoader: use std::string instead of strcpy() + strcat() 88d4dd4b CommandLineArguments: use std::string in GenerateHelp() Wouter Klouwen (1): 749b7506 ProcessUNIX: Use monotonic clock in kwsysProcessTimeGetCurrent() for POSIX
Diffstat (limited to 'CommandLineArguments.cxx')
-rw-r--r--CommandLineArguments.cxx20
1 files changed, 7 insertions, 13 deletions
diff --git a/CommandLineArguments.cxx b/CommandLineArguments.cxx
index 5498377..5792da9 100644
--- a/CommandLineArguments.cxx
+++ b/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);