commit:     c36d5f202a01df81b6ab1d94408ac3c6aefa907f
Author:     Sebastian Pipping <sping <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  8 16:50:25 2016 +0000
Commit:     Sebastian Pipping <sping <AT> gentoo <DOT> org>
CommitDate: Mon Aug  8 16:52:44 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c36d5f20

app-text/clara: Fix segfault start-up

Extracted from
http://archive.debian.org/debian/pool/main/c/clara/clara_20031214-4.diff.gz

Package-Manager: portage-2.2.28

 app-text/clara/clara-20031214-r1.ebuild            | 55 +++++++++++++
 .../clara/files/clara-20031214-debian-vararg.patch | 90 ++++++++++++++++++++++
 2 files changed, 145 insertions(+)

diff --git a/app-text/clara/clara-20031214-r1.ebuild 
b/app-text/clara/clara-20031214-r1.ebuild
new file mode 100644
index 0000000..2b564d9
--- /dev/null
+++ b/app-text/clara/clara-20031214-r1.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit eutils toolchain-funcs
+
+DESCRIPTION="An OCR (Optical Character Recognition) program"
+SRC_URI="mirror://gentoo/${P}.tar.gz"
+HOMEPAGE="http://www.claraocr.org/";
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="~amd64 ~ppc ~x86 ~ppc-macos ~sparc-solaris"
+IUSE=""
+
+RDEPEND="x11-libs/libX11"
+DEPEND="${RDEPEND}"
+
+# The test provided by clara doesn't seem to make any sense.  It just
+# calls the binary with an unsupported option, which results in an
+# error.
+RESTRICT="test"
+
+src_prepare() {
+       sed -i -re "s/(C|LD)FLAGS =/\1FLAGS +=/" Makefile
+       epatch "${FILESDIR}/${PN}_open_mode.patch"
+       epatch "${FILESDIR}/${P}-debian-vararg.patch"
+}
+
+src_compile() {
+       emake CC="$(tc-getCC)" || die
+       emake doc || die
+}
+
+src_install() {
+       dobin ${PN} selthresh
+       doman doc/${PN}*.1 selthresh.1
+
+       dodoc ANNOUNCE CHANGELOG doc/FAQ
+       insinto /usr/share/doc/${P}
+       doins imre.pbm
+
+       dohtml doc/*.html
+}
+
+pkg_postinst() {
+       elog
+       elog "Please note that Clara OCR has to be trained to recognize text,"
+       elog "without a training session it simply won't work. Have a look at"
+       elog "the docs in /usr/share/doc/${P}/html/ to get more "
+       elog "info about the training procedure."
+       elog
+}

diff --git a/app-text/clara/files/clara-20031214-debian-vararg.patch 
b/app-text/clara/files/clara-20031214-debian-vararg.patch
new file mode 100644
index 0000000..570bc40
--- /dev/null
+++ b/app-text/clara/files/clara-20031214-debian-vararg.patch
@@ -0,0 +1,90 @@
+--- clara-20031214.orig/clara.c
++++ clara-20031214/clara.c
+@@ -751,11 +751,12 @@
+     s[128] = 0;
+     logmsg(s);
+ 
+-    if (!trace)
+-        return;
+-    va_start(args,m);
+-    vfprintf(stderr,m,args);
+-    fprintf(stderr,"\n");
++    if (trace) {
++        vfprintf(stderr,m,args);
++        fprintf(stderr,"\n");
++    }
++
++    va_end(args);
+ }
+ 
+ /*
+@@ -775,10 +776,12 @@
+     logmsg(s);
+ 
+     /* send to stderr if requested */
+-    if (!debug)
+-        return;
+-    vfprintf(stderr,m,args);
+-    fprintf(stderr,"\n");
++    if (debug) {
++        vfprintf(stderr,m,args);
++        fprintf(stderr,"\n");
++    }
++
++    va_end(args);
+ }
+ 
+ /*
+@@ -797,9 +800,10 @@
+     s[128] = 0;
+     logmsg(s);
+ 
+-    va_start(args,m);
+     vfprintf(stderr,m,args);
+     fprintf(stderr,"\n");
++
++    va_end(args);
+ }
+ 
+ /* (devel)
+--- clara-20031214.orig/event.c
++++ clara-20031214/event.c
+@@ -638,6 +638,8 @@
+         }
+     }
+ 
++    va_end(args);
++
+ /*
+     printf("request (priority %d, mclip=%d, redraw=%d) to draw the message 
\"%s\"\n",f,mclip,redraw_stline,s);
+ */
+--- clara-20031214.orig/html.c
++++ clara-20031214/html.c
+@@ -1548,11 +1548,12 @@
+     va_list args;
+     int n=0,f;
+ 
+-    va_start(args, fmt);
+     for (f=0; f==0; ) {
+ 
+         /* try to write */
++        va_start(args, fmt);
+         n = vsnprintf(*t+*top+1,*sz-*top-1,fmt,args);
++        va_end(args);
+ 
+         /*
+             Some implementations of vsnprintf return -1 when
+@@ -1589,11 +1590,12 @@
+     va_list args;
+     int n=0,f;
+ 
+-    va_start(args, fmt);
+     for (f=0; f==0; ) {
+ 
+         /* try to write */
++        va_start(args, fmt);
+         n = vsnprintf(text+topt+1,textsz-topt-1,fmt,args);
++        va_end(args);
+ 
+         /*
+             Some implementations of vsnprintf return -1 when

Reply via email to