pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/libfilezilla Add two patches from upstream that fi...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3493bcbc4de5
branches:  trunk
changeset: 350061:3493bcbc4de5
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Thu Jul 21 17:16:17 2016 +0000

description:
Add two patches from upstream that fix wide character support.

In particular, this fixes ftp mode.

Investigated with upstream by richard@, thank you very much!

Bump PKGREVISION.

diffstat:

 net/libfilezilla/Makefile                       |   3 +-
 net/libfilezilla/distinfo                       |   4 +-
 net/libfilezilla/patches/patch-lib_string.cpp   |  84 +++++++++++++++++++++++++
 net/libfilezilla/patches/patch-tests_string.cpp |  54 ++++++++++++++++
 4 files changed, 143 insertions(+), 2 deletions(-)

diffs (171 lines):

diff -r ace7f9c3cd04 -r 3493bcbc4de5 net/libfilezilla/Makefile
--- a/net/libfilezilla/Makefile Thu Jul 21 17:05:52 2016 +0000
+++ b/net/libfilezilla/Makefile Thu Jul 21 17:16:17 2016 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.2 2016/07/19 18:42:22 wiz Exp $
+# $NetBSD: Makefile,v 1.3 2016/07/21 17:16:17 wiz Exp $
 
 DISTNAME=      libfilezilla-0.5.3
+PKGREVISION=   1
 CATEGORIES=    devel
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE:=filezilla/}
 EXTRACT_SUFX=  .tar.bz2
diff -r ace7f9c3cd04 -r 3493bcbc4de5 net/libfilezilla/distinfo
--- a/net/libfilezilla/distinfo Thu Jul 21 17:05:52 2016 +0000
+++ b/net/libfilezilla/distinfo Thu Jul 21 17:16:17 2016 +0000
@@ -1,6 +1,8 @@
-$NetBSD: distinfo,v 1.3 2016/07/19 18:42:22 wiz Exp $
+$NetBSD: distinfo,v 1.4 2016/07/21 17:16:17 wiz Exp $
 
 SHA1 (libfilezilla-0.5.3.tar.bz2) = 035c79d677ee7ab00aaf7b3b65e47139e955f072
 RMD160 (libfilezilla-0.5.3.tar.bz2) = bcc0905c81030c0b8ec563bd3017b404f82271cd
 SHA512 (libfilezilla-0.5.3.tar.bz2) = 73c1e5a8940e08dc96f511dc5dce7bdc17d2feada131b4459e8a65c074e48a04b7eb884e55a59ac1e04c72ae47cd596c8f668cd7086f302f86bdbb14a32e83cd
 Size (libfilezilla-0.5.3.tar.bz2) = 376339 bytes
+SHA1 (patch-lib_string.cpp) = 00632aede9d27348efa664bfa84f6dbe90f92dd2
+SHA1 (patch-tests_string.cpp) = 7c55ccccfebdf81e50bbe8f8f44351b41505f554
diff -r ace7f9c3cd04 -r 3493bcbc4de5 net/libfilezilla/patches/patch-lib_string.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfilezilla/patches/patch-lib_string.cpp     Thu Jul 21 17:16:17 2016 +0000
@@ -0,0 +1,84 @@
+$NetBSD: patch-lib_string.cpp,v 1.4 2016/07/21 17:16:17 wiz Exp $
+
+SVN 7668
+
+--- lib/string.cpp.orig        2016-06-20 08:08:07.000000000 +0000
++++ lib/string.cpp
+@@ -95,6 +95,59 @@ std::wstring to_wstring(std::string cons
+ // Depending which one is used, declare iconv_second_arg_type as either char* or char const*
+ extern "C" typedef size_t (*iconv_prototype_with_const)(iconv_t, char const**, size_t *, char**, size_t *);
+ typedef std::conditional<std::is_same<decltype(&iconv), iconv_prototype_with_const>::value, char const*, char*>::type iconv_second_arg_type;
++
++namespace {
++// On some platforms, e.g. those derived from SunOS, iconv does not understand "WCHAR_T", so we
++// need to guess an encoding.
++char const* const calc_wchar_t_encoding()
++{
++      auto try_encoding = [](char const* const encoding) -> bool {
++              iconv_t cd = iconv_open(encoding, "UTF-8");
++              if (cd == reinterpret_cast<iconv_t>(-1)) {
++                      return false;
++              }
++              iconv_close(cd);
++              return true;
++              
++      };
++      if (try_encoding("WCHAR_T")) {
++              return "WCHAR_T";
++      }
++      else {
++              // Explicitly specify endianess, otherwise we'll get a BOM prefixed to everything
++
++              int const i = 1;
++              char const* p = reinterpret_cast<char const*>(&i);
++              bool little_endian = p[0] == 1;
++
++              if (sizeof(wchar_t) == 4) {
++                      if (little_endian && try_encoding("UTF-32LE")) {
++                              return "UTF-32LE";
++                      }
++                      if (!little_endian && try_encoding("UTF-32BE")) {
++                              return "UTF-32BE";
++                      }
++              }
++              else if (sizeof(wchar_t) == 2) {
++                      if (little_endian && try_encoding("UTF-16LE")) {
++                              return "UTF-16LE";
++                      }
++                      if (!little_endian && try_encoding("UTF-16BE")) {
++                              return "UTF-16BE";
++                      }
++              }
++      }
++
++      // Oh dear...
++      return "WCHAR_T";
++}
++
++char const* wchar_t_encoding()
++{
++      static char const* const encoding = calc_wchar_t_encoding();
++      return encoding;
++}
++}
+ #endif
+ 
+ std::wstring to_wstring_from_utf8(std::string const& in)
+@@ -111,7 +164,7 @@ std::wstring to_wstring_from_utf8(std::s
+                       MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, in_p, len, out_p, len);
+               }
+ #else
+-              iconv_t cd = iconv_open("WCHAR_T", "UTF-8");
++              iconv_t cd = iconv_open(wchar_t_encoding(), "UTF-8");
+               if (cd != reinterpret_cast<iconv_t>(-1)) {
+                       auto in_p = const_cast<iconv_second_arg_type>(in.c_str());
+                       size_t in_len = in.size();
+@@ -175,7 +228,7 @@ std::string FZ_PUBLIC_SYMBOL to_utf8(std
+                       WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, in_p, len, out_p, len, 0, 0);
+               }
+ #else
+-              iconv_t cd = iconv_open("UTF-8", "WCHAR_T");
++              iconv_t cd = iconv_open("UTF-8", wchar_t_encoding());
+               if (cd != reinterpret_cast<iconv_t>(-1)) {
+                       auto in_p = reinterpret_cast<iconv_second_arg_type>(const_cast<wchar_t*>(in.c_str()));
+                       size_t in_len = in.size() * sizeof(wchar_t);
diff -r ace7f9c3cd04 -r 3493bcbc4de5 net/libfilezilla/patches/patch-tests_string.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfilezilla/patches/patch-tests_string.cpp   Thu Jul 21 17:16:17 2016 +0000
@@ -0,0 +1,54 @@
+$NetBSD: patch-tests_string.cpp,v 1.1 2016/07/21 17:16:17 wiz Exp $
+
+SVN 7667
+
+--- tests/string.cpp.orig      2016-01-31 10:35:01.000000000 +0000
++++ tests/string.cpp
+@@ -11,6 +11,7 @@ class string_test : public CppUnit::Test
+       CPPUNIT_TEST_SUITE(string_test);
+       CPPUNIT_TEST(test_conversion);
+       CPPUNIT_TEST(test_conversion2);
++      CPPUNIT_TEST(test_conversion_utf8);
+       CPPUNIT_TEST_SUITE_END();
+ 
+ public:
+@@ -19,6 +20,7 @@ public:
+ 
+       void test_conversion();
+       void test_conversion2();
++      void test_conversion_utf8();
+ };
+ 
+ CPPUNIT_TEST_SUITE_REGISTRATION(string_test);
+@@ -43,7 +45,7 @@ void string_test::test_conversion()
+ 
+ void string_test::test_conversion2()
+ {
+-      wchar_t p[] = { 'M', 'o', 't', 0xf6, 'r', 'h', 'e', 'a', 'd', 0 };
++      wchar_t const p[] = { 'M', 'o', 't', 0xf6, 'r', 'h', 'e', 'a', 'd', 0 };
+       std::wstring const w(p);
+ 
+       std::string const s = fz::to_string(w);
+@@ -54,3 +56,22 @@ void string_test::test_conversion2()
+ 
+       ASSERT_EQUAL(w, w2);
+ }
++
++void string_test::test_conversion_utf8()
++{
++      wchar_t const p[] = { 'M', 'o', 't', 0xf6, 'r', 'h', 'e', 'a', 'd', 0 };
++      unsigned char const p_utf8[] = { 'M', 'o', 't', 0xc3, 0xb6, 'r', 'h', 'e', 'a', 'd', 0 };
++
++      std::wstring const w(p);
++      std::string const u(reinterpret_cast<char const*>(p_utf8));
++
++      std::string const s = fz::to_utf8(w);
++
++      CPPUNIT_ASSERT(s.size() >= w.size());
++
++      ASSERT_EQUAL(s, u);
++
++      std::wstring const w2 = fz::to_wstring_from_utf8(s);
++
++      ASSERT_EQUAL(w, w2);
++}



Home | Main Index | Thread Index | Old Index