[Cmake-commits] CMake branch, next, updated. v2.8.3-1182-ge13cd47

Brad King brad.king at kitware.com
Tue Jan 4 13:31:45 EST 2011


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  e13cd47017db9acfe53458331aece28e7cb4cc17 (commit)
       via  e73bf1c384b644a122cccc4a85a1c0fb0943759a (commit)
      from  eb7aa7392e45c0bb0de117688ef7b033b0bad333 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e13cd47017db9acfe53458331aece28e7cb4cc17
commit e13cd47017db9acfe53458331aece28e7cb4cc17
Merge: eb7aa73 e73bf1c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 4 13:31:31 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jan 4 13:31:31 2011 -0500

    Merge topic 'fix-test-output-truncation' into next
    
    e73bf1c CTest: Do not truncate UTF-8 test output too early (#10656)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e73bf1c384b644a122cccc4a85a1c0fb0943759a
commit e73bf1c384b644a122cccc4a85a1c0fb0943759a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 4 13:20:49 2011 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 4 13:20:49 2011 -0500

    CTest: Do not truncate UTF-8 test output too early (#10656)
    
    Since commit e4beefeb (CTest: Do not munge UTF-8 output in XML files,
    2009-12-08) we validate UTF-8 encoding of build and test output as it is
    written to XML files.  However, in cmCTestTestHandler::CleanTestOutput
    we still processed test output one byte at a time and did not recognize
    multi-byte UTF-8 characters.  Presence of such characters caused early
    truncation.
    
    Teach CleanTestOutput to truncate test output at the limit but without
    cutting it in the middle of a multi-byte encoding.  Also, stop avoiding
    truncation in the middle of an XML tag like "<MyElement>" because the
    '<' and '>' will be properly escaped in the generated XML anyway.

diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 6d1af2d..d1bc837 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -26,6 +26,7 @@
 #include "cmCommand.h"
 #include "cmSystemTools.h"
 #include "cmXMLSafe.h"
+#include "cm_utf8.h"
 
 #include <stdlib.h>
 #include <math.h>
@@ -1980,65 +1981,45 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
     }
 }
 
-//----------------------------------------------------------------------
-bool cmCTestTestHandler::CleanTestOutput(std::string& output,
-  size_t remove_threshold)
+//----------------------------------------------------------------------------
+bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
 {
-  if ( remove_threshold == 0 )
+  if(!length || length >= output.size() ||
+     output.find("CTEST_FULL_OUTPUT") != output.npos)
     {
     return true;
     }
-  if ( output.find("CTEST_FULL_OUTPUT") != output.npos )
+
+  // Truncate at given length but do not break in the middle of a multi-byte
+  // UTF-8 encoding.
+  char const* const begin = output.c_str();
+  char const* const end = begin + output.size();
+  char const* const truncate = begin + length;
+  char const* current = begin;
+  while(current < truncate)
     {
-    return true;
-    }
-  cmOStringStream ostr;
-  std::string::size_type cc;
-  std::string::size_type skipsize = 0;
-  int inTag = 0;
-  int skipped = 0;
-  for ( cc = 0; cc < output.size(); cc ++ )
-    {
-    int ch = output[cc];
-    if ( ch < 0 || ch > 255 )
-      {
-      break;
-      }
-    if ( ch == '<' )
-      {
-      inTag = 1;
-      }
-    if ( !inTag )
+    unsigned int ch;
+    if(const char* next = cm_utf8_decode_character(current, end, &ch))
       {
-      int notskip = 0;
-      // Skip
-      if ( skipsize < remove_threshold )
-        {
-        ostr << static_cast<char>(ch);
-        notskip = 1;
-        }
-      skipsize ++;
-      if ( notskip && skipsize >= remove_threshold )
+      if(next > truncate)
         {
-        skipped = 1;
+        break;
         }
+      current = next;
       }
-    else
-      {
-      ostr << static_cast<char>(ch);
-      }
-    if ( ch == '>' )
+    else // Bad byte will be handled by cmXMLSafe.
       {
-      inTag = 0;
+      ++current;
       }
     }
-  if ( skipped )
-    {
-    ostr << "..." << std::endl << "The rest of the test output was removed "
-      "since it exceeds the threshold of "
-      << remove_threshold << " characters." << std::endl;
-    }
-  output = ostr.str();
+  output = output.substr(0, current - begin);
+
+  // Append truncation message.
+  cmOStringStream msg;
+  msg << "...\n"
+    "The rest of the test output was removed since it exceeds the threshold "
+    "of " << length << " bytes.\n";
+  output += msg.str();
   return true;
 }
 

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

Summary of changes:
 Source/CTest/cmCTestTestHandler.cxx |   75 +++++++++++++----------------------
 1 files changed, 28 insertions(+), 47 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list