[Cmake-commits] CMake branch, next, updated. v3.0.0-4026-g7243483

Clinton Stimpson clinton at elemtech.com
Mon Jun 30 22:48:20 EDT 2014


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  724348323c1b882f127d90df0714faedc6461804 (commit)
       via  d5160fd4916b98ede37446f88f504961704ffd27 (commit)
      from  2f8fa2dc6c36f450c6d74be64735abca32214387 (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=724348323c1b882f127d90df0714faedc6461804
commit 724348323c1b882f127d90df0714faedc6461804
Merge: 2f8fa2d d5160fd
Author:     Clinton Stimpson <clinton at elemtech.com>
AuthorDate: Mon Jun 30 22:48:19 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jun 30 22:48:19 2014 -0400

    Merge topic 'libarchive-encoding' into next
    
    d5160fd4 Encoding: Create helper functions for some libarchive calls.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5160fd4916b98ede37446f88f504961704ffd27
commit d5160fd4916b98ede37446f88f504961704ffd27
Author:     Clinton Stimpson <clinton at elemtech.com>
AuthorDate: Mon Jun 30 20:46:33 2014 -0600
Commit:     Clinton Stimpson <clinton at elemtech.com>
CommitDate: Mon Jun 30 20:46:33 2014 -0600

    Encoding: Create helper functions for some libarchive calls.
    
    These helper functions reduce the number of conditionals.

diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index e6a3e70..3b0ead5 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -25,6 +25,28 @@ static std::string cm_archive_error_string(struct archive* a)
 }
 
 //----------------------------------------------------------------------------
+static void cm_archive_entry_copy_pathname(struct archive_entry* e,
+  const std::string& dest)
+{
+#if cmsys_STL_HAS_WSTRING
+  archive_entry_copy_pathname_w(e, cmsys::Encoding::ToWide(dest).c_str());
+#else
+  archive_entry_copy_pathname(e, dest.c_str());
+#endif
+}
+
+//----------------------------------------------------------------------------
+static void cm_archive_entry_copy_sourcepath(struct archive_entry* e,
+  const std::string& file)
+{
+#if cmsys_STL_HAS_WSTRING
+  archive_entry_copy_sourcepath_w(e, cmsys::Encoding::ToWide(file).c_str());
+#else
+  archive_entry_copy_sourcepath(e, file.c_str());
+#endif
+}
+
+//----------------------------------------------------------------------------
 class cmArchiveWrite::Entry
 {
   struct archive_entry* Object;
@@ -237,13 +259,8 @@ bool cmArchiveWrite::AddFile(const char* file,
     std::cout << dest << "\n";
     }
   Entry e;
-#if cmsys_STL_HAS_WSTRING
-  archive_entry_copy_sourcepath_w(e, cmsys::Encoding::ToWide(file).c_str());
-  archive_entry_copy_pathname_w(e, cmsys::Encoding::ToWide(dest).c_str());
-#else
-  archive_entry_copy_sourcepath(e, file);
-  archive_entry_copy_pathname(e, dest.c_str());
-#endif
+  cm_archive_entry_copy_sourcepath(e, file);
+  cm_archive_entry_copy_pathname(e, dest);
   if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK)
     {
     this->Error = "archive_read_disk_entry_from_file: ";
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index ed0cb4c..d0fa834 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -91,6 +91,31 @@ extern char** environ;
 # endif
 #endif
 
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+static std::string
+cm_archive_entry_pathname(struct archive_entry *entry)
+{
+#if cmsys_STL_HAS_WSTRING
+  return cmsys::Encoding::ToNarrow(
+    archive_entry_pathname_w(entry)).c_str();
+#else
+  return archive_entry_pathname(entry);
+#endif
+}
+
+static int cm_archive_read_open_file(struct archive* a,
+                                     const char* file,
+                                     int block_size)
+{
+#if cmsys_STL_HAS_WSTRING
+  std::wstring wfile = cmsys::Encoding::ToWide(file);
+  return archive_read_open_filename_w(a, wfile.c_str(), block_size);
+#else
+  return archive_read_open_filename(a, file, block_size);
+#endif
+}
+#endif
+
 #ifdef _WIN32
 class cmSystemToolsWindowsHandle
 {
@@ -1581,12 +1606,7 @@ namespace{
     }
   strftime(tmp, sizeof(tmp), fmt, localtime(&tim));
   fprintf(out, " %s ", tmp);
-#if cmsys_STL_HAS_WSTRING
-  fprintf(out, "%s",
-    cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry)).c_str());
-#else
-  fprintf(out, "%s", archive_entry_pathname(entry));
-#endif
+  fprintf(out, "%s", cm_archive_entry_pathname(entry).c_str());
 
   /* Extra information for links. */
   if (archive_entry_hardlink(entry)) /* Hard link */
@@ -1646,12 +1666,7 @@ bool extract_tar(const char* outFileName, bool verbose,
   archive_read_support_compression_all(a);
   archive_read_support_format_all(a);
   struct archive_entry *entry;
-#if cmsys_STL_HAS_WSTRING
-  std::wstring wOutFileName = cmsys::Encoding::ToWide(outFileName);
-  int r = archive_read_open_filename_w(a, wOutFileName.c_str(), 10240);
-#else
-  int r = archive_read_open_file(a, outFileName, 10240);
-#endif
+  int r = cm_archive_read_open_file(a, outFileName, 10240);
   if(r)
     {
     cmSystemTools::Error("Problem with archive_read_open_file(): ",
@@ -1676,12 +1691,7 @@ bool extract_tar(const char* outFileName, bool verbose,
       if(extract)
         {
         cmSystemTools::Stdout("x ");
-#if cmsys_STL_HAS_WSTRING
-        cmSystemTools::Stdout(
-          cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry)).c_str());
-#else
-        cmSystemTools::Stdout(archive_entry_pathname(entry));
-#endif
+        cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
         }
       else
         {
@@ -1691,12 +1701,7 @@ bool extract_tar(const char* outFileName, bool verbose,
       }
     else if(!extract)
       {
-#if cmsys_STL_HAS_WSTRING
-      cmSystemTools::Stdout(
-        cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry)).c_str());
-#else
-        cmSystemTools::Stdout(archive_entry_pathname(entry));
-#endif
+      cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
       cmSystemTools::Stdout("\n");
       }
     if(extract)
@@ -1726,13 +1731,9 @@ bool extract_tar(const char* outFileName, bool verbose,
       else if(const char* linktext = archive_entry_symlink(entry))
         {
         std::cerr << "cmake -E tar: warning: skipping symbolic link \""
-#if cmsys_STL_HAS_WSTRING
-                 << cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry))
-#else
-                 << archive_entry_pathname(entry)
-#endif
-                 << "\" -> \""
-                 << linktext << "\"." << std::endl;
+                  << cm_archive_entry_pathname(entry)
+                  << "\" -> \""
+                  << linktext << "\"." << std::endl;
         }
 #endif
       else
@@ -1740,12 +1741,7 @@ bool extract_tar(const char* outFileName, bool verbose,
         cmSystemTools::Error("Problem with archive_write_header(): ",
                              archive_error_string(ext));
         cmSystemTools::Error("Current file: ",
-#if cmsys_STL_HAS_WSTRING
-          cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry)).c_str()
-#else
-          archive_entry_pathname(entry)
-#endif
-          );
+                             cm_archive_entry_pathname(entry).c_str());
         break;
         }
       }

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

Summary of changes:
 Source/cmArchiveWrite.cxx |   31 +++++++++++++++-----
 Source/cmSystemTools.cxx  |   70 +++++++++++++++++++++------------------------
 2 files changed, 57 insertions(+), 44 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list