From 40aaaa64e86ba6710bbeb31c4615a6ce80e75e11 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 28 Apr 2021 20:21:43 +0100 Subject: gentoo resync : 28.04.2021 --- app-text/sdcv/files/sdcv-0.5.3-t_list.patch | 19 ++++ app-text/sdcv/files/sdcv-synonyms-bin-search.patch | 112 +++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 app-text/sdcv/files/sdcv-0.5.3-t_list.patch create mode 100644 app-text/sdcv/files/sdcv-synonyms-bin-search.patch (limited to 'app-text/sdcv/files') 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 new file mode 100644 index 000000000000..c26a93522bd1 --- /dev/null +++ b/app-text/sdcv/files/sdcv-0.5.3-t_list.patch @@ -0,0 +1,19 @@ +diff --git a/tests/t_list b/tests/t_list +index a8c92c4..c410cf2 100755 +--- a/tests/t_list ++++ b/tests/t_list +@@ -1,11 +1,10 @@ + #!/bin/sh + + PATH_TO_SDCV="$1" +-ndicts=`"$PATH_TO_SDCV" -l | wc -l` ++TEST_DIR="$2" ++ndicts=`"$PATH_TO_SDCV" --data-dir "${TEST_DIR}" -l | wc -l` + ndicts=$(($ndicts-1)) +-ncom=`find /usr/share/stardict/dic -name "*.ifo" | wc -l` +-nspe=`find "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic -name "*.ifo" | wc -l` +-nmy=$(($ncom+$nspe)) ++nmy=`find "${TEST_DIR}" -name "*.ifo" | wc -l` + + if [ $nmy -ne $ndicts ]; then + echo "should be: $nmy, we have: $ndicts" >&2 diff --git a/app-text/sdcv/files/sdcv-synonyms-bin-search.patch b/app-text/sdcv/files/sdcv-synonyms-bin-search.patch new file mode 100644 index 000000000000..e3583b1a5fb6 --- /dev/null +++ b/app-text/sdcv/files/sdcv-synonyms-bin-search.patch @@ -0,0 +1,112 @@ +ommit 4ae420734990ab9f5ccc038262368256b9323f4a +Merge: b66799f 994c1c7 +Author: Evgeniy Dushistov +Date: Wed Dec 23 04:30:13 2020 +0300 + + Merge pull request #67 from doozan/master + + Use binary search for synonyms, fixes #31 + +diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp +index 0af4304..6b1f92b 100644 +--- a/src/stardict_lib.cpp ++++ b/src/stardict_lib.cpp +@@ -833,21 +833,23 @@ bool SynFile::load(const std::string &url, gulong wc) + { + struct stat stat_buf; + if (!stat(url.c_str(), &stat_buf)) { +- MapFile syn; +- if (!syn.open(url.c_str(), stat_buf.st_size)) ++ ++ if (!synfile.open(url.c_str(), stat_buf.st_size)) + return false; +- const gchar *current = syn.begin(); ++ ++ synlist.resize(wc + 1); ++ gchar *p1 = synfile.begin(); ++ + for (unsigned long i = 0; i < wc; i++) { + // each entry in a syn-file is: + // - 0-terminated string + // 4-byte index into .dict file in network byte order +- glib::CharStr lower_string{ g_utf8_casefold(current, -1) }; +- std::string synonym{ get_impl(lower_string) }; +- current += synonym.length() + 1; +- const guint32 idx = g_ntohl(get_uint32(current)); +- current += sizeof(idx); +- synonyms[synonym] = idx; ++ ++ synlist[i] = p1; ++ p1 += strlen(p1) + 1 + 4; + } ++ synlist[wc] = p1; ++ + return true; + } else { + return false; +@@ -856,13 +858,38 @@ bool SynFile::load(const std::string &url, gulong wc) + + bool SynFile::lookup(const char *str, glong &idx) + { +- glib::CharStr lower_string{ g_utf8_casefold(str, -1) }; +- auto it = synonyms.find(get_impl(lower_string)); +- if (it != synonyms.end()) { +- idx = it->second; +- return true; ++ bool bFound = false; ++ glong iTo = synlist.size() - 2; ++ if (iTo <0) return false; ++ ++ if (stardict_strcmp(str, get_key(0)) < 0) { ++ idx = 0; ++ } else if (stardict_strcmp(str, get_key(iTo)) > 0) { ++ idx = INVALID_INDEX; ++ } else { ++ glong iThisIndex = 0; ++ glong iFrom = 0; ++ gint cmpint; ++ while (iFrom <= iTo) { ++ iThisIndex = (iFrom + iTo) / 2; ++ cmpint = stardict_strcmp(str, get_key(iThisIndex)); ++ if (cmpint > 0) ++ iFrom = iThisIndex + 1; ++ else if (cmpint < 0) ++ iTo = iThisIndex - 1; ++ else { ++ bFound = true; ++ break; ++ } ++ } ++ if (!bFound) ++ idx = iFrom; //next ++ else { ++ const gchar *key = get_key(iThisIndex); ++ idx = g_ntohl(get_uint32(key+strlen(key)+1)); ++ } + } +- return false; ++ return bFound; + } + + bool Dict::Lookup(const char *str, glong &idx) +diff --git a/src/stardict_lib.hpp b/src/stardict_lib.hpp +index a629cbe..38f76f4 100644 +--- a/src/stardict_lib.hpp ++++ b/src/stardict_lib.hpp +@@ -102,11 +102,15 @@ public: + class SynFile + { + public: ++ SynFile() {} ++ ~SynFile() {} + bool load(const std::string &url, gulong wc); + bool lookup(const char *str, glong &idx); ++ const gchar *get_key(glong idx) { return synlist[idx]; } + + private: +- std::map synonyms; ++ MapFile synfile; ++ std::vector synlist; + }; + + class Dict : public DictBase -- cgit v1.2.3