Gentoo Archives: gentoo-commits

From: Andrew Savchenko <bircoph@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-text/sdcv/files/, app-text/sdcv/
Date: Sat, 03 Apr 2021 19:19:03
Message-Id: 1617477523.beb002c292228709cf437afc2c31f2b1af1be71b.bircoph@gentoo
1 commit: beb002c292228709cf437afc2c31f2b1af1be71b
2 Author: Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 3 19:14:53 2021 +0000
4 Commit: Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 3 19:18:43 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=beb002c2
7
8 app-text/sdcv: version bump
9
10 - Update to 0.5.3
11 - Bump to EAPI 7
12 - Migrate to cmake.eclass
13 - Pick up upstream patchset for binsearch speedup
14
15 Closes: https://bugs.gentoo.org/774510
16 Package-Manager: Portage-3.0.18, Repoman-3.0.3
17 Signed-off-by: Andrew Savchenko <bircoph <AT> gentoo.org>
18
19 app-text/sdcv/Manifest | 1 +
20 app-text/sdcv/files/sdcv-0.5.3-t_list.patch | 19 ++++
21 app-text/sdcv/files/sdcv-synonyms-bin-search.patch | 112 +++++++++++++++++++++
22 app-text/sdcv/sdcv-0.5.3.ebuild | 74 ++++++++++++++
23 4 files changed, 206 insertions(+)
24
25 diff --git a/app-text/sdcv/Manifest b/app-text/sdcv/Manifest
26 index c30f650ef31..3800567f539 100644
27 --- a/app-text/sdcv/Manifest
28 +++ b/app-text/sdcv/Manifest
29 @@ -1 +1,2 @@
30 DIST sdcv-0.5.2.tar.gz 61541 BLAKE2B 3b86b69c1e781c311ebbd427d09f8e1c8f97a9fc7b72e22f812ec4619fb4f3cd673ea5548cfdd89554e1613877d20676b8830fd5921082d7a13facb761001c00 SHA512 8752a225aebcc28cd8911591333410a0da94db9a7718cee744f8fbc6ceeae14bbf13c6d5a02a05652ff032276765537573e216acd49980f80c06319dac7075fb
31 +DIST sdcv-0.5.3.tar.gz 62105 BLAKE2B 1424510cff2fa355d17884a31f8136f4c8a7bde071f387dd8a69b1d2d6b9c8e52869cd602b27b9966725370cf128fb62b8628e735f1faa92b78f75215462804f SHA512 73a305baad74d0584912e115d3de7395c8e88745fb69b4e5f1a345061629b0d4e05898bd589e96ce07948d52ba7c508ec4ab77862c8fadca5a2f19c5244e1442
32
33 diff --git a/app-text/sdcv/files/sdcv-0.5.3-t_list.patch b/app-text/sdcv/files/sdcv-0.5.3-t_list.patch
34 new file mode 100644
35 index 00000000000..c26a93522bd
36 --- /dev/null
37 +++ b/app-text/sdcv/files/sdcv-0.5.3-t_list.patch
38 @@ -0,0 +1,19 @@
39 +diff --git a/tests/t_list b/tests/t_list
40 +index a8c92c4..c410cf2 100755
41 +--- a/tests/t_list
42 ++++ b/tests/t_list
43 +@@ -1,11 +1,10 @@
44 + #!/bin/sh
45 +
46 + PATH_TO_SDCV="$1"
47 +-ndicts=`"$PATH_TO_SDCV" -l | wc -l`
48 ++TEST_DIR="$2"
49 ++ndicts=`"$PATH_TO_SDCV" --data-dir "${TEST_DIR}" -l | wc -l`
50 + ndicts=$(($ndicts-1))
51 +-ncom=`find /usr/share/stardict/dic -name "*.ifo" | wc -l`
52 +-nspe=`find "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic -name "*.ifo" | wc -l`
53 +-nmy=$(($ncom+$nspe))
54 ++nmy=`find "${TEST_DIR}" -name "*.ifo" | wc -l`
55 +
56 + if [ $nmy -ne $ndicts ]; then
57 + echo "should be: $nmy, we have: $ndicts" >&2
58
59 diff --git a/app-text/sdcv/files/sdcv-synonyms-bin-search.patch b/app-text/sdcv/files/sdcv-synonyms-bin-search.patch
60 new file mode 100644
61 index 00000000000..e3583b1a5fb
62 --- /dev/null
63 +++ b/app-text/sdcv/files/sdcv-synonyms-bin-search.patch
64 @@ -0,0 +1,112 @@
65 +ommit 4ae420734990ab9f5ccc038262368256b9323f4a
66 +Merge: b66799f 994c1c7
67 +Author: Evgeniy Dushistov <dushistov@××××.ru>
68 +Date: Wed Dec 23 04:30:13 2020 +0300
69 +
70 + Merge pull request #67 from doozan/master
71 +
72 + Use binary search for synonyms, fixes #31
73 +
74 +diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp
75 +index 0af4304..6b1f92b 100644
76 +--- a/src/stardict_lib.cpp
77 ++++ b/src/stardict_lib.cpp
78 +@@ -833,21 +833,23 @@ bool SynFile::load(const std::string &url, gulong wc)
79 + {
80 + struct stat stat_buf;
81 + if (!stat(url.c_str(), &stat_buf)) {
82 +- MapFile syn;
83 +- if (!syn.open(url.c_str(), stat_buf.st_size))
84 ++
85 ++ if (!synfile.open(url.c_str(), stat_buf.st_size))
86 + return false;
87 +- const gchar *current = syn.begin();
88 ++
89 ++ synlist.resize(wc + 1);
90 ++ gchar *p1 = synfile.begin();
91 ++
92 + for (unsigned long i = 0; i < wc; i++) {
93 + // each entry in a syn-file is:
94 + // - 0-terminated string
95 + // 4-byte index into .dict file in network byte order
96 +- glib::CharStr lower_string{ g_utf8_casefold(current, -1) };
97 +- std::string synonym{ get_impl(lower_string) };
98 +- current += synonym.length() + 1;
99 +- const guint32 idx = g_ntohl(get_uint32(current));
100 +- current += sizeof(idx);
101 +- synonyms[synonym] = idx;
102 ++
103 ++ synlist[i] = p1;
104 ++ p1 += strlen(p1) + 1 + 4;
105 + }
106 ++ synlist[wc] = p1;
107 ++
108 + return true;
109 + } else {
110 + return false;
111 +@@ -856,13 +858,38 @@ bool SynFile::load(const std::string &url, gulong wc)
112 +
113 + bool SynFile::lookup(const char *str, glong &idx)
114 + {
115 +- glib::CharStr lower_string{ g_utf8_casefold(str, -1) };
116 +- auto it = synonyms.find(get_impl(lower_string));
117 +- if (it != synonyms.end()) {
118 +- idx = it->second;
119 +- return true;
120 ++ bool bFound = false;
121 ++ glong iTo = synlist.size() - 2;
122 ++ if (iTo <0) return false;
123 ++
124 ++ if (stardict_strcmp(str, get_key(0)) < 0) {
125 ++ idx = 0;
126 ++ } else if (stardict_strcmp(str, get_key(iTo)) > 0) {
127 ++ idx = INVALID_INDEX;
128 ++ } else {
129 ++ glong iThisIndex = 0;
130 ++ glong iFrom = 0;
131 ++ gint cmpint;
132 ++ while (iFrom <= iTo) {
133 ++ iThisIndex = (iFrom + iTo) / 2;
134 ++ cmpint = stardict_strcmp(str, get_key(iThisIndex));
135 ++ if (cmpint > 0)
136 ++ iFrom = iThisIndex + 1;
137 ++ else if (cmpint < 0)
138 ++ iTo = iThisIndex - 1;
139 ++ else {
140 ++ bFound = true;
141 ++ break;
142 ++ }
143 ++ }
144 ++ if (!bFound)
145 ++ idx = iFrom; //next
146 ++ else {
147 ++ const gchar *key = get_key(iThisIndex);
148 ++ idx = g_ntohl(get_uint32(key+strlen(key)+1));
149 ++ }
150 + }
151 +- return false;
152 ++ return bFound;
153 + }
154 +
155 + bool Dict::Lookup(const char *str, glong &idx)
156 +diff --git a/src/stardict_lib.hpp b/src/stardict_lib.hpp
157 +index a629cbe..38f76f4 100644
158 +--- a/src/stardict_lib.hpp
159 ++++ b/src/stardict_lib.hpp
160 +@@ -102,11 +102,15 @@ public:
161 + class SynFile
162 + {
163 + public:
164 ++ SynFile() {}
165 ++ ~SynFile() {}
166 + bool load(const std::string &url, gulong wc);
167 + bool lookup(const char *str, glong &idx);
168 ++ const gchar *get_key(glong idx) { return synlist[idx]; }
169 +
170 + private:
171 +- std::map<std::string, gulong> synonyms;
172 ++ MapFile synfile;
173 ++ std::vector<gchar *> synlist;
174 + };
175 +
176 + class Dict : public DictBase
177
178 diff --git a/app-text/sdcv/sdcv-0.5.3.ebuild b/app-text/sdcv/sdcv-0.5.3.ebuild
179 new file mode 100644
180 index 00000000000..8b7225b3c9d
181 --- /dev/null
182 +++ b/app-text/sdcv/sdcv-0.5.3.ebuild
183 @@ -0,0 +1,74 @@
184 +# Copyright 1999-2021 Gentoo Authors
185 +# Distributed under the terms of the GNU General Public License v2
186 +
187 +EAPI=7
188 +
189 +PLOCALES="cs fr ru sk uk zh_CN zh_TW"
190 +inherit cmake l10n
191 +
192 +DESCRIPTION="Console version of Stardict program"
193 +HOMEPAGE="https://dushistov.github.io/sdcv/"
194 +SRC_URI="https://github.com/Dushistov/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
195 +
196 +LICENSE="GPL-2"
197 +SLOT="0"
198 +KEYWORDS="~amd64 ~x86"
199 +IUSE="darkterm nls readline test"
200 +RESTRICT="!test? ( test )"
201 +
202 +RDEPEND="
203 + >=dev-libs/glib-2.36
204 + sys-libs/zlib
205 + readline? ( sys-libs/readline:= )
206 +"
207 +DEPEND="${RDEPEND}"
208 +BDEPEND="
209 + nls? ( >=sys-devel/gettext-0.14.1 )
210 + test? ( app-misc/jq )
211 +"
212 +
213 +PATCHES=(
214 + "${FILESDIR}/${PN}-0.5.3-t_list.patch"
215 + "${FILESDIR}/${PN}-t_interactive.patch"
216 + "${FILESDIR}/${PN}-synonyms-bin-search.patch"
217 +)
218 +
219 +src_prepare() {
220 + if use darkterm; then
221 + sed -i 's/;34m/;36m/' src/libwrapper.cpp || die
222 + fi
223 +
224 + rm_loc() {
225 + rm "po/${1}.po" || die
226 + }
227 + l10n_for_each_disabled_locale_do rm_loc
228 +
229 + # do not install locale-specific man pages unless asked to
230 + if ! has uk ${LINGUAS-uk}; then
231 + sed -ni '/share\/man\/uk/!p' CMakeLists.txt || die
232 + fi
233 +
234 + cmake_src_prepare
235 +}
236 +
237 +src_configure() {
238 + local mycmakeargs=(
239 + -DENABLE_NLS="$(usex nls)"
240 + -DWITH_READLINE="$(usex readline)"
241 + -DBUILD_TESTS="$(usex test ON OFF)"
242 + )
243 + cmake_src_configure
244 +}
245 +
246 +src_compile() {
247 + cmake_src_compile
248 + use nls && cmake_src_compile lang
249 +}
250 +
251 +src_install() {
252 + # with USE=nls, but empty intersection of LINGUAS and list of
253 + # supported translations, this directory is required, see bug 583386
254 + mkdir -p "${BUILD_DIR}/locale"
255 + cmake_src_install
256 + dodoc doc/DICTFILE_FORMAT
257 +}