From 0353d2ab83670f5329c2785ad3c43c4df48ad4c2 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 8 Apr 2020 16:31:48 -0400 Subject: [PATCH] dev-libs/libfmt: Fix handling of unsigned char strings in printf See: https://github.com/fmtlib/fmt/issues/1620 Package-Manager: Portage-2.3.97, Repoman-2.3.22 Signed-off-by: Craig Andrews --- ....2.0-unsigned-char-strings-in-printf.patch | 46 +++++++++++++++++++ dev-libs/libfmt/libfmt-6.2.0-r1.ebuild | 40 ++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 dev-libs/libfmt/files/libfmt-6.2.0-unsigned-char-strings-in-printf.patch create mode 100644 dev-libs/libfmt/libfmt-6.2.0-r1.ebuild diff --git a/dev-libs/libfmt/files/libfmt-6.2.0-unsigned-char-strings-in-printf.patch b/dev-libs/libfmt/files/libfmt-6.2.0-unsigned-char-strings-in-printf.patch new file mode 100644 index 000000000000..2ce27c83e622 --- /dev/null +++ b/dev-libs/libfmt/files/libfmt-6.2.0-unsigned-char-strings-in-printf.patch @@ -0,0 +1,46 @@ +From 7d01859ef16e6b65bc023ad8bebfedecb088bf81 Mon Sep 17 00:00:00 2001 +From: Victor Zverovich +Date: Wed, 8 Apr 2020 12:32:34 -0700 +Subject: [PATCH] Fix handling of unsigned char strings in printf + +--- + include/fmt/core.h | 8 ++++++++ + test/printf-test.cc | 6 ++++++ + 2 files changed, 14 insertions(+) + +diff --git a/include/fmt/core.h b/include/fmt/core.h +index 6df2875ac..dc10722bf 100644 +--- a/include/fmt/core.h ++++ b/include/fmt/core.h +@@ -972,6 +972,14 @@ template struct arg_mapper { + static_assert(std::is_same::value, "invalid string type"); + return reinterpret_cast(val); + } ++ FMT_CONSTEXPR const char* map(signed char* val) { ++ const auto* const_val = val; ++ return map(const_val); ++ } ++ FMT_CONSTEXPR const char* map(unsigned char* val) { ++ const auto* const_val = val; ++ return map(const_val); ++ } + + FMT_CONSTEXPR const void* map(void* val) { return val; } + FMT_CONSTEXPR const void* map(const void* val) { return val; } +diff --git a/test/printf-test.cc b/test/printf-test.cc +index 5aaa27b13..545e02aab 100644 +--- a/test/printf-test.cc ++++ b/test/printf-test.cc +@@ -447,6 +447,12 @@ TEST(PrintfTest, String) { + EXPECT_PRINTF(L" (null)", L"%10s", null_wstr); + } + ++TEST(PrintfTest, UCharString) { ++ unsigned char str[] = "test"; ++ unsigned char* pstr = str; ++ EXPECT_EQ("test", fmt::sprintf("%s", pstr)); ++} ++ + TEST(PrintfTest, Pointer) { + int n; + void* p = &n; diff --git a/dev-libs/libfmt/libfmt-6.2.0-r1.ebuild b/dev-libs/libfmt/libfmt-6.2.0-r1.ebuild new file mode 100644 index 000000000000..f5dcf196261c --- /dev/null +++ b/dev-libs/libfmt/libfmt-6.2.0-r1.ebuild @@ -0,0 +1,40 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +CMAKE_ECLASS=cmake +inherit cmake-multilib + +DESCRIPTION="Small, safe and fast formatting library" +HOMEPAGE="https://github.com/fmtlib/fmt" + +LICENSE="MIT" +IUSE="test" +SLOT="0/$(ver_cut 1)" + +if [[ ${PV} == *9999 ]] ; then + EGIT_REPO_URI="https://github.com/fmtlib/fmt.git" + inherit git-r3 +else + SRC_URI="https://github.com/fmtlib/fmt/archive/${PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~amd64 ~ppc ~ppc64 ~x86" + S="${WORKDIR}/fmt-${PV}" +fi + +DEPEND="" +RDEPEND="" +RESTRICT="!test? ( test )" + +PATCHES=( + "${FILESDIR}/${P}-unsigned-char-strings-in-printf.patch" +) + +multilib_src_configure() { + local mycmakeargs=( + -DFMT_CMAKE_DIR="$(get_libdir)/cmake/fmt" + -DFMT_LIB_DIR="$(get_libdir)" + -DFMT_TEST=$(usex test) + ) + cmake_src_configure +} -- 2.26.2