1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-22 00:35:15 +00:00

- Update to 1.9.

PR:		ports/125611
Submitted by:	bf <bf2006a@yahoo.com>
Approved by:	maintainer timeout (> 2 weeks)
This commit is contained in:
Felippe de Meirelles Motta 2008-09-02 19:06:45 +00:00
parent daeb996df4
commit 71c95c84ef
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=219687
6 changed files with 167 additions and 53 deletions

View File

@ -6,12 +6,9 @@
#
PORTNAME= pstotext
PORTVERSION= 1.8g
PORTREVISION= 1
PORTVERSION= 1.9
CATEGORIES= print
MASTER_SITES= http://www.breuninger.org/files/distfiles/
DISTNAME= ${PORTNAME}
EXTRACT_SUFX= .tar.Z
MASTER_SITES= http://mirror.cs.wisc.edu/pub/mirrors/ghost/contrib/
MAINTAINER= ob@breuninger.org
COMMENT= A PostScript to Text converter
@ -20,9 +17,18 @@ USE_GHOSTSCRIPT_RUN= yes
MAN1= pstotext.1
PLIST_FILES= bin/pstotext
PORTDOCS= copyright
post-patch:
${REINPLACE_CMD} -e 's;%%LOCALBASE%%;${LOCALBASE};g' ${WRKSRC}/main.c
${REINPLACE_CMD} -e 's;%%PREFIX%%;${PREFIX};g' ${WRKSRC}/pstotext.1
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/pstotext ${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/pstotext.1 ${PREFIX}/man/man1
${INSTALL_MAN} ${WRKSRC}/pstotext.1 ${MAN1PREFIX}/man/man1
.ifndef(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/pstotext.txt ${DOCSDIR}/copyright
.endif
.include <bsd.port.mk>

View File

@ -1,3 +1,3 @@
MD5 (pstotext.tar.Z) = 1be0be028ccc85be1bf55d7e90976b18
SHA256 (pstotext.tar.Z) = 139ff4819bd067cb185c5d65d97b2ce62fb8109487a44e4b5450916179363652
SIZE (pstotext.tar.Z) = 58743
MD5 (pstotext-1.9.tar.gz) = 64576e8a10ff5514e285d98b3898ae78
SHA256 (pstotext-1.9.tar.gz) = cfe0a251d0d43982a7d3bdf1d1670c854432739d00cb593c9beaca4b2cc36c27
SIZE (pstotext-1.9.tar.gz) = 37461

View File

@ -1,29 +1,28 @@
--- Makefile.orig Wed Oct 28 08:45:58 1998
+++ Makefile Tue Feb 1 23:21:29 2000
@@ -8,7 +8,8 @@
--- Makefile.orig 2004-01-09 05:20:35.000000000 -0500
+++ Makefile 2008-07-14 12:26:19.832973217 -0400
@@ -9,7 +9,6 @@
# commenting out the includes of ptotdll.h in ptotdll.c and main.c.
# PMcJ 6 Sep 96
-CC=gcc
+CC?=gcc
+CFLAGS?=-O2
#CC=cc -std
BUNDLE = ocr.h rot270.h rot90.h
@@ -16,10 +17,10 @@
@@ -17,18 +16,18 @@
all: pstotext
main.o: ptotdll.h bundle.h ocr.h rot270.h rot90.h
main.o: main.c ptotdll.h bundle.h ocr.h rot270.h rot90.h
- $(CC) -c $*.c
+ $(CC) ${CFLAGS} -c $*.c
ptotdll.o: ptotdll.h
ptotdll.o: ptotdll.c ptotdll.h
- $(CC) -c $*.c
+ $(CC) ${CFLAGS} -c $*.c
pstotext: bundle.o main.o ptotdll.o
$(CC) -o pstotext main.o bundle.o ptotdll.o -lm
@@ -27,7 +28,7 @@
- $(CC) -o pstotext main.o bundle.o ptotdll.o -lm
+ $(CC) ${CFLAGS} -o pstotext main.o bundle.o ptotdll.o -lm
.SUFFIXES: .ps
.c.o:

View File

@ -1,21 +1,135 @@
--- main.c.orig Fri Oct 16 16:27:57 1998
+++ main.c Tue Feb 1 23:29:34 2000
@@ -90,13 +90,16 @@
static char *make_temp(b) BUNDLE b; {
/* Return pathname of temporary file containing bundle "b". Caller
should unlink file (and, technically, free pathname). */
+ int fd;
FILE *f;
--- main.c.orig 2008-07-14 11:41:51.368157158 -0400
+++ main.c 2008-07-14 12:07:36.524646879 -0400
@@ -126,12 +126,14 @@
static int cleanup(void) {
int gsstatus, status = 0;
pstotextExit(instance);
- if (gs!=NULL) {
#ifdef VMS
char *path = tempnam("SYS$SCRATCH:", ".ps2t");
+ if (gs!=NULL) {
gsstatus = fclose(gs);
+ }
#else
- char *path = tempnam("/tmp", ",ps2t");
+ char *path = strdup("/tmp/ps2tXXXXXXXXXX");
+ if ((fd = mkstemp(path)) == NULL)
+ {perror(cmd); exit(1);}
- gsstatus = pclose(gs);
+ waitpid(-1, &gsstatus, 0);
#endif
- f = fopen(path, "w");
+ f = fdopen(fd, "w");
if (f==NULL) {perror(cmd); exit(1);}
putbundle(b, f);
fclose(f);
+ if (gsstatus) {
if (WIFEXITED(gsstatus)) {
if (WEXITSTATUS(gsstatus)!=0) status = 3;
else if (WIFSIGNALED(gsstatus)) status = 4;
@@ -166,8 +168,13 @@
static int do_it(char *path) {
/* If "path" is NULL, then "stdin" should be processed. */
- char *gs_cmdline;
- char *input;
+ char *gs_argv[32];
+ int gs_argc=0;
+#ifdef DEBUG
+ int i;
+#endif
+ int fd[2];
+ pid_t p;
int status;
char norotate[] = "";
FILE *fileout;
@@ -201,47 +208,31 @@
exit(1);
}
- if (path==NULL) {
- input = (char*)malloc(2);
- if (input == NULL) {
- fprintf(stderr,"No memory available\n");
- cleanup();
- exit(1);
- }
- strcpy(input, "-");
- } else {
- input = (char*)malloc(strlen(path) + 6);
- if (input == NULL) {
- fprintf(stderr,"No memory available\n");
- cleanup();
- exit(1);
- }
- strcpy(input, "-- '"); strcat(input, path); strcat(input, "'");
+ gs_argv[gs_argc++] = "gs";
+ gs_argv[gs_argc++] = "-r72";
+ gs_argv[gs_argc++] = "-dNODISPLAY";
+ gs_argv[gs_argc++] = "-dFIXEDMEDIA";
+ gs_argv[gs_argc++] = "-dDELAYBIND";
+ gs_argv[gs_argc++] = "-dWRITESYSTEMDICT";
+ if (!debug) {
+ gs_argv[gs_argc++] = "-q";
+ }
+ gs_argv[gs_argc++] = "-dNOPAUSE";
+ gs_argv[gs_argc++] = "-dSAFER";
+ if (rotate_path && strcmp(rotate_path, "")) {
+ gs_argv[gs_argc++] = rotate_path;
+ }
+ if (ocr_path && strcmp(ocr_path, "")) {
+ gs_argv[gs_argc++] = ocr_path;
+ }
+ if (path == NULL ) {
+ gs_argv[gs_argc++] = "-";
+ }
+ else {
+ gs_argv[gs_argc++] = "--";
+ gs_argv[gs_argc++] = path;
}
-
- gs_cmdline = (char*)malloc(strlen(gs_cmd)+strlen(rotate_path)+
- strlen(ocr_path) + strlen(input) + 128);
-
- if (gs_cmdline == NULL) {
- fprintf(stderr, "No memory available\n");
- cleanup();
- exit(1);
- }
-
- sprintf(
- gs_cmdline,
-#ifdef VMS
- "%s -r72 \"-dNODISPLAY\" \"-dFIXEDMEDIA\" \"-dDELAYBIND\" \"-dWRITESYSTEMDICT\" %s \"-dNOPAUSE\" %s %s %s",
-#else
- "%s -r72 -dNODISPLAY -dFIXEDMEDIA -dDELAYBIND -dWRITESYSTEMDICT %s -dNOPAUSE %s %s %s",
-#endif
- gs_cmd,
- (debug ? "" : "-q"),
- rotate_path,
- ocr_path,
- input
- );
- if (debug) fprintf(stderr, "%s\n", gs_cmdline);
+ gs_argv[gs_argc++] = NULL;
#ifdef VMS
cmdfile = tempnam("SYS$SCRATCH:","PS2TGS");
gsoutfile = tempnam("SYS$SCRATCH:","GSRES");
@@ -259,8 +250,25 @@
exit(1);
}
#else
- gs = popen(gs_cmdline, "r");
- if (gs==0) {perror(cmd); exit(1);}
+ if (pipe(fd)) {
+ perror("pipe failed: "); exit(1);
+ };
+ p = fork();
+ if (p == -1) {
+ perror("fork failed: "); exit(1);
+ }
+ if (p == 0) { /* child */
+ close(fd[0]);
+ dup2(fd[1], 1); /* Redirect stdout into pipe to parent */
+ execvp("%%LOCALBASE%%/bin/gs", gs_argv);
+ perror("execvp: "); status=cleanup(); exit(1);
+ } else { /* parent */
+ close(fd[1]);
+ gs = fdopen(fd[0], "r");
+ if (gs == NULL) {
+ perror("fdopen: "); status=cleanup(); exit(1);
+ }
+ }
#endif
status = pstotextInit(&instance);
if (status!=0) {

View File

@ -0,0 +1,11 @@
--- pstotext.1.orig 2008-07-14 11:41:51.372153755 -0400
+++ pstotext.1 2008-07-14 12:40:21.785198430 -0400
@@ -128,7 +128,7 @@
.br
Distributed only by permission.
.br
-See file pstotext.txt for details.
+See file %%PREFIX%%/share/doc/pstotext/copyright for details.
.br
.BR
.PP

View File

@ -21,19 +21,3 @@ standard input. (PDF documents require random access, hence cannot be read
from standard input.) You can use the -output option to specify an output file
(remember to invoke it before the input file); otherwise pstotext writes to
standard output.
The option -cork is only relevant for PostScript files produced by dvips from
TeX or LaTeX documents; it tells pstotext to use the Cork encoding (known as T1
in LaTeX) rather than the old TeX text encoding (known as OT1 in LaTeX).
Unfortunately files produced by dvips don't distinguish which font encodings
were used.
The options -landscape and -landscapeOther should be used for documents that
must be rotated 90 degrees clockwise or counterclockwise, respectively, in
order to be readable.
The options -debug and -bboxes are mostly of use for the maintainers of
pstotext. -debug shows Ghostscript output and error messages. -bboxes outputs
one word per line with bounding box information.
WWW: http://www.research.digital.com/SRC/virtualpaper/pstotext.html