summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-03-09 14:29:02 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-03-09 14:29:02 (GMT)
commitad9f0d831e6522d9606bab7ae08559cebeed83ce (patch)
treed85ba309d378fac37063e7b05fc624e60a819a64 /Source/cmSystemTools.cxx
parent6aad93f407f341fae1afb80ebeab532451c39458 (diff)
parentb633b263082ae2c74a030aefb9048b0a20098b61 (diff)
downloadCMake-ad9f0d831e6522d9606bab7ae08559cebeed83ce.zip
CMake-ad9f0d831e6522d9606bab7ae08559cebeed83ce.tar.gz
CMake-ad9f0d831e6522d9606bab7ae08559cebeed83ce.tar.bz2
Merge topic 'dev/string-apis'
b633b263 CPackWiX: Fix test to build with expected config 191f25e2 stringapi: Prevent a NULL dereference in WiX 219d6ad6 speedup: Avoid excess iterator dereferences caaad357 speedup: Cache strings for comparisons 7abf4e31 stringapi: Use strings for dependency information 94fc63e2 stringapi: Use strings for cache iterator values 85fc9f26 stringapi: Command names 6557382d stringapi: Use strings for program paths 1a1b737c stringapi: Use strings for generator names 24b5e93d stringapi: Use strings for directories 11ed3e2c stringapi: Add string overload for the Def struct b3bf31a5 stringapi: Miscellaneous char* parameters 5af95c39 typo: Match argument name with the header 2b17626e stringapi: Pass strings as install directories in CPack 3def29da stringapi: Use strings for feature arguments acb116e3 stringapi: Return a string reference for the configuration ...
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx73
1 files changed, 21 insertions, 52 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7cc63bb..39b53bf 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -179,10 +179,11 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64)
}
#endif
-std::string cmSystemTools::EscapeQuotes(const char* str)
+std::string cmSystemTools::EscapeQuotes(const std::string& str)
{
- std::string result = "";
- for(const char* ch = str; *ch != '\0'; ++ch)
+ std::string result;
+ result.reserve(str.size());
+ for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
{
if(*ch == '"')
{
@@ -476,13 +477,6 @@ public:
args.push_back(*arg);
}
}
- void Store(std::vector<cmStdString>& args) const
- {
- for(char** arg = this->ArgV; arg && *arg; ++arg)
- {
- args.push_back(*arg);
- }
- }
};
//----------------------------------------------------------------------------
@@ -494,15 +488,6 @@ void cmSystemTools::ParseUnixCommandLine(const char* command,
argv.Store(args);
}
-//----------------------------------------------------------------------------
-void cmSystemTools::ParseUnixCommandLine(const char* command,
- std::vector<cmStdString>& args)
-{
- // Invoke the underlying parser.
- cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0);
- argv.Store(args);
-}
-
std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
int shell_flags)
{
@@ -522,9 +507,9 @@ std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
return result;
}
-std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
+std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
{
- std::vector<cmStdString> args;
+ std::vector<std::string> args;
std::string arg;
bool win_path = false;
@@ -605,22 +590,6 @@ std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
}
-bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
- std::string* output ,
- int* retVal , const char* dir ,
- OutputOption outputflag ,
- double timeout )
-{
- std::vector<std::string> cmd;
- for(std::vector<cmStdString>::const_iterator i = command.begin();
- i != command.end(); ++i)
- {
- cmd.push_back(*i);
- }
- return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir,
- outputflag, timeout);
-}
-
bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
std::string* output ,
int* retVal , const char* dir ,
@@ -780,7 +749,7 @@ bool cmSystemTools::RunSingleCommand(
outputflag = OUTPUT_NONE;
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+ std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if(args.size() < 1)
{
@@ -944,7 +913,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
#endif
}
-bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
+bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmCryptoHashMD5 md5;
@@ -959,7 +928,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
#endif
}
-std::string cmSystemTools::ComputeStringMD5(const char* input)
+std::string cmSystemTools::ComputeStringMD5(const std::string& input)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmCryptoHashMD5 md5;
@@ -971,13 +940,14 @@ std::string cmSystemTools::ComputeStringMD5(const char* input)
#endif
}
-void cmSystemTools::Glob(const char *directory, const char *regexp,
+void cmSystemTools::Glob(const std::string& directory,
+ const std::string& regexp,
std::vector<std::string>& files)
{
cmsys::Directory d;
- cmsys::RegularExpression reg(regexp);
+ cmsys::RegularExpression reg(regexp.c_str());
- if (d.Load(directory))
+ if (d.Load(directory.c_str()))
{
size_t numf;
unsigned int i;
@@ -994,14 +964,13 @@ void cmSystemTools::Glob(const char *directory, const char *regexp,
}
-void cmSystemTools::GlobDirs(const char *fullPath,
+void cmSystemTools::GlobDirs(const std::string& path,
std::vector<std::string>& files)
{
- std::string path = fullPath;
std::string::size_type pos = path.find("/*");
if(pos == std::string::npos)
{
- files.push_back(fullPath);
+ files.push_back(path);
return;
}
std::string startPath = path.substr(0, pos);
@@ -1113,8 +1082,8 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
}
}
-bool cmSystemTools::SimpleGlob(const cmStdString& glob,
- std::vector<cmStdString>& files,
+bool cmSystemTools::SimpleGlob(const std::string& glob,
+ std::vector<std::string>& files,
int type /* = 0 */)
{
files.clear();
@@ -1232,7 +1201,7 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
return cmSystemTools::UNKNOWN_FILE_FORMAT;
}
-bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l)
+bool cmSystemTools::Split(const char* s, std::vector<std::string>& l)
{
std::vector<std::string> temp;
bool res = Superclass::Split(s, temp);
@@ -1444,7 +1413,7 @@ bool cmSystemTools::IsPathToFramework(const char* path)
}
bool cmSystemTools::CreateTar(const char* outFileName,
- const std::vector<cmStdString>& files,
+ const std::vector<std::string>& files,
bool gzip, bool bzip2, bool verbose)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1464,7 +1433,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
cmArchiveWrite::CompressNone)),
cmArchiveWrite::TypeTAR);
a.SetVerbose(verbose);
- for(std::vector<cmStdString>::const_iterator i = files.begin();
+ for(std::vector<std::string>::const_iterator i = files.begin();
i != files.end(); ++i)
{
std::string path = *i;
@@ -2316,7 +2285,7 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
std::string& soname)
{
- std::vector<cmStdString> cmds;
+ std::vector<std::string> cmds;
cmds.push_back("otool");
cmds.push_back("-D");
cmds.push_back(fullPath.c_str());