diff options
author | Michal Čihař <michal@cihar.com> | 2017-11-17 15:58:24 +0100 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2017-11-17 15:58:24 +0100 |
commit | 4a253fdaf5a464f8f8609ea13c645bd264ebebf2 (patch) | |
tree | 8e6ec7ef388c227571749d1fc3e2aa244a5a1747 | |
parent | 5662746319626c59f3ca0c631e29c46fd0336b81 (diff) |
Add patch to fix FTBFS on big endian machines (Closes: #881221).debian/0.5.2-2
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | debian/patches/0f83f0aa0b8340f2d59bb3a4e174585780a2c54b.patch | 60 | ||||
-rw-r--r-- | debian/patches/series | 1 |
3 files changed, 67 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 9f94718..41e729c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +sdcv (0.5.2-2) unstable; urgency=medium + + * Add patch to fix FTBFS on big endian machines (Closes: #881221). + + -- Michal Čihař <nijel@debian.org> Fri, 17 Nov 2017 15:58:22 +0100 + sdcv (0.5.2-1) unstable; urgency=medium * New upstream release. diff --git a/debian/patches/0f83f0aa0b8340f2d59bb3a4e174585780a2c54b.patch b/debian/patches/0f83f0aa0b8340f2d59bb3a4e174585780a2c54b.patch new file mode 100644 index 0000000..d9106eb --- /dev/null +++ b/debian/patches/0f83f0aa0b8340f2d59bb3a4e174585780a2c54b.patch @@ -0,0 +1,60 @@ +From 0f83f0aa0b8340f2d59bb3a4e174585780a2c54b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= <michal@cihar.com> +Date: Tue, 14 Nov 2017 09:02:03 +0100 +Subject: [PATCH] Store integer magic in cache file +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This allows to detect different endianity of machines to avoid +loading caches created with different endianity. + +Fixes #36 + +Signed-off-by: Michal Čihař <michal@cihar.com> +--- + src/stardict_lib.cpp | 12 ++++++++++-- + tests/rus-eng-stardict-2.4.2/1.xdxf.idx.oft | Bin 38 -> 42 bytes + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp +index 63e23f5..a911ddd 100644 +--- a/src/stardict_lib.cpp ++++ b/src/stardict_lib.cpp +@@ -491,7 +491,8 @@ class OffsetIndex : public IIndexFile + static std::list<std::string> get_cache_variant(const std::string &url); + }; + +-const char *OffsetIndex::CACHE_MAGIC = "StarDict's Cache, Version: 0.1"; ++const char *OffsetIndex::CACHE_MAGIC = "StarDict's Cache, Version: 0.2"; ++#define CACHE_MAGIC_BYTES 0x51a4d1c1 + + class WordListIndex : public IIndexFile + { +@@ -573,7 +574,11 @@ bool OffsetIndex::load_cache(const std::string &url) + continue; + if (strncmp(mf.begin(), CACHE_MAGIC, strlen(CACHE_MAGIC)) != 0) + continue; +- memcpy(&wordoffset[0], mf.begin() + strlen(CACHE_MAGIC), wordoffset.size() * sizeof(wordoffset[0])); ++ guint32 tmp; ++ memcpy(&tmp, mf.begin() + strlen(CACHE_MAGIC), sizeof(tmp)); ++ if (tmp != CACHE_MAGIC_BYTES) ++ continue; ++ memcpy(&wordoffset[0], mf.begin() + strlen(CACHE_MAGIC) + sizeof(guint32), wordoffset.size() * sizeof(wordoffset[0])); + return true; + } + +@@ -605,10 +610,13 @@ bool OffsetIndex::save_cache(const std::string &url, bool verbose) + const std::list<std::string> vars = get_cache_variant(url); + for (const std::string &item : vars) { + FILE *out = fopen(item.c_str(), "wb"); ++ guint32 magic = CACHE_MAGIC_BYTES; + if (!out) + continue; + if (fwrite(CACHE_MAGIC, 1, strlen(CACHE_MAGIC), out) != strlen(CACHE_MAGIC)) + continue; ++ if (fwrite(&magic, 1, sizeof(magic), out) != sizeof(magic)) ++ continue; + if (fwrite(&wordoffset[0], sizeof(wordoffset[0]), wordoffset.size(), out) != wordoffset.size()) + continue; + fclose(out); diff --git a/debian/patches/series b/debian/patches/series index 710e72d..a94d743 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ +0f83f0aa0b8340f2d59bb3a4e174585780a2c54b.patch Fix-test-execution-on-Debian.patch |