summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-30 10:07:56 -0400
committerBrad King <brad.king@kitware.com>2017-09-30 10:07:56 -0400
commit90f1b9ad4ebc882bb3f45834c8a5953ba1cee3c2 (patch)
tree69807a1a5b5e4df1aa7f30bfeeea1a2f0b31a14f /Source
parent5dd75e35959a25d22d8535263cb414763699b584 (diff)
parent4532b0357261af903f86bc29429ae3c9413b54ab (diff)
downloadcmake-90f1b9ad4ebc882bb3f45834c8a5953ba1cee3c2.tar.gz
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys: KWSys 2017-09-30 (f108739d)
Diffstat (limited to 'Source')
-rw-r--r--Source/kwsys/CMakeLists.txt1
-rw-r--r--Source/kwsys/SystemTools.cxx98
-rw-r--r--Source/kwsys/SystemTools.hxx.in7
-rw-r--r--Source/kwsys/testIOS.cxx139
-rw-r--r--Source/kwsys/testSystemTools.cxx6
5 files changed, 3 insertions, 248 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 5b8ce00a9e..21568bbedd 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -1028,7 +1028,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
)
ENDIF()
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
- testIOS
testSystemTools
testCommandLineArguments
testCommandLineArguments1
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 0a22d638a9..ecfa3319bc 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2371,104 +2371,6 @@ long int SystemTools::CreationTime(const std::string& filename)
return ct;
}
-bool SystemTools::ConvertDateMacroString(const char* str, time_t* tmt)
-{
- if (!str || !tmt || strlen(str) > 11) {
- return false;
- }
-
- struct tm tmt2;
-
- // __DATE__
- // The compilation date of the current source file. The date is a string
- // literal of the form Mmm dd yyyy. The month name Mmm is the same as for
- // dates generated by the library function asctime declared in TIME.H.
-
- // index: 012345678901
- // format: Mmm dd yyyy
- // example: Dec 19 2003
-
- static char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
-
- char buffer[12];
- strcpy(buffer, str);
-
- buffer[3] = 0;
- char* ptr = strstr(month_names, buffer);
- if (!ptr) {
- return false;
- }
-
- int month = static_cast<int>((ptr - month_names) / 3);
- int day = atoi(buffer + 4);
- int year = atoi(buffer + 7);
-
- tmt2.tm_isdst = -1;
- tmt2.tm_hour = 0;
- tmt2.tm_min = 0;
- tmt2.tm_sec = 0;
- tmt2.tm_wday = 0;
- tmt2.tm_yday = 0;
- tmt2.tm_mday = day;
- tmt2.tm_mon = month;
- tmt2.tm_year = year - 1900;
-
- *tmt = mktime(&tmt2);
- return true;
-}
-
-bool SystemTools::ConvertTimeStampMacroString(const char* str, time_t* tmt)
-{
- if (!str || !tmt || strlen(str) > 26) {
- return false;
- }
-
- struct tm tmt2;
-
- // __TIMESTAMP__
- // The date and time of the last modification of the current source file,
- // expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy,
- /// where Ddd is the abbreviated day of the week and Date is an integer
- // from 1 to 31.
-
- // index: 0123456789
- // 0123456789
- // 0123456789
- // format: Ddd Mmm Date hh:mm:ss yyyy
- // example: Fri Dec 19 14:34:58 2003
-
- static char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
-
- char buffer[27];
- strcpy(buffer, str);
-
- buffer[7] = 0;
- char* ptr = strstr(month_names, buffer + 4);
- if (!ptr) {
- return false;
- }
-
- int month = static_cast<int>((ptr - month_names) / 3);
- int day = atoi(buffer + 8);
- int hour = atoi(buffer + 11);
- int min = atoi(buffer + 14);
- int sec = atoi(buffer + 17);
- int year = atoi(buffer + 20);
-
- tmt2.tm_isdst = -1;
- tmt2.tm_hour = hour;
- tmt2.tm_min = min;
- tmt2.tm_sec = sec;
- tmt2.tm_wday = 0;
- tmt2.tm_yday = 0;
- tmt2.tm_mday = day;
- tmt2.tm_mon = month;
- tmt2.tm_year = year - 1900;
-
- *tmt = mktime(&tmt2);
- return true;
-}
-
std::string SystemTools::GetLastSystemError()
{
int e = errno;
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 41a60d3058..35bc1b19ba 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -206,13 +206,6 @@ public:
static int Strucmp(const char* s1, const char* s2);
/**
- * Convert a string in __DATE__ or __TIMESTAMP__ format into a time_t.
- * Return false on error, true on success
- */
- static bool ConvertDateMacroString(const char* str, time_t* tmt);
- static bool ConvertTimeStampMacroString(const char* str, time_t* tmt);
-
- /**
* Split a string on its newlines into multiple lines
* Return false only if the last line stored had no newline
*/
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx
deleted file mode 100644
index 3e4c325c76..0000000000
--- a/Source/kwsys/testIOS.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-#include "kwsysPrivate.h"
-#include KWSYS_HEADER(Configure.hxx)
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string.h> /* strlen */
-#include <vector>
-
-// Work-around CMake dependency scanning limitation. This must
-// duplicate the above list of headers.
-#if 0
-#include "Configure.hxx.in"
-#endif
-
-int testIOS(int, char* [])
-{
- std::ostringstream ostr;
- const char hello[] = "hello";
- ostr << hello;
- if (ostr.str() != hello) {
- std::cerr << "failed to write hello to ostr" << std::endl;
- return 1;
- }
- const char world[] = "world";
- std::ostringstream ostr2;
- ostr2.write(hello, strlen(hello)); /* I could do sizeof */
- ostr2.put('\0');
- ostr2.write(world, strlen(world));
- if (ostr2.str().size() != strlen(hello) + 1 + strlen(world)) {
- std::cerr << "failed to write hello to ostr2" << std::endl;
- return 1;
- }
- static const unsigned char array[] = {
- 0xff, 0x4f, 0xff, 0x51, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x01, 0xff, 0x52, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x04, 0x04, 0x00, 0x01, 0xff,
- 0x5c, 0x00, 0x13, 0x40, 0x40, 0x48, 0x48, 0x50, 0x48, 0x48, 0x50, 0x48,
- 0x48, 0x50, 0x48, 0x48, 0x50, 0x48, 0x48, 0x50, 0xff, 0x64, 0x00, 0x2c,
- 0x00, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79,
- 0x20, 0x49, 0x54, 0x4b, 0x2f, 0x47, 0x44, 0x43, 0x4d, 0x2f, 0x4f, 0x70,
- 0x65, 0x6e, 0x4a, 0x50, 0x45, 0x47, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69,
- 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0xff, 0x90, 0x00, 0x0a, 0x00, 0x00,
- 0x00, 0x00, 0x06, 0x2c, 0x00, 0x01, 0xff, 0x93, 0xcf, 0xb0, 0x18, 0x08,
- 0x7f, 0xc6, 0x99, 0xbf, 0xff, 0xc0, 0xf8, 0xc1, 0xc1, 0xf3, 0x05, 0x81,
- 0xf2, 0x83, 0x0a, 0xa5, 0xff, 0x10, 0x90, 0xbf, 0x2f, 0xff, 0x04, 0xa8,
- 0x7f, 0xc0, 0xf8, 0xc4, 0xc1, 0xf3, 0x09, 0x81, 0xf3, 0x0c, 0x19, 0x34
- };
- const size_t narray = sizeof(array); // 180
- std::stringstream strstr;
- strstr.write((char*)array, narray);
- // strstr.seekp( narray / 2 ); // set position of put pointer in mid string
- if (strstr.str().size() != narray) {
- std::cerr << "failed to write array to strstr" << std::endl;
- return 1;
- }
-
- std::istringstream istr(" 10 20 str ");
- std::string s;
- int x;
- if (istr >> x) {
- if (x != 10) {
- std::cerr << "x != 10" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 10 from istr" << std::endl;
- return 1;
- }
- if (istr >> x) {
- if (x != 20) {
- std::cerr << "x != 20" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 20 from istr" << std::endl;
- return 1;
- }
- if (istr >> s) {
- if (s != "str") {
- std::cerr << "s != \"str\"" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read str from istr" << std::endl;
- return 1;
- }
- if (istr >> s) {
- std::cerr << "Able to read past end of stream" << std::endl;
- return 1;
- } else {
- // Clear the failure.
- istr.clear(istr.rdstate() & ~std::ios::eofbit);
- istr.clear(istr.rdstate() & ~std::ios::failbit);
- }
- istr.str("30");
- if (istr >> x) {
- if (x != 30) {
- std::cerr << "x != 30" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 30 from istr" << std::endl;
- return 1;
- }
-
- std::stringstream sstr;
- sstr << "40 str2";
- if (sstr >> x) {
- if (x != 40) {
- std::cerr << "x != 40" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 40 from sstr" << std::endl;
- return 1;
- }
- if (sstr >> s) {
- if (s != "str2") {
- std::cerr << "s != \"str2\"" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read str2 from sstr" << std::endl;
- return 1;
- }
-
- // Just try to compile this.
- if (x == 12345) {
- std::ifstream fin("/does_not_exist", std::ios::in | std::ios::binary);
- }
-
- std::cout << "IOS tests passed" << std::endl;
- return 0;
-}
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 1871f5dd0d..768eb4d127 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -22,6 +22,7 @@
#include <iostream>
#include <sstream>
+#include <stdlib.h> /* free */
#include <string.h> /* strcmp */
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <io.h> /* _umask (MSVC) / umask (Borland) */
@@ -535,15 +536,14 @@ static bool CheckStringOperations()
}
delete[] cres;
- char* cres2 = new char[strlen("Mary Had A Little Lamb.") + 1];
- strcpy(cres2, "Mary Had A Little Lamb.");
+ char* cres2 = strdup("Mary Had A Little Lamb.");
kwsys::SystemTools::ReplaceChars(cres2, "aeiou", 'X');
if (strcmp(cres2, "MXry HXd A LXttlX LXmb.")) {
std::cerr << "Problem with ReplaceChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
}
- delete[] cres2;
+ free(cres2);
if (!kwsys::SystemTools::StringStartsWith("Mary Had A Little Lamb.",
"Mary ")) {