[Cmake-commits] CMake branch, next, updated. v3.7.0-1416-g25be059

Brad King brad.king at kitware.com
Tue Nov 29 11:50:08 EST 2016


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  25be059cb83743a37db09b72ccf33862983bb416 (commit)
       via  8bced8b18de592b572eb5766c7d36d76ea789d09 (commit)
       via  cd5cff13370f6953497484f6e4b04f957fe9c9a7 (commit)
      from  57b72acd65db3dc86d326967ec0b1a304c57b6fe (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=25be059cb83743a37db09b72ccf33862983bb416
commit 25be059cb83743a37db09b72ccf33862983bb416
Merge: 57b72ac 8bced8b
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 29 11:50:07 2016 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Nov 29 11:50:07 2016 -0500

    Merge topic 'update-kwsys' into next
    
    8bced8b1 Merge branch 'upstream-KWSys' into update-kwsys
    cd5cff13 KWSys 2016-11-28 (1c7c2139)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8bced8b18de592b572eb5766c7d36d76ea789d09
commit 8bced8b18de592b572eb5766c7d36d76ea789d09
Merge: 44c978a cd5cff1
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 29 11:49:34 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Nov 29 11:49:34 2016 -0500

    Merge branch 'upstream-KWSys' into update-kwsys
    
    * upstream-KWSys:
      KWSys 2016-11-28 (1c7c2139)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd5cff13370f6953497484f6e4b04f957fe9c9a7
commit cd5cff13370f6953497484f6e4b04f957fe9c9a7
Author:     KWSys Upstream <kwrobot at kitware.com>
AuthorDate: Mon Nov 28 09:03:37 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Nov 29 11:49:33 2016 -0500

    KWSys 2016-11-28 (1c7c2139)
    
    Code extracted from:
    
        http://public.kitware.com/KWSys.git
    
    at commit 1c7c2139e773124c0a2b80e10b2840c22a750980 (master).
    
    Upstream Shortlog
    -----------------
    
    Brad King (2):
          5e556d53 Refactor CMake policy settings
          cb55cf5a Set CMake Policy CMP0063 to NEW within KWSys
    
    Dāvis Mosāns (1):
          1c7c2139 ConsoleBuf: Fix character handling between buffer boundaries

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2d313c..b8a9a6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,12 +67,15 @@
 # written.
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
-IF(POLICY CMP0025)
-  CMAKE_POLICY(SET CMP0025 NEW)
-ENDIF()
-IF(POLICY CMP0056)
-  CMAKE_POLICY(SET CMP0056 NEW)
-ENDIF()
+FOREACH(p
+    CMP0025 # CMake 3.0, Compiler id for Apple Clang is now AppleClang.
+    CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
+    CMP0063 # CMake 3.3, Honor visibility properties for all target types.
+    )
+  IF(POLICY ${p})
+    CMAKE_POLICY(SET ${p} NEW)
+  ENDIF()
+ENDFOREACH()
 SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
 
 #-----------------------------------------------------------------------------
diff --git a/ConsoleBuf.hxx.in b/ConsoleBuf.hxx.in
index 717462e..c45a351 100644
--- a/ConsoleBuf.hxx.in
+++ b/ConsoleBuf.hxx.in
@@ -147,42 +147,47 @@ protected:
         return Traits::eof();
       }
       if (m_isConsoleInput) {
-        wchar_t wbuffer[128];
+        // ReadConsole doesn't tell if there's more input available
+        // don't support reading more characters than this
+        wchar_t wbuffer[8192];
         DWORD charsRead;
-        if (::ReadConsoleW(m_hInput, wbuffer,
-                           (sizeof(wbuffer) / sizeof(wbuffer[0])) - 1,
-                           &charsRead, NULL) == 0 ||
+        if (ReadConsoleW(m_hInput, wbuffer,
+                         (sizeof(wbuffer) / sizeof(wbuffer[0])), &charsRead,
+                         NULL) == 0 ||
             charsRead == 0) {
           _setg(true);
           return Traits::eof();
         }
-        wbuffer[charsRead] = L'\0';
-        setBuffer(wbuffer, m_ibuffer);
+        setBuffer(std::wstring(wbuffer, charsRead), m_ibuffer);
       } else {
-        std::wstring totalBuffer;
         std::wstring wbuffer;
-        char buffer[128];
+        std::string strbuffer;
         DWORD bytesRead;
-        while (::ReadFile(m_hInput, buffer,
-                          (sizeof(buffer) / sizeof(buffer[0])) - 1, &bytesRead,
-                          NULL) == 0) {
-          if (::GetLastError() == ERROR_MORE_DATA) {
-            buffer[bytesRead] = '\0';
-            if (decodeInputBuffer(buffer, wbuffer)) {
-              totalBuffer += wbuffer;
-              continue;
-            }
+        LARGE_INTEGER size;
+        if (GetFileSizeEx(m_hInput, &size) == 0) {
+          _setg(true);
+          return Traits::eof();
+        }
+        char* buffer = new char[size.LowPart];
+        while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, NULL) ==
+               0) {
+          if (GetLastError() == ERROR_MORE_DATA) {
+            strbuffer += std::string(buffer, bytesRead);
+            continue;
           }
           _setg(true);
+          delete[] buffer;
           return Traits::eof();
         }
-        buffer[bytesRead] = '\0';
-        if (!decodeInputBuffer(buffer, wbuffer)) {
+        if (bytesRead > 0) {
+          strbuffer += std::string(buffer, bytesRead);
+        }
+        delete[] buffer;
+        if (!decodeInputBuffer(strbuffer, wbuffer)) {
           _setg(true);
           return Traits::eof();
         }
-        totalBuffer += wbuffer;
-        setBuffer(totalBuffer, m_ibuffer);
+        setBuffer(wbuffer, m_ibuffer);
       }
       _setg();
     }
@@ -315,6 +320,10 @@ private:
   }
   bool encodeOutputBuffer(const std::wstring wbuffer, std::string& buffer)
   {
+    if (wbuffer.size() == 0) {
+      buffer = std::string();
+      return true;
+    }
     const int length =
       WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
                           (int)wbuffer.size(), NULL, 0, NULL, NULL);
@@ -329,23 +338,31 @@ private:
     delete[] buf;
     return success;
   }
-  bool decodeInputBuffer(const char* buffer, std::wstring& wbuffer)
+  bool decodeInputBuffer(const std::string buffer, std::wstring& wbuffer)
   {
+    int length = int(buffer.length());
+    if (length == 0) {
+      wbuffer = std::wstring();
+      return true;
+    }
     int actualCodepage = m_activeInputCodepage;
     const char BOM_UTF8[] = { char(0xEF), char(0xBB), char(0xBF) };
-    if (std::memcmp(buffer, BOM_UTF8, sizeof(BOM_UTF8)) == 0) {
+    const char* data = buffer.data();
+    const size_t BOMsize = sizeof(BOM_UTF8);
+    if (length >= BOMsize && std::memcmp(data, BOM_UTF8, BOMsize) == 0) {
       // PowerShell uses UTF-8 with BOM for pipes
       actualCodepage = CP_UTF8;
-      buffer += sizeof(BOM_UTF8);
+      data += BOMsize;
+      length -= BOMsize;
     }
     const int wlength =
-      MultiByteToWideChar(actualCodepage, 0, buffer, -1, NULL, 0);
+      MultiByteToWideChar(actualCodepage, 0, data, length, NULL, 0);
     wchar_t* wbuf = new wchar_t[wlength];
     const bool success =
-      MultiByteToWideChar(actualCodepage, 0, buffer, -1, wbuf, wlength) > 0
+      MultiByteToWideChar(actualCodepage, 0, data, length, wbuf, wlength) > 0
       ? true
       : false;
-    wbuffer = wbuf;
+    wbuffer = std::wstring(wbuf, wlength);
     delete[] wbuf;
     return success;
   }

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

Summary of changes:
 Source/kwsys/CMakeLists.txt    |   15 +++++----
 Source/kwsys/ConsoleBuf.hxx.in |   71 +++++++++++++++++++++++++---------------
 2 files changed, 53 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list