summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/CMakeLists.txt86
-rw-r--r--Source/kwsys/DateStamp.h.in42
-rw-r--r--Source/kwsys/SystemInformation.cxx2
-rw-r--r--Source/kwsys/SystemTools.cxx232
-rw-r--r--Source/kwsys/SystemTools.hxx.in6
-rw-r--r--Source/kwsys/hash_fun.hxx.in5
-rw-r--r--Source/kwsys/hashtable.hxx.in2
-rw-r--r--Source/kwsys/kwsysDateStamp.cmake21
-rwxr-xr-xSource/kwsys/kwsysDateStamp.py54
-rw-r--r--Source/kwsys/kwsysPlatformTestsCXX.cxx35
-rw-r--r--Source/kwsys/testSystemTools.cxx54
11 files changed, 358 insertions, 181 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 0ef4e28..a132357 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -123,7 +123,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_USE_FundamentalType 1)
SET(KWSYS_USE_Terminal 1)
SET(KWSYS_USE_IOStream 1)
- SET(KWSYS_USE_DateStamp 1)
SET(KWSYS_USE_String 1)
SET(KWSYS_USE_SystemInformation 1)
SET(KWSYS_USE_CPU 1)
@@ -142,7 +141,6 @@ IF(KWSYS_USE_Process)
SET(KWSYS_USE_System 1)
ENDIF(KWSYS_USE_Process)
IF(KWSYS_USE_SystemInformation)
- SET(KWSYS_USE_FundamentalType 1)
SET(KWSYS_USE_Process 1)
ENDIF(KWSYS_USE_SystemInformation)
@@ -414,6 +412,39 @@ IF(UNIX)
"Checking whether struct stat has st_mtim member" DIRECT)
ENDIF(UNIX)
+# Check existence and uniqueness of long long and __int64.
+KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
+ "Checking whether C++ compiler has 'long long'" DIRECT)
+KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS___INT64
+ "Checking whether C++ compiler has '__int64'" DIRECT)
+IF(KWSYS_CXX_HAS___INT64)
+ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_AND___INT64
+ "Checking whether long and __int64 are the same type" DIRECT)
+ IF(KWSYS_CXX_HAS_LONG_LONG)
+ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_LONG_AND___INT64
+ "Checking whether long long and __int64 are the same type" DIRECT)
+ ENDIF()
+ENDIF()
+
+# Enable the "long long" type if it is available. It is standard in
+# C99 and C++03 but not in earlier standards.
+IF(KWSYS_CXX_HAS_LONG_LONG)
+ SET(KWSYS_USE_LONG_LONG 1)
+ELSE()
+ SET(KWSYS_USE_LONG_LONG 0)
+ENDIF()
+
+# Enable the "__int64" type if it is available and unique. It is not
+# standard.
+SET(KWSYS_USE___INT64 0)
+IF(KWSYS_CXX_HAS___INT64)
+ IF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
+ IF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
+ SET(KWSYS_USE___INT64 1)
+ ENDIF()
+ ENDIF()
+ENDIF()
+
IF(KWSYS_USE_FundamentalType)
# Look for type size helper macros.
KWSYS_PLATFORM_INFO_TEST(C KWSYS_C_TYPE_MACROS
@@ -464,34 +495,6 @@ IF(KWSYS_USE_FundamentalType)
ENDIF()
ENDFOREACH()
- # Check uniqueness of types.
- IF(KWSYS_SIZEOF___INT64)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_AND___INT64
- "Checking whether long and __int64 are the same type" DIRECT)
- IF(KWSYS_SIZEOF_LONG_LONG)
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_LONG_AND___INT64
- "Checking whether long long and __int64 are the same type" DIRECT)
- ENDIF(KWSYS_SIZEOF_LONG_LONG)
- ENDIF(KWSYS_SIZEOF___INT64)
-
- # Enable the "long long" type if it is available. It is standard in
- # C99 and C++03 but not in earlier standards.
- IF(KWSYS_SIZEOF_LONG_LONG)
- SET(KWSYS_USE_LONG_LONG 1)
- ELSE(KWSYS_SIZEOF_LONG_LONG)
- SET(KWSYS_USE_LONG_LONG 0)
- ENDIF(KWSYS_SIZEOF_LONG_LONG)
-
- # Enable the "__int64" type if it is available and unique. It is not
- # standard.
- SET(KWSYS_USE___INT64 0)
- IF(KWSYS_SIZEOF___INT64)
- IF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
- IF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
- SET(KWSYS_USE___INT64 1)
- ENDIF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
- ENDIF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
- ENDIF(KWSYS_SIZEOF___INT64)
IF(KWSYS_USE___INT64)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
"Checking whether unsigned __int64 can convert to double" DIRECT)
@@ -506,8 +509,6 @@ ENDIF(KWSYS_USE_FundamentalType)
IF(KWSYS_USE_IOStream)
# Determine whether iostreams support long long.
- KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
- "Checking whether C++ compiler has 'long long'" DIRECT)
IF(KWSYS_CXX_HAS_LONG_LONG)
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
-DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
@@ -553,11 +554,22 @@ SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES
COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}"
)
-IF(KWSYS_DO_NOT_CLEAN_PUTENV)
- # Disable cleanup of putenv memory for issues with GCOV.
+IF(KWSYS_USE_SystemTools)
+ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_SETENV
+ "Checking whether CXX compiler has setenv" DIRECT)
+ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UNSETENV
+ "Checking whether CXX compiler has unsetenv" DIRECT)
+ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
+ "Checking whether CXX compiler has environ in stdlib.h" DIRECT)
SET_SOURCE_FILES_PROPERTIES(SystemTools.cxx PROPERTIES
- COMPILE_FLAGS -DKWSYS_DO_NOT_CLEAN_PUTENV=1)
-ENDIF(KWSYS_DO_NOT_CLEAN_PUTENV)
+ COMPILE_FLAGS "-DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}")
+ENDIF()
+
+IF(KWSYS_USE_SystemInformation)
+ SET_PROPERTY(SOURCE SystemInformation.cxx PROPERTY
+ COMPILE_DEFINITIONS KWSYS_USE_LONG_LONG=${KWSYS_USE_LONG_LONG}
+ KWSYS_USE___INT64=${KWSYS_USE___INT64})
+ENDIF()
#-----------------------------------------------------------------------------
# Choose a directory for the generated headers.
@@ -690,7 +702,7 @@ ENDFOREACH(cpp)
# Add selected C components.
FOREACH(c
- Process Base64 FundamentalType MD5 Terminal System DateStamp String CPU
+ Process Base64 FundamentalType MD5 Terminal System String CPU
)
IF(KWSYS_USE_${c})
# Use the corresponding header file.
diff --git a/Source/kwsys/DateStamp.h.in b/Source/kwsys/DateStamp.h.in
deleted file mode 100644
index c3d0099..0000000
--- a/Source/kwsys/DateStamp.h.in
+++ /dev/null
@@ -1,42 +0,0 @@
-/*============================================================================
- KWSys - Kitware System Library
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
- Distributed under the OSI-approved BSD License (the "License");
- see accompanying file Copyright.txt for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License for more information.
-============================================================================*/
-#ifndef @KWSYS_NAMESPACE@_DateStamp_h
-#define @KWSYS_NAMESPACE@_DateStamp_h
-
-/** Version date integer year. The format is CCYY. */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_YEAR @KWSYS_DATE_STAMP_YEAR@
-
-/** Version date integer month. The format is MM. */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_MONTH @KWSYS_DATE_STAMP_MONTH@
-
-/** Version date integer day. The format is DD. */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_DAY @KWSYS_DATE_STAMP_DAY@
-
-/** Version date full integer. The format is CCYYMMDD. */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_FULL @KWSYS_DATE_STAMP_YEAR@@KWSYS_DATE_STAMP_MONTH@@KWSYS_DATE_STAMP_DAY@
-
-/** Version date string year. The format is "CCYY". */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_STRING_YEAR "@KWSYS_DATE_STAMP_YEAR@"
-
-/** Version date string month. The format is "MM". */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_STRING_MONTH "@KWSYS_DATE_STAMP_MONTH@"
-
-/** Version date string day. The format is "DD". */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_STRING_DAY "@KWSYS_DATE_STAMP_DAY@"
-
-/** Version date full string. The format is "CCYYMMDD". */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_STRING_FULL "@KWSYS_DATE_STAMP_YEAR@@KWSYS_DATE_STAMP_MONTH@@KWSYS_DATE_STAMP_DAY@"
-
-/** Version date formatted string. The format is "CCYY-MM-DD". */
-#define @KWSYS_NAMESPACE@_DATE_STAMP_STRING "@KWSYS_DATE_STAMP_YEAR@-@KWSYS_DATE_STAMP_MONTH@-@KWSYS_DATE_STAMP_DAY@"
-
-#endif
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index d49c0d7..e1ee873 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -26,7 +26,6 @@
// http://msdn.microsoft.com/en-us/library/ms683219(VS.85).aspx
#include "kwsysPrivate.h"
-#include KWSYS_HEADER(FundamentalType.h)
#include KWSYS_HEADER(stl/string)
#include KWSYS_HEADER(stl/vector)
#include KWSYS_HEADER(ios/iosfwd)
@@ -38,7 +37,6 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-# include "FundamentalType.h.in"
# include "SystemInformation.hxx.in"
# include "Process.h.in"
# include "Configure.hxx.in"
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 4d83293..66850e9 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -25,6 +25,8 @@
#include KWSYS_HEADER(ios/fstream)
#include KWSYS_HEADER(ios/sstream)
+#include KWSYS_HEADER(stl/set)
+
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
@@ -78,6 +80,10 @@
# undef _WIN32
#endif
+#if !KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
+extern char **environ;
+#endif
+
#ifdef __CYGWIN__
extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32_path);
#endif
@@ -371,38 +377,224 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result)
}
}
-#ifdef __INTEL_COMPILER
-#pragma warning disable 444
+//----------------------------------------------------------------------------
+
+#if defined(__CYGWIN__) || defined(__GLIBC__)
+# define KWSYS_PUTENV_NAME /* putenv("A") removes A. */
+#elif defined(_WIN32)
+# define KWSYS_PUTENV_EMPTY /* putenv("A=") removes A. */
#endif
-class kwsysDeletingCharVector : public kwsys_stl::vector<char*>
+#if KWSYS_CXX_HAS_UNSETENV
+/* unsetenv("A") removes A from the environment.
+ On older platforms it returns void instead of int. */
+static int kwsysUnPutEnv(const char* env)
{
-public:
- ~kwsysDeletingCharVector();
-};
+ if(const char* eq = strchr(env, '='))
+ {
+ std::string name(env, eq-env);
+ unsetenv(name.c_str());
+ }
+ else
+ {
+ unsetenv(env);
+ }
+ return 0;
+}
-kwsysDeletingCharVector::~kwsysDeletingCharVector()
+#elif defined(KWSYS_PUTENV_EMPTY) || defined(KWSYS_PUTENV_NAME)
+/* putenv("A=") or putenv("A") removes A from the environment. */
+static int kwsysUnPutEnv(const char* env)
{
-#ifndef KWSYS_DO_NOT_CLEAN_PUTENV
- for(kwsys_stl::vector<char*>::iterator i = this->begin();
- i != this->end(); ++i)
+ int err = 0;
+ const char* eq = strchr(env, '=');
+ size_t const len = eq? (size_t)(eq-env) : strlen(env);
+# ifdef KWSYS_PUTENV_EMPTY
+ size_t const sz = len + 2;
+# else
+ size_t const sz = len + 1;
+# endif
+ char local_buf[256];
+ char* buf = sz > sizeof(local_buf) ? (char*)malloc(sz) : local_buf;
+ if(!buf)
+ {
+ return -1;
+ }
+ strncpy(buf, env, len);
+# ifdef KWSYS_PUTENV_EMPTY
+ buf[len] = '=';
+ buf[len+1] = 0;
+ if(putenv(buf) < 0)
+ {
+ err = errno;
+ }
+# else
+ buf[len] = 0;
+ if(putenv(buf) < 0 && errno != EINVAL)
+ {
+ err = errno;
+ }
+# endif
+ if(buf != local_buf)
{
- delete []*i;
+ free(buf);
}
+ if(err)
+ {
+ errno = err;
+ return -1;
+ }
+ return 0;
+}
+
+#else
+/* Manipulate the "environ" global directly. */
+static int kwsysUnPutEnv(const char* env)
+{
+ const char* eq = strchr(env, '=');
+ size_t const len = eq? (size_t)(eq-env) : strlen(env);
+ int in = 0;
+ int out = 0;
+ while(environ[in])
+ {
+ if(strlen(environ[in]) > len &&
+ environ[in][len] == '=' &&
+ strncmp(env, environ[in], len) == 0)
+ {
+ ++in;
+ }
+ else
+ {
+ environ[out++] = environ[in++];
+ }
+ }
+ while(out < in)
+ {
+ environ[out++] = 0;
+ }
+ return 0;
+}
#endif
+
+//----------------------------------------------------------------------------
+
+#if KWSYS_CXX_HAS_SETENV
+
+/* setenv("A", "B", 1) will set A=B in the environment and makes its
+ own copies of the strings. */
+bool SystemTools::PutEnv(const char* env)
+{
+ if(const char* eq = strchr(env, '='))
+ {
+ std::string name(env, eq-env);
+ return setenv(name.c_str(), eq+1, 1) == 0;
+ }
+ else
+ {
+ return kwsysUnPutEnv(env) == 0;
+ }
+}
+
+bool SystemTools::UnPutEnv(const char* env)
+{
+ return kwsysUnPutEnv(env) == 0;
+}
+
+#else
+
+/* putenv("A=B") will set A=B in the environment. Most putenv implementations
+ put their argument directly in the environment. They never free the memory
+ on program exit. Keep an active set of pointers to memory we allocate and
+ pass to putenv, one per environment key. At program exit remove any
+ environment values that may still reference memory we allocated. Then free
+ the memory. This will not affect any environment values we never set. */
+
+# ifdef __INTEL_COMPILER
+# pragma warning disable 444 /* base has non-virtual destructor */
+# endif
+
+/* Order by environment key only (VAR from VAR=VALUE). */
+struct kwsysEnvCompare
+{
+ bool operator() (const char* l, const char* r) const
+ {
+ const char* leq = strchr(l, '=');
+ const char* req = strchr(r, '=');
+ size_t llen = leq? (leq-l) : strlen(l);
+ size_t rlen = req? (req-r) : strlen(r);
+ if(llen == rlen)
+ {
+ return strncmp(l,r,llen) < 0;
+ }
+ else
+ {
+ return strcmp(l,r) < 0;
+ }
+ }
+};
+
+class kwsysEnv: public kwsys_stl::set<const char*, kwsysEnvCompare>
+{
+ class Free
+ {
+ const char* Env;
+ public:
+ Free(const char* env): Env(env) {}
+ ~Free() { free(const_cast<char*>(this->Env)); }
+ };
+public:
+ typedef kwsys_stl::set<const char*, kwsysEnvCompare> derived;
+ ~kwsysEnv()
+ {
+ for(derived::iterator i = this->begin(); i != this->end(); ++i)
+ {
+ kwsysUnPutEnv(*i);
+ free(const_cast<char*>(*i));
+ }
+ }
+ const char* Release(const char* env)
+ {
+ const char* old = 0;
+ derived::iterator i = this->find(env);
+ if(i != this->end())
+ {
+ old = *i;
+ this->erase(i);
+ }
+ return old;
+ }
+ bool Put(const char* env)
+ {
+ Free oldEnv(this->Release(env));
+ static_cast<void>(oldEnv);
+ char* newEnv = strdup(env);
+ this->insert(newEnv);
+ return putenv(newEnv) == 0;
+ }
+ bool UnPut(const char* env)
+ {
+ Free oldEnv(this->Release(env));
+ static_cast<void>(oldEnv);
+ return kwsysUnPutEnv(env) == 0;
+ }
+};
+
+static kwsysEnv kwsysEnvInstance;
+
+bool SystemTools::PutEnv(const char* env)
+{
+ return kwsysEnvInstance.Put(env);
}
-bool SystemTools::PutEnv(const char* value)
+
+bool SystemTools::UnPutEnv(const char* env)
{
- static kwsysDeletingCharVector localEnvironment;
- char* envVar = new char[strlen(value)+1];
- strcpy(envVar, value);
- int ret = putenv(envVar);
- // save the pointer in the static vector so that it can
- // be deleted on exit
- localEnvironment.push_back(envVar);
- return ret == 0;
+ return kwsysEnvInstance.UnPut(env);
}
+#endif
+
+//----------------------------------------------------------------------------
+
const char* SystemTools::GetExecutableExtension()
{
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__VMS)
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 04f1978..5171125 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -749,7 +749,11 @@ public:
/** Put a string into the environment
of the form var=value */
- static bool PutEnv(const char* value);
+ static bool PutEnv(const char* env);
+
+ /** Remove a string from the environment.
+ Input is of the form "var" or "var=value" (value is ignored). */
+ static bool UnPutEnv(const char* env);
/**
* Get current working directory CWD
diff --git a/Source/kwsys/hash_fun.hxx.in b/Source/kwsys/hash_fun.hxx.in
index 8c5eb6a..6f787dd 100644
--- a/Source/kwsys/hash_fun.hxx.in
+++ b/Source/kwsys/hash_fun.hxx.in
@@ -38,7 +38,6 @@
#define @KWSYS_NAMESPACE@_hash_fun_hxx
#include <@KWSYS_NAMESPACE@/Configure.hxx>
-#include <@KWSYS_NAMESPACE@/FundamentalType.h>
#include <@KWSYS_NAMESPACE@/cstddef> // size_t
#include <@KWSYS_NAMESPACE@/stl/string> // string
@@ -124,7 +123,7 @@ struct hash<unsigned long> {
};
// use long long or __int64
-#if @KWSYS_NAMESPACE@_USE_LONG_LONG
+#if @KWSYS_USE_LONG_LONG@
@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
struct hash<long long> {
size_t operator()(long long __x) const { return __x; }
@@ -134,7 +133,7 @@ struct hash<long long> {
struct hash<unsigned long long> {
size_t operator()(unsigned long long __x) const { return __x; }
};
-#elif @KWSYS_NAMESPACE@_USE___INT64
+#elif @KWSYS_USE___INT64@
@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
struct hash<__int64> {
size_t operator()(__int64 __x) const { return __x; }
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
index db52fc8..c835503 100644
--- a/Source/kwsys/hashtable.hxx.in
+++ b/Source/kwsys/hashtable.hxx.in
@@ -394,7 +394,7 @@ enum { _stl_num_primes = 31 };
// create a function with a static local to that function that returns
// the static
-inline const unsigned long* get_stl_prime_list() {
+static inline const unsigned long* get_stl_prime_list() {
static const unsigned long _stl_prime_list[_stl_num_primes] =
{
diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake
deleted file mode 100644
index f157607..0000000
--- a/Source/kwsys/kwsysDateStamp.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-# Do not edit! Generated by kwsysDateStamp.py
-#=============================================================================
-# KWSys - Kitware System Library
-# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-
-# KWSys version date year component. Format is CCYY.
-SET(KWSYS_DATE_STAMP_YEAR 2012)
-
-# KWSys version date month component. Format is MM.
-SET(KWSYS_DATE_STAMP_MONTH 04)
-
-# KWSys version date day component. Format is DD.
-SET(KWSYS_DATE_STAMP_DAY 18)
diff --git a/Source/kwsys/kwsysDateStamp.py b/Source/kwsys/kwsysDateStamp.py
deleted file mode 100755
index bd2e49a..0000000
--- a/Source/kwsys/kwsysDateStamp.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/python
-#=============================================================================
-# KWSys - Kitware System Library
-# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-
-import sys,os
-import time
-
-# Get the path to the directory containing this script.
-if __name__ == '__main__':
- selfdir = os.path.abspath(sys.path[0] or os.curdir)
-else:
- selfdir = os.path.abspath(os.path.dirname(__file__))
-
-# Open the CMake code file.
-fname = os.path.join(selfdir, 'kwsysDateStamp.cmake')
-fout = open(fname, 'w');
-
-# Get the current time.
-ct = time.localtime()
-
-# Write the CMake code describing the date.
-fout.write("""# Do not edit! Generated by kwsysDateStamp.py
-#=============================================================================
-# KWSys - Kitware System Library
-# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-
-# KWSys version date year component. Format is CCYY.
-SET(KWSYS_DATE_STAMP_YEAR %04u)
-
-# KWSys version date month component. Format is MM.
-SET(KWSYS_DATE_STAMP_MONTH %02u)
-
-# KWSys version date day component. Format is DD.
-SET(KWSYS_DATE_STAMP_DAY %02u)
-""" % (ct.tm_year, ct.tm_mon, ct.tm_mday))
-
-fout.close()
diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx
index 903be9b..7b73d06 100644
--- a/Source/kwsys/kwsysPlatformTestsCXX.cxx
+++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx
@@ -122,6 +122,15 @@ int main()
}
#endif
+#ifdef TEST_KWSYS_CXX_HAS___INT64
+__int64 f(__int64 n) { return n; }
+int main()
+{
+ __int64 n = 0;
+ return static_cast<int>(f(n));
+}
+#endif
+
#ifdef TEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS
template <class T> class A;
template <class T> int f(A<T>&);
@@ -393,6 +402,32 @@ int main(int, char **argv)
}
#endif
+#ifdef TEST_KWSYS_CXX_HAS_SETENV
+#include <stdlib.h>
+int main()
+{
+ return setenv("A", "B", 1);
+}
+#endif
+
+#ifdef TEST_KWSYS_CXX_HAS_UNSETENV
+#include <stdlib.h>
+int main()
+{
+ unsetenv("A");
+ return 0;
+}
+#endif
+
+#ifdef TEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
+#include <stdlib.h>
+int main()
+{
+ char* e = environ[0];
+ return e? 0:1;
+}
+#endif
+
#ifdef TEST_KWSYS_CXX_TYPE_INFO
/* Collect fundamental type information and save it to a CMake script. */
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index c0e74af..3ac0cb3 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -328,6 +328,58 @@ bool CheckStringOperations()
}
//----------------------------------------------------------------------------
+
+bool CheckPutEnv(const char* env, const char* name, const char* value)
+{
+ if(!kwsys::SystemTools::PutEnv(env))
+ {
+ kwsys_ios::cerr << "PutEnv(\"" << env
+ << "\") failed!" << kwsys_ios::endl;
+ return false;
+ }
+ const char* v = kwsys::SystemTools::GetEnv(name);
+ v = v? v : "(null)";
+ if(strcmp(v, value) != 0)
+ {
+ kwsys_ios::cerr << "GetEnv(\"" << name << "\") returned \""
+ << v << "\", not \"" << value << "\"!" << kwsys_ios::endl;
+ return false;
+ }
+ return true;
+}
+
+bool CheckUnPutEnv(const char* env, const char* name)
+{
+ if(!kwsys::SystemTools::UnPutEnv(env))
+ {
+ kwsys_ios::cerr << "UnPutEnv(\"" << env << "\") failed!"
+ << kwsys_ios::endl;
+ return false;
+ }
+ if(const char* v = kwsys::SystemTools::GetEnv(name))
+ {
+ kwsys_ios::cerr << "GetEnv(\"" << name << "\") returned \""
+ << v << "\", not (null)!" << kwsys_ios::endl;
+ return false;
+ }
+ return true;
+}
+
+bool CheckEnvironmentOperations()
+{
+ bool res = true;
+ res &= CheckPutEnv("A=B", "A", "B");
+ res &= CheckPutEnv("B=C", "B", "C");
+ res &= CheckPutEnv("C=D", "C", "D");
+ res &= CheckPutEnv("D=E", "D", "E");
+ res &= CheckUnPutEnv("A", "A");
+ res &= CheckUnPutEnv("B=", "B");
+ res &= CheckUnPutEnv("C=D", "C");
+ /* Leave "D=E" in environment so a memory checker can test for leaks. */
+ return res;
+}
+
+//----------------------------------------------------------------------------
int testSystemTools(int, char*[])
{
bool res = true;
@@ -356,5 +408,7 @@ int testSystemTools(int, char*[])
res &= CheckStringOperations();
+ res &= CheckEnvironmentOperations();
+
return res ? 0 : 1;
}