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
This commit is contained in:
Sebastian Pipping
2016-08-08 18:50:25 +02:00
parent b5995474bf
commit c36d5f202a
2 changed files with 145 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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