summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorwiz <wiz>2016-07-21 17:16:17 +0000
committerwiz <wiz>2016-07-21 17:16:17 +0000
commit4381eb755c4c9d295d49d78edf0b12091dfb1643 (patch)
treebad0b1d6845741475cf82521e05f15f4345a0799 /net
parent9b2d67e27e7b811f231d50e4dbc4bed1220abe2a (diff)
downloadpkgsrc-4381eb755c4c9d295d49d78edf0b12091dfb1643.tar.gz
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 (limited to 'net')
-rw-r--r--net/libfilezilla/Makefile3
-rw-r--r--net/libfilezilla/distinfo4
-rw-r--r--net/libfilezilla/patches/patch-lib_string.cpp84
-rw-r--r--net/libfilezilla/patches/patch-tests_string.cpp54
4 files changed, 143 insertions, 2 deletions
diff --git a/net/libfilezilla/Makefile b/net/libfilezilla/Makefile
index 479f98f4907..c55a771a2a1 100644
--- a/net/libfilezilla/Makefile
+++ b/net/libfilezilla/Makefile
@@ -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 --git a/net/libfilezilla/distinfo b/net/libfilezilla/distinfo
index a9f8011b934..d96073b72be 100644
--- a/net/libfilezilla/distinfo
+++ b/net/libfilezilla/distinfo
@@ -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 --git a/net/libfilezilla/patches/patch-lib_string.cpp b/net/libfilezilla/patches/patch-lib_string.cpp
new file mode 100644
index 00000000000..65b1c6fcd4f
--- /dev/null
+++ b/net/libfilezilla/patches/patch-lib_string.cpp
@@ -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 --git a/net/libfilezilla/patches/patch-tests_string.cpp b/net/libfilezilla/patches/patch-tests_string.cpp
new file mode 100644
index 00000000000..2d6e337d211
--- /dev/null
+++ b/net/libfilezilla/patches/patch-tests_string.cpp
@@ -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);
++}