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  d4506d1708d5da92f5ba26b43262db6d8b0077f9 (commit)
       via  b17d835f7d6047dfb5ec33283eb75c4c5ebdc353 (commit)
       via  f31d11f635edd36d6ef3d946a475565533b33854 (commit)
       via  0379c24d878e763ebb5918014fc58380a379ac18 (commit)
       via  c805a31c2ced7199b2807cecc22213e96c0279c8 (commit)
      from  a2742925ced9b822a2249aad5982b5d8f07c8c02 (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=d4506d1708d5da92f5ba26b43262db6d8b0077f9
commit d4506d1708d5da92f5ba26b43262db6d8b0077f9
Merge: a274292 b17d835
Author:     Clinton Stimpson <clin...@elemtech.com>
AuthorDate: Mon Jan 26 10:38:00 2015 -0500
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Mon Jan 26 10:38:00 2015 -0500

    Merge topic 'file-strings-utf-16' into next
    
    b17d835f StringFileTest: Use LENGTH_MINIMUM instead of REGEX.
    f31d11f6 StringFileTest: read files using same encoding. Add tests for BOM 
use.
    0379c24d Add test for file(STRINGS) with UTF-16 and UTF-32 encodings.
    c805a31c file STRINGS UTF-16 and UTF-32 convertible to ASCII


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b17d835f7d6047dfb5ec33283eb75c4c5ebdc353
commit b17d835f7d6047dfb5ec33283eb75c4c5ebdc353
Author:     Clinton Stimpson <clin...@elemtech.com>
AuthorDate: Mon Jan 26 08:27:59 2015 -0700
Commit:     Clinton Stimpson <clin...@elemtech.com>
CommitDate: Mon Jan 26 08:32:13 2015 -0700

    StringFileTest: Use LENGTH_MINIMUM instead of REGEX.
    
    This clarifies the intent of getting strings longer than 4.

diff --git a/Tests/StringFileTest/CMakeLists.txt 
b/Tests/StringFileTest/CMakeLists.txt
index 3998b7e..539b854 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -69,7 +69,7 @@ endif()
 foreach(bit 16 32)
   foreach(endian LE BE)
     set(file_to_check UTF-${bit}${endian}.txt)
-    file(STRINGS ${file_to_check} str ENCODING UTF-${bit}${endian} REGEX 
"....")
+    file(STRINGS ${file_to_check} str ENCODING UTF-${bit}${endian} 
LENGTH_MINIMUM 4)
     message("${file_to_check} as UTF-${bit}${endian}: ${str}")
     if(NOT str MATCHES "Hello World")
         message(SEND_ERROR

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f31d11f635edd36d6ef3d946a475565533b33854
commit f31d11f635edd36d6ef3d946a475565533b33854
Author:     Justin Borodinsky <justin.borodin...@gmail.com>
AuthorDate: Fri Jan 16 20:13:01 2015 -0500
Commit:     Clinton Stimpson <clin...@elemtech.com>
CommitDate: Mon Jan 26 08:32:13 2015 -0700

    StringFileTest: read files using same encoding. Add tests for BOM use.

diff --git a/Tests/StringFileTest/CMakeLists.txt 
b/Tests/StringFileTest/CMakeLists.txt
index 7a818cb..3998b7e 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -69,22 +69,25 @@ endif()
 foreach(bit 16 32)
   foreach(endian LE BE)
     set(file_to_check UTF-${bit}${endian}.txt)
-    foreach(bit_check 16 32)
-      foreach(endian_check LE BE)
-        file(STRINGS ${file_to_check} str ENCODING 
UTF-${bit_check}${endian_check})
-        if("${bit}" STREQUAL "${bitcheck}")
-          if(NOT str MATCHES "Hello World")
-            message(SEND_ERROR
+    file(STRINGS ${file_to_check} str ENCODING UTF-${bit}${endian} REGEX 
"....")
+    message("${file_to_check} as UTF-${bit}${endian}: ${str}")
+    if(NOT str MATCHES "Hello World")
+        message(SEND_ERROR
               "file(STRINGS) incorrectly read from ${file_to_check} file 
[${str}]")
-          endif()
-        else()
-          if(NOT "${str}" STREQUAL "")
-            message(SEND_ERROR
+    endif()
+  endforeach()
+endforeach()
+
+# check files using BOM for encoding
+foreach(bit 16 32)
+  foreach(endian LE BE)
+    set(file_to_check UTF-${bit}${endian}.txt)
+    file(STRINGS ${file_to_check} str REGEX "....")
+    message("${file_to_check} : ${str}")
+    if(NOT str MATCHES "Hello World")
+        message(SEND_ERROR
               "file(STRINGS) incorrectly read from ${file_to_check} file 
[${str}]")
-          endif()
-        endif()
-      endforeach()
-    endforeach()
+    endif()
   endforeach()
 endforeach()
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0379c24d878e763ebb5918014fc58380a379ac18
commit 0379c24d878e763ebb5918014fc58380a379ac18
Author:     Clinton Stimpson <clin...@elemtech.com>
AuthorDate: Tue Jan 13 22:29:55 2015 -0700
Commit:     Clinton Stimpson <clin...@elemtech.com>
CommitDate: Mon Jan 26 08:32:13 2015 -0700

    Add test for file(STRINGS) with UTF-16 and UTF-32 encodings.

diff --git a/Tests/StringFileTest/CMakeLists.txt 
b/Tests/StringFileTest/CMakeLists.txt
index faf3bc9..7a818cb 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -65,6 +65,29 @@ else()
     "file(STRINGS) incorrectly read from utf8 file [${infile_strings}]")
 endif()
 
+# check files with UTF-16 or UTF-32 content
+foreach(bit 16 32)
+  foreach(endian LE BE)
+    set(file_to_check UTF-${bit}${endian}.txt)
+    foreach(bit_check 16 32)
+      foreach(endian_check LE BE)
+        file(STRINGS ${file_to_check} str ENCODING 
UTF-${bit_check}${endian_check})
+        if("${bit}" STREQUAL "${bitcheck}")
+          if(NOT str MATCHES "Hello World")
+            message(SEND_ERROR
+              "file(STRINGS) incorrectly read from ${file_to_check} file 
[${str}]")
+          endif()
+        else()
+          if(NOT "${str}" STREQUAL "")
+            message(SEND_ERROR
+              "file(STRINGS) incorrectly read from ${file_to_check} file 
[${str}]")
+          endif()
+        endif()
+      endforeach()
+    endforeach()
+  endforeach()
+endforeach()
+
 # String test
 string(REGEX MATCH "[cC][mM][aA][kK][eE]" rmvar "CMake is great")
 string(REGEX MATCHALL "[cC][mM][aA][kK][eE]" rmallvar "CMake is better than 
cmake or CMake")
diff --git a/Tests/StringFileTest/UTF-16BE.txt 
b/Tests/StringFileTest/UTF-16BE.txt
new file mode 100644
index 0000000..9d976bc
Binary files /dev/null and b/Tests/StringFileTest/UTF-16BE.txt differ
diff --git a/Tests/StringFileTest/UTF-16LE.txt 
b/Tests/StringFileTest/UTF-16LE.txt
new file mode 100644
index 0000000..ebba874
Binary files /dev/null and b/Tests/StringFileTest/UTF-16LE.txt differ
diff --git a/Tests/StringFileTest/UTF-32BE.txt 
b/Tests/StringFileTest/UTF-32BE.txt
new file mode 100644
index 0000000..6725fbb
Binary files /dev/null and b/Tests/StringFileTest/UTF-32BE.txt differ
diff --git a/Tests/StringFileTest/UTF-32LE.txt 
b/Tests/StringFileTest/UTF-32LE.txt
new file mode 100644
index 0000000..cf5102f
Binary files /dev/null and b/Tests/StringFileTest/UTF-32LE.txt differ

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c805a31c2ced7199b2807cecc22213e96c0279c8
commit c805a31c2ced7199b2807cecc22213e96c0279c8
Author:     Justin Borodinsky <justin.borodin...@gmail.com>
AuthorDate: Sun Jan 11 14:33:36 2015 -0500
Commit:     Clinton Stimpson <clin...@elemtech.com>
CommitDate: Mon Jan 26 08:32:13 2015 -0700

    file STRINGS UTF-16 and UTF-32 convertible to ASCII

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index f125292..579e715 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -472,7 +472,13 @@ bool 
cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
   bool have_regex = false;
   bool newline_consume = false;
   bool hex_conversion_enabled = true;
-  bool utf8_encoding = false;
+  enum { encoding_none = cmsys::FStream::BOM_None,
+         encoding_utf8 = cmsys::FStream::BOM_UTF8,
+         encoding_utf16le = cmsys::FStream::BOM_UTF16LE,
+         encoding_utf16be = cmsys::FStream::BOM_UTF16BE,
+         encoding_utf32le = cmsys::FStream::BOM_UTF32LE,
+         encoding_utf32be = cmsys::FStream::BOM_UTF32BE};
+  int encoding = encoding_none;
   int arg_mode = arg_none;
   for(unsigned int i=3; i < args.size(); ++i)
     {
@@ -599,7 +605,23 @@ bool 
cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
       {
       if(args[i] == "UTF-8")
         {
-        utf8_encoding = true;
+        encoding = encoding_utf8;
+        }
+      else if(args[i] == "UTF-16LE")
+        {
+        encoding = encoding_utf16le;
+        }
+      else if(args[i] == "UTF-16BE")
+        {
+        encoding = encoding_utf16be;
+        }
+      else if(args[i] == "UTF-32LE")
+        {
+        encoding = encoding_utf32le;
+        }
+      else if(args[i] == "UTF-32BE")
+        {
+        encoding = encoding_utf32be;
         }
       else
         {
@@ -647,6 +669,23 @@ bool 
cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
     return false;
     }
 
+  //If BOM is found and encoding was not specified, use the BOM
+  int bom_found = cmsys::FStream::ReadBOM(fin);
+  if(encoding == encoding_none && bom_found != cmsys::FStream::BOM_None)
+    {
+    encoding = bom_found;
+    }
+
+  unsigned int bytes_rem = 0;
+  if(encoding == encoding_utf16le || encoding == encoding_utf16be)
+    {
+    bytes_rem = 1;
+    }
+  if(encoding == encoding_utf32le || encoding == encoding_utf32be)
+    {
+    bytes_rem = 3;
+    }
+
   // Parse strings out of the file.
   int output_size = 0;
   std::vector<std::string> strings;
@@ -658,6 +697,25 @@ bool 
cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
     std::string current_str;
 
     int c = fin.get();
+    for(unsigned int i=0; i<bytes_rem; ++i)
+      {
+      int c1 = fin.get();
+      if(!fin)
+        {
+        fin.putback(static_cast<char>(c1));
+        break;
+        }
+      c = (c << 8) | c1;
+      }
+    if(encoding == encoding_utf16le)
+      {
+      c = ((c & 0xFF) << 8) | ((c & 0xFF00) >> 8);
+      }
+    else if(encoding == encoding_utf32le)
+      {
+       c = (((c & 0xFF) << 24) | ((c & 0xFF00) << 8) |
+          ((c & 0xFF0000) >> 8) | ((c & 0xFF000000) >> 24));
+      }
 
     if(c == '\r')
       {
@@ -673,7 +731,7 @@ bool 
cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
       // c is guaranteed to fit in char by the above if...
       current_str += static_cast<char>(c);
       }
-    else if(utf8_encoding)
+    else if(encoding == encoding_utf8)
       {
       // Check for UTF-8 encoded string (up to 4 octets)
       static const unsigned char utf8_check_table[3][2] =

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

Summary of changes:
 Source/cmFileCommand.cxx            |   64 +++++++++++++++++++++++++++++++++--
 Tests/StringFileTest/CMakeLists.txt |   26 ++++++++++++++
 Tests/StringFileTest/UTF-16BE.txt   |  Bin 0 -> 83 bytes
 Tests/StringFileTest/UTF-16LE.txt   |  Bin 0 -> 83 bytes
 Tests/StringFileTest/UTF-32BE.txt   |  Bin 0 -> 165 bytes
 Tests/StringFileTest/UTF-32LE.txt   |  Bin 0 -> 165 bytes
 6 files changed, 87 insertions(+), 3 deletions(-)
 create mode 100644 Tests/StringFileTest/UTF-16BE.txt
 create mode 100644 Tests/StringFileTest/UTF-16LE.txt
 create mode 100644 Tests/StringFileTest/UTF-32BE.txt
 create mode 100644 Tests/StringFileTest/UTF-32LE.txt


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/mailman/listinfo/cmake-commits

Reply via email to