Skip to content

Commit

Permalink
Fixing stardict broken by my mistake.
Browse files Browse the repository at this point in the history
git-svn-id: https://nixos.org/repos/nix/nixpkgs/trunk@34549 70bd8c7a-acb8-0310-9f0d-9cc1c95dcdbb
  • Loading branch information
vcunat committed Jun 18, 2012
1 parent 9dbf471 commit 2ce0f4d
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 0 deletions.
@@ -0,0 +1,19 @@
This patch is from OpenSUSE .src.rpm for the following crash on startup:

ERROR:compositelookup.cpp:53:void CompositeLookup::send_net_dict_request(const string&, const string&): assertion failed: (NetDictRequests.end() == std::find(NetDictRequests.begin(), NetDictRequests.end(), request))

--- dict/src/lib/compositelookup.cpp
+++ dict/src/lib/compositelookup.cpp
@@ -50,8 +50,10 @@
void CompositeLookup::send_net_dict_request(const std::string& dict_id, const std::string& key)
{
NetDictRequest request(dict_id, key);
- g_assert(NetDictRequests.end() == std::find(NetDictRequests.begin(), NetDictRequests.end(), request));
- NetDictRequests.push_back(request);
+ if(NetDictRequests.end() == std::find(NetDictRequests.begin(), NetDictRequests.end(), request))
+ {
+ NetDictRequests.push_back(request);
+ }
}

/* returns true if got expected response */
@@ -0,0 +1,13 @@
http://bugs.gentoo.org/396219

--- dict/src/tomboykeybinder.h
+++ dict/src/tomboykeybinder.h
@@ -21,7 +21,7 @@
#ifndef __TOMBOY_KEY_BINDER_H__
#define __TOMBOY_KEY_BINDER_H__

-#include <glib/gtypes.h>
+#include <glib.h>

G_BEGIN_DECLS

20 changes: 20 additions & 0 deletions pkgs/applications/misc/stardict/stardict-3.0.3-entry.patch
@@ -0,0 +1,20 @@
warning: key "Encoding" in group "Desktop Entry" is deprecated
error: value "stardict.png" for key "Icon" in group "Desktop Entry" is an icon name with an extension, but there should be no extension
error: value "Dictionary" in key "Categories" in group "Desktop Entry" requires another category to be present among the following categories: Office;TextTools

--- dict/data/stardict.desktop.in
+++ dict/data/stardict.desktop.in
@@ -1,11 +1,10 @@
[Desktop Entry]
-Encoding=UTF-8
_Name=StarDict
_Comment=Lookup words
Exec=stardict
Terminal=false
Type=Application
-Icon=stardict.png
+Icon=stardict
StartupNotify=true
-Categories=Utility;Dictionary;
+Categories=Utility;Office;TextTools;Dictionary;
X-GNOME-DocPath=stardict/stardict.xml
13 changes: 13 additions & 0 deletions pkgs/applications/misc/stardict/stardict-3.0.3-gcc46.patch
@@ -0,0 +1,13 @@
http://bugs.gentoo.org/362299

--- dict/stardict-plugins/stardict-wordnet-plugin/scene.h
+++ dict/stardict-plugins/stardict-wordnet-plugin/scene.h
@@ -25,6 +25,8 @@
#ifndef __PHYSICS_H__
#define __PHYSICS_H__

+#include <cstddef>
+
#include "partic.h"
#include "spring.h"

26 changes: 26 additions & 0 deletions pkgs/applications/misc/stardict/stardict-3.0.3-overflow.patch
@@ -0,0 +1,26 @@
This patch is stardict-tools-3.0.3-destbufferoverflow.patch from OpenSUSE .src.rpm for:

warning: call to ‘__fgets_chk_warn’ declared with attribute warning: fgets called with bigger size than length of destination buffer [enabled by default]

--- tools/src/myspell2dic.c
+++ tools/src/myspell2dic.c
@@ -132,7 +132,7 @@ if (argc<3)

fprintf(stderr, "Enter grammar language [Spanish]: ");
fflush(stderr);
-fgets(lang, 100, stdin);
+fgets(lang, 50, stdin);
if ((p=strchr(lang, '\n'))!=NULL) *p=0;
if (*lang==0) strcpy(lang, "Spanish");

--- tools/src/ooo2dict.c
+++ tools/src/ooo2dict.c
@@ -71,7 +71,7 @@ current2=malloc(10000);

fprintf(stderr, "Enter thesaurus language [WordNet_English]: ");
fflush(stderr);
-fgets(lang, 100, stdin);
+fgets(lang, 50, stdin);
if ((p=strchr(lang, '\n'))!=NULL) *p=0;
if (*lang==0) strcpy(lang, "WordNet_English");
F=fopen((argc>1)? argv[1]: "/usr/share/myspell/dicts/th_en_US_v2.dat", "rt");
39 changes: 39 additions & 0 deletions pkgs/applications/misc/stardict/stardict-3.0.3-zlib-1.2.5.2.patch
@@ -0,0 +1,39 @@
http://bugs.gentoo.org/401887

diff --git a/lib/src/libcommon.cpp b/lib/src/libcommon.cpp
index 16770a3..a4299e7 100644
--- a/lib/src/libcommon.cpp
+++ b/lib/src/libcommon.cpp
@@ -614,7 +614,7 @@ int unpack_zlib(const char* arch_file_name, const char* out_file_name)
return EXIT_FAILURE;
}
while(true) {
- len = gzread(get_impl(in), buf, buffer_size);
+ len = gzread((gzFile)get_impl(in), buf, buffer_size);
if(len < 0) {
g_critical(read_file_err, arch_file_name, "");
return EXIT_FAILURE;
@@ -871,3 +871,8 @@ int remove_recursive(const std::string& path)
return res;
}
}
+
+int gzclose_compat(void * file)
+{
+ return gzclose ((gzFile)file);
+}
diff --git a/lib/src/libcommon.h b/lib/src/libcommon.h
index 10f13b4..bdcbf2f 100644
--- a/lib/src/libcommon.h
+++ b/lib/src/libcommon.h
@@ -187,8 +187,9 @@ namespace clib {
typedef ResourceWrapper<FILE, FILE*, int, fclose> File;
}

+extern int gzclose_compat(void * file);
namespace zip {
-typedef ResourceWrapper<void, void*, int, gzclose> gzFile;
+typedef ResourceWrapper<void, void*, int, gzclose_compat> gzFile;
}

/* Create a new temporary file. Return file name in file name encoding.
46 changes: 46 additions & 0 deletions pkgs/applications/misc/stardict/stardict.nix
@@ -0,0 +1,46 @@
{stdenv, fetchurl, pkgconfig, gtk, glib, zlib, libxml2, intltool, gnome_doc_utils, libgnomeui, scrollkeeper, mysql, pcre, which, libxslt}:
stdenv.mkDerivation rec {
name= "stardict-3.0.3";

src = fetchurl {
url = "http://stardict-3.googlecode.com/files/${name}.tar.bz2";
sha256 = "0wrb8xqy6x9piwrn0vw5alivr9h3b70xlf51qy0jpl6d7mdhm8cv";
};

buildInputs = [ pkgconfig gtk glib zlib libxml2 intltool gnome_doc_utils libgnomeui scrollkeeper mysql pcre which libxslt];

postPatch = ''
# mysql hacks: we need dynamic linking as there is no libmysqlclient.a
substituteInPlace tools/configure --replace '/usr/local/include/mysql' '${mysql}/include/mysql/'
substituteInPlace tools/configure --replace 'AC_FIND_FILE([libmysqlclient.a]' 'AC_FIND_FILE([libmysqlclient.so]'
substituteInPlace tools/configure --replace '/usr/local/lib/mysql' '${mysql}/lib/mysql/'
substituteInPlace tools/configure --replace 'for y in libmysqlclient.a' 'for y in libmysqlclient.so'
substituteInPlace tools/configure --replace 'libmysqlclient.a' 'libmysqlclient.so'
# a list of p0 patches from gentoo devs
patch -p0 < ${./stardict-3.0.3-overflow.patch}
patch -p0 < ${./stardict-3.0.3-gcc46.patch}
patch -p0 < ${./stardict-3.0.3-compositelookup_cpp.patch}
patch -p0 < ${./stardict-3.0.3-correct-glib-include.patch}
patch -p0 < ${./stardict-3.0.3-entry.patch}
# disable the xsltproc internet query
substituteInPlace dict/help/Makefile.am --replace 'xsltproc -o' 'xsltproc --nonet -o'
substituteInPlace dict/help/Makefile.in --replace 'xsltproc -o' 'xsltproc --nonet -o'
'';

# another gentoo patch: a p1 patch
patches = [ ./stardict-3.0.3-zlib-1.2.5.2.patch ];

configurePhase = ''
./configure --disable-spell --disable-gucharmap --disable-festival --disable-espeak --disable-scrollkeeper --prefix=$out
'';

meta = {
description = "stardict";
homepage = "A international dictionary supporting fuzzy and glob style matching";
license = "LGPL3";
maintainers = with stdenv.lib.maintainers; [qknight];
};
}

0 comments on commit 2ce0f4d

Please sign in to comment.