diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2005-03-11 16:48:39 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2005-03-11 16:48:39 (GMT) |
commit | a1de57485109518c925aa203c926fe7e614fe028 (patch) | |
tree | f41f9730869e5721e452aca4776ca5f7c37131b3 /Source/kwsys/SystemTools.cxx | |
parent | 95d6107da2678f0e27c4f50d3481b8c4b570cde9 (diff) | |
download | CMake-a1de57485109518c925aa203c926fe7e614fe028.zip CMake-a1de57485109518c925aa203c926fe7e614fe028.tar.gz CMake-a1de57485109518c925aa203c926fe7e614fe028.tar.bz2 |
ENH: add last two small funcs from vtkString. Done removing deps
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index fb0c4ef..87cf953 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -841,6 +841,55 @@ kwsys_stl::string SystemTools::AddSpaceBetweenCapitalizedWords( return n; } +char* SystemTools::AppendStrings(const char* str1, const char* str2) +{ + if (!str1) + { + return SystemTools::DuplicateString(str2); + } + if (!str2) + { + return SystemTools::DuplicateString(str1); + } + size_t len1 = strlen(str1); + char *newstr = new char[len1 + strlen(str2) + 1]; + if (!newstr) + { + return 0; + } + strcpy(newstr, str1); + strcat(newstr + len1, str2); + return newstr; +} + +char* SystemTools::AppendStrings( + const char* str1, const char* str2, const char* str3) +{ + if (!str1) + { + return SystemTools::AppendStrings(str2, str3); + } + if (!str2) + { + return SystemTools::AppendStrings(str1, str3); + } + if (!str3) + { + return SystemTools::AppendStrings(str1, str2); + } + + size_t len1 = strlen(str1), len2 = strlen(str2); + char *newstr = new char[len1 + len2 + strlen(str3) + 1]; + if (!newstr) + { + return 0; + } + strcpy(newstr, str1); + strcat(newstr + len1, str2); + strcat(newstr + len1 + len2, str3); + return newstr; +} + // Return a lower case string kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s) { |