[Cmake-commits] CMake branch, next, updated. v3.7.2-2204-ga191239

Brad King brad.king at kitware.com
Mon Jan 16 14:12:46 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  a19123906c75f70d8f8289c57bd6e8bf4a24ae8b (commit)
       via  ee77941a1fdf3a617207b00a7f2e9315eaef7b31 (commit)
       via  219c7bdcb16cd1dfe2e72befa4334c5b8147e1d7 (commit)
      from  2af02e78b771682ddfe50f4a0cd7a16fc021ff56 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a19123906c75f70d8f8289c57bd6e8bf4a24ae8b
commit a19123906c75f70d8f8289c57bd6e8bf4a24ae8b
Merge: 2af02e7 ee77941
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jan 16 14:12:46 2017 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jan 16 14:12:46 2017 -0500

    Merge topic 'update-kwsys' into next
    
    ee77941a Merge branch 'upstream-KWSys' into update-kwsys
    219c7bdc KWSys 2017-01-16 (a423d829)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee77941a1fdf3a617207b00a7f2e9315eaef7b31
commit ee77941a1fdf3a617207b00a7f2e9315eaef7b31
Merge: 35ad12f 219c7bd
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jan 16 14:06:29 2017 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jan 16 14:06:29 2017 -0500

    Merge branch 'upstream-KWSys' into update-kwsys
    
    * upstream-KWSys:
      KWSys 2017-01-16 (a423d829)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=219c7bdcb16cd1dfe2e72befa4334c5b8147e1d7
commit 219c7bdcb16cd1dfe2e72befa4334c5b8147e1d7
Author:     KWSys Upstream <kwrobot at kitware.com>
AuthorDate: Mon Jan 16 08:53:56 2017 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jan 16 14:06:28 2017 -0500

    KWSys 2017-01-16 (a423d829)
    
    Code extracted from:
    
        https://gitlab.kitware.com/utils/kwsys.git
    
    at commit a423d82989a4b89fa7d17f3dd5215684e902208e (master).
    
    Upstream Shortlog
    -----------------
    
    Ben Boeckel (1):
          45db0937 SystemTools: use PathExists where appropriate
    
    Brad King (1):
          e08eee61 SystemTools: Fix conversion warning in test case
    
    Eric Berge (1):
          687fcd79 Add -lsocket for libcmsys.a build on SunOS
    
    Gregor Jasny (1):
          0541ce21 SystemTools: Fix off-by-one in GetLineFromStream with size limit

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9eb3b2d..d4fe8a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -818,6 +818,9 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
         # for symbol lookup using dladdr
         TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
       ENDIF()
+      IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+        TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} socket)
+      ENDIF()
     ENDIF()
   ENDIF()
 
diff --git a/SystemTools.cxx b/SystemTools.cxx
index b018a43..97dd4ae 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -763,7 +763,7 @@ bool SystemTools::MakeDirectory(const char* path)
 
 bool SystemTools::MakeDirectory(const std::string& path)
 {
-  if (SystemTools::FileExists(path)) {
+  if (SystemTools::PathExists(path)) {
     return SystemTools::FileIsDirectory(path);
   }
   if (path.empty()) {
@@ -1280,7 +1280,7 @@ bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
 
 bool SystemTools::Touch(const std::string& filename, bool create)
 {
-  if (!SystemTools::FileExists(filename)) {
+  if (!SystemTools::PathExists(filename)) {
     if (create) {
       FILE* file = Fopen(filename, "a+b");
       if (file) {
@@ -4289,7 +4289,7 @@ bool SystemTools::GetLineFromStream(std::istream& is, std::string& line,
     // if we read too much then truncate the buffer
     if (leftToRead > 0) {
       if (static_cast<long>(length) > leftToRead) {
-        buffer[leftToRead - 1] = 0;
+        buffer[leftToRead] = 0;
         leftToRead = 0;
       } else {
         leftToRead -= static_cast<long>(length);
@@ -4389,10 +4389,7 @@ bool SystemTools::SetPermissions(const char* file, mode_t mode,
 bool SystemTools::SetPermissions(const std::string& file, mode_t mode,
                                  bool honor_umask)
 {
-  // TEMPORARY / TODO:  After FileExists calls lstat() instead of
-  // access(), change this call to FileExists instead of
-  // TestFileAccess so that we don't follow symlinks.
-  if (!SystemTools::TestFileAccess(file, TEST_FILE_OK)) {
+  if (!SystemTools::PathExists(file)) {
     return false;
   }
   if (honor_umask) {
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index b04f2cb..8e1ea25 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -6,11 +6,13 @@
 #pragma warning(disable : 4786)
 #endif
 
+#include KWSYS_HEADER(FStream.hxx)
 #include KWSYS_HEADER(SystemTools.hxx)
 
 // Work-around CMake dependency scanning limitation.  This must
 // duplicate the above list of headers.
 #if 0
+#include "FStream.hxx.in"
 #include "SystemTools.hxx.in"
 #endif
 
@@ -857,6 +859,55 @@ static bool CheckFind()
   return res;
 }
 
+static bool CheckGetLineFromStream()
+{
+  const std::string fileWithFiveCharsOnFirstLine(TEST_SYSTEMTOOLS_SOURCE_DIR
+                                                 "/README.rst");
+
+  kwsys::ifstream file(fileWithFiveCharsOnFirstLine.c_str(), std::ios::in);
+
+  if (!file) {
+    std::cerr << "Problem opening: " << fileWithFiveCharsOnFirstLine
+              << std::endl;
+    return false;
+  }
+
+  std::string line;
+  bool has_newline = false;
+  bool result;
+
+  file.seekg(0, std::ios::beg);
+  result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1);
+  if (!result || line.size() != 5) {
+    std::cerr << "First line does not have five characters: " << line.size()
+              << std::endl;
+    return false;
+  }
+
+  file.seekg(0, std::ios::beg);
+  result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1);
+  if (!result || line.size() != 5) {
+    std::cerr << "First line does not have five characters after rewind: "
+              << line.size() << std::endl;
+    return false;
+  }
+
+  bool ret = true;
+
+  for (size_t size = 1; size <= 5; ++size) {
+    file.seekg(0, std::ios::beg);
+    result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline,
+                                                   static_cast<long>(size));
+    if (!result || line.size() != size) {
+      std::cerr << "Should have read " << size << " characters but got "
+                << line.size() << std::endl;
+      ret = false;
+    }
+  }
+
+  return ret;
+}
+
 //----------------------------------------------------------------------------
 int testSystemTools(int, char* [])
 {
@@ -893,5 +944,7 @@ int testSystemTools(int, char* [])
 
   res &= CheckFind();
 
+  res &= CheckGetLineFromStream();
+
   return res ? 0 : 1;
 }

-----------------------------------------------------------------------

Summary of changes:
 Source/kwsys/CMakeLists.txt      |    3 +++
 Source/kwsys/SystemTools.cxx     |   11 +++-----
 Source/kwsys/testSystemTools.cxx |   53 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list