summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2009-10-08 14:56:55 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2009-10-08 14:56:55 (GMT)
commit2af045dfc584cdef64869829147e81b70afb8f09 (patch)
tree60f1caac1819d9fe6a64d96491a9f68ccba3cab4 /Source/kwsys
parentf3a0fba75e6c25876f6543460ae29f918c949d3f (diff)
downloadCMake-2af045dfc584cdef64869829147e81b70afb8f09.zip
CMake-2af045dfc584cdef64869829147e81b70afb8f09.tar.gz
CMake-2af045dfc584cdef64869829147e81b70afb8f09.tar.bz2
Trimmed off the newline from sw_vers output on mac, it could cause xml parsing errors if left in
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/SystemInformation.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index f3150ea..89fdf9b 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -243,6 +243,7 @@ protected:
// For Mac
bool ParseSysCtl();
void CallSwVers();
+ void TrimNewline(kwsys_stl::string&);
kwsys_stl::string ExtractValueFromSysCtl(const char* word);
kwsys_stl::string SysCtlBuffer;
@@ -3390,6 +3391,7 @@ void SystemInformationImplementation::CallSwVers()
args.push_back("-productName");
args.push_back(0);
output = this->RunProcess(args);
+ this->TrimNewline(output);
this->OSName = output;
args.clear();
@@ -3397,6 +3399,7 @@ void SystemInformationImplementation::CallSwVers()
args.push_back("-productVersion");
args.push_back(0);
output = this->RunProcess(args);
+ this->TrimNewline(output);
this->OSRelease = output;
args.clear();
@@ -3404,10 +3407,28 @@ void SystemInformationImplementation::CallSwVers()
args.push_back("-buildVersion");
args.push_back(0);
output = this->RunProcess(args);
+ this->TrimNewline(output);
this->OSVersion = output;
#endif
}
+void SystemInformationImplementation::TrimNewline(kwsys_stl::string& output)
+{
+ // remove \r
+ kwsys_stl::string::size_type pos=0;
+ while((pos = output.find("\r", pos)) != kwsys_stl::string::npos)
+ {
+ output.erase(pos);
+ }
+
+ // remove \n
+ pos = 0;
+ while((pos = output.find("\n", pos)) != kwsys_stl::string::npos)
+ {
+ output.erase(pos);
+ }
+}
+
/** Return true if the machine is 64 bits */
bool SystemInformationImplementation::Is64Bits()
{