diff -Nru pstotext-1.9/debian/changelog pstotext-1.9/debian/changelog --- pstotext-1.9/debian/changelog 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/changelog 2010-07-10 17:24:08.000000000 +0000 @@ -1,3 +1,24 @@ +pstotext (1.9-5) unstable; urgency=medium + + * New maintainer (closes: #585061) + * [debian/control] updated dependency on ghostscript (closes: #539671) + * [debian/rules] -fno-string-aliasing workaround to prevent broken + compilation of type punning (closes: #586914) + * [debian/copyright] new maintainer, including pstotext.txt only once + (closes: #289097) + * [debian/control] updated to Standards-Version: 3.9.0.0 (no changes needed) + * [debian/control] new Homepage field added; added ${misc:Depends} + * [debian/{preinst,postinst,prerm,postrm}] deleted because trivial + * [debian/README.debian] doc path fixed; new maintainer + * [debian/compat] set to 7 + * [debian/source/format] set to "3.0 (quilt)" + * [debian/watch] added + * patches moved from diff.gz to debian/patches + * [debian/rules] - builds in debian/pstotext instead of debian/tmp; + dh_installman instead of dh_install_manpages; wiped useless dh_* + + -- Jan Jeroným Zvánovec Sat, 10 Jul 2010 19:23:58 +0200 + pstotext (1.9-4) unstable; urgency=medium * [main.c] Applied patch courtesy of Martin Ehmsen to diff -Nru pstotext-1.9/debian/compat pstotext-1.9/debian/compat --- pstotext-1.9/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/compat 2010-07-10 17:24:08.000000000 +0000 @@ -0,0 +1 @@ +7 diff -Nru pstotext-1.9/debian/control pstotext-1.9/debian/control --- pstotext-1.9/debian/control 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/control 2010-07-10 17:24:08.000000000 +0000 @@ -1,13 +1,14 @@ Source: pstotext Section: text Priority: optional -Build-Depends: debhelper -Maintainer: J.H.M. Dassen (Ray) -Standards-Version: 3.7.2 +Build-Depends: debhelper (>= 7) +Maintainer: Jan Jeroným Zvánovec +Standards-Version: 3.9.0.0 +Homepage: http://www.cs.wisc.edu/~ghost/doc/pstotext.htm Package: pstotext Architecture: any -Depends: gs | gs-gpl (>= 3.51), ${shlibs:Depends} +Depends: ghostscript, ${shlibs:Depends}, ${misc:Depends} Description: Extract text from PostScript and PDF files pstotext extracts text (in the ISO 8859-1 character set) from a PostScript or PDF (Portable Document Format) file. Thus, pstotext is similar to the diff -Nru pstotext-1.9/debian/copyright pstotext-1.9/debian/copyright --- pstotext-1.9/debian/copyright 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/copyright 2010-07-10 17:24:08.000000000 +0000 @@ -1,170 +1,13 @@ This package was originally debianized by J.H.M. Dassen on Sun, 12 Jan 1997 19:18:04 +0100. +The current Debian maintainer is Jan Jeroným Zvánovec + It was originally obtained via http://www.research.digital.com/SRC/virtualpaper/pstotext.html but is now found through http://www.cs.wisc.edu/~ghost/doc/pstotext.htm -Copyright information (pstotext.txt file of the source distribution): - -=================================================================== -pstotext.txt 9 Jan 2004 -=================================================================== -pstotext 1.9 - PostScript text extractor. Requires Ghostscript. - -The files pstotxt1.dll (Win16), pstotxt2.dll (OS/2) pstotxt3.dll (Win32), and -pstotext.zip (sources) constitute the pstotext package, which was written by -Paul McJones and Andrew Birrell of Digital Equipment Corporation's Systems -Research Center. These files are copyright by Digital Equipment Corporation. -You may use them subject to the attached END USER LICENSE AGREEMENT. - -The source files are available in the GSview source distribution, -or directly from the authors: - http://www.research.digital.com/SRC/virtualpaper/pstotext.html - -You can build DLL and command-line versions of pstotext for various -platforms from the sources: - PLATFORM BUILD FILE - Unix Makefile - Win16 pstotxt1.mak - OS/2 pstotxt2.mak - Win32 pstotxt3.mak (Borland C++ 4.5) - Win32 pstotxtv.mak (Microsoft Visual Studio) - VMS descrip.mms - -pstotext was developed as a part of the Virtual Paper system, which is -a high-quality viewer for computer-generated or scanned documents. -See: - http://www.research.digital.com/SRC/virtualpaper/ - -We appreciate Russell Lang's willingness to incorporate pstotext in -GSview, and his help in redesigning the API to the DLL module and in -debugging the final version. We thank Hunter Goatley for the VMS -port. - -You can contact the authors at and -. -For Windows and OS, contact gsview@ghostgum.com.au; -for VMS, contact . - -Version 1.9 is a modification of 1.8h to recognise excessive space in -"ashow" as being a word separator, as found output from groff 1.08. -Also fixed widthshow, awidthshow and added xshow, yshow and xyshow. -Uses ANSI prototypes. These are now required, not optional. -Fixes a number of compiler warnings. -Note that neither of the original authors still work at DEC/Compaq/HP. -2004-01-09 by Russell Lang at Ghostgum Software Pty Ltd. - -Version 1.8h is a modification of the original 1.8 to allow -operation with Aladdin Ghostscript 6.0, to add -output to -Windows and OS/2 executables, and to insert line breaks -and form feeds is pstotext output. Modifications made -2000-07-15 by Russell Lang at Ghostgum Software Pty Ltd. -main.c changed to use mkstemp not tempnam for Unix, -2000-06-02 by Russell Lang at Ghostgum Software Pty Ltd. - - - ========================== - END USER LICENSE AGREEMENT - ========================== - -GRANT. Subject to the provisions contained herein, Digital Equipment -Corporation ("Digital") hereby grants you a non-exclusive license to -use its accompanying proprietary software product and associated -documentation ("Software") free of charge pursuant to the terms and -conditions of this Agreement. - -You are not entitled to support or telephone assistance in connection -with your use of the Software. - -SOFTWARE AND DOCUMENTATION. Digital shall furnish the Software to you -electronically or on media in source code form. This license does not -grant you any right to any enhancement or update to the Software and -Documentation. - -USE RESTRICTIONS. You may use, copy, modify, and distribute the -Software in source code or object code form, subject to the following -conditions: - - (1) If the Software is modified, any Software containing -modifications must prominently state in the modified product or -documentation (i) that it has been modified, (ii) the identity of the -person or entity that made the modifications, and (iii) the date the -modifications were made. - - (2) Each copy of the Software made by you shall be subject to -the terms of this Agreement and shall contain all of Digital's notices -regarding copyrights, trademarks and other proprietary rights as -contained in the Software originally provided to you. - - (3) The Software may not be transferred to any third party -unless such third party receives a copy of this Agreement and agrees -to be bound by all of its terms and conditions. - -TITLE. Title, ownership rights, and intellectual property rights in -and to the Software shall remain in Digital and/or its suppliers. The -Software is protected by the copyright laws of the United States and -international copyright treaties. - -CONTENT. Title, ownership rights, and intellectual property rights in -and to the content accessed through the Software is the property of -the applicable content owner and may be protected by applicable -copyright or other law. This License gives you no rights to such -content. - -DISCLAIMER OF WARRANTY. Since the Software is provided free of -charge, the Software is provided on an "AS IS" basis, without warranty -of any kind, including without limitation the warranties of -merchantability, fitness for a particular purpose and -non-infringement. The entire risk as to the quality and performance -of the Software is borne by you. Should the Software prove defective, -you, and not Digital assume the entire cost of any service and repair. -This disclaimer of warranty constitutes an essential part of the -agreement. - -LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL -THEORY, TORT, CONTRACT, OR OTHERWISE, SHALL DIGITAL OR ITS SUPPLIERS -RESELLERS, OR LICENSEES BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY -CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, -STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER -COMMERCIAL DAMAGES OR LOSSES, EVEN IF DIGITAL SHALL HAVE BEEN INFORMED -OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER -PARTY. - -EXPORT CONTROLS. You may not download or otherwise export or reexport -the Software or any underlying information or technology except in -full compliance with all United States and other applicable laws and -regulations. By downloading or using the Software, you are agreeing -to the foregoing. - -TERMINATION. This Agreement shall automatically terminate upon -failure by you to comply with its terms, in which case you shall -immediately discontinue the use of the Software and shall within ten -(10) days return to Digital or destroy all copies of the Software. -You may also terminate this Agreement at any time by destroying the -Software and all copies thereof. - -MISCELLANEOUS. This Agreement represents the complete and exclusive -statement of the agreements concerning this license between the -parties. It may be amended only by a writing executed by both -parties. If any provision of this Agreement is held to be -unenforceable for any reason, such provision shall be reformed only to -the extent necessary to make it enforceable, and such decision shall -not affect the enforceability (i) of such provision under other -circumstances or (ii) of the remaining provisions hereof under all -circumstances. Headings shall not be considered in interpreting this -Agreement. This Agreement shall be governed by and construed under -the laws of the Commonwealth of Massachusetts, except as governed by -Federal law. This Agreement will not be governed by the United -Nations Convention of Contracts for the International Sale of Goods, -the application of which is hereby expressly excluded. +Original copyright ⓒ 1995-1998, Digital Equipment Corporation +Full copyright information (pstotext.txt file of the source distribution): -U.S. Government Restricted Rights. Use, duplication or disclosure by -the Government is subject to restrictions set forth in subparagraphs -(a) through (d) of the Commercial Computer-Restricted Rights clause at -FAR 52 227-19 when applicable, or in subparagraph (c) (1) (ii) of the -Rights in Technical Data and Computer Software clause at DFARS -252.227-7013, and in similar clauses in the NASA FAR Supplement. -Contractor/manufacturer is Digital Equipment Corporation. diff -Nru pstotext-1.9/debian/dirs pstotext-1.9/debian/dirs --- pstotext-1.9/debian/dirs 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/dirs 2010-07-10 17:24:08.000000000 +0000 @@ -1,2 +1,3 @@ usr/bin usr/share/man/man1 +usr/share/doc/pstotext diff -Nru pstotext-1.9/debian/manpages pstotext-1.9/debian/manpages --- pstotext-1.9/debian/manpages 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/manpages 2010-07-10 17:24:08.000000000 +0000 @@ -0,0 +1 @@ +pstotext.1 diff -Nru pstotext-1.9/debian/patches/1.9-3_and_1.9-4.patch pstotext-1.9/debian/patches/1.9-3_and_1.9-4.patch --- pstotext-1.9/debian/patches/1.9-3_and_1.9-4.patch 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/patches/1.9-3_and_1.9-4.patch 2010-07-10 17:24:08.000000000 +0000 @@ -0,0 +1,141 @@ +Subject: Security fix, arbitratry code execution via bad popen(3) call +Bug-Debian: http://bugs.debian.org/356988 +Author: J.H.M. Dassen (Ray) +Author: Martin Ehmsen +Last-Update: 2010-07-10 + +--- a/main.c ++++ b/main.c +@@ -126,12 +126,14 @@ + static int cleanup(void) { + int gsstatus, status = 0; + pstotextExit(instance); +- if (gs!=NULL) { + #ifdef VMS ++ if (gs!=NULL) { + gsstatus = fclose(gs); ++ } + #else +- gsstatus = pclose(gs); ++ waitpid(-1, &gsstatus, 0); + #endif ++ 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("/usr/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) { diff -Nru pstotext-1.9/debian/patches/doc-path.patch pstotext-1.9/debian/patches/doc-path.patch --- pstotext-1.9/debian/patches/doc-path.patch 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/patches/doc-path.patch 2010-07-10 17:24:08.000000000 +0000 @@ -0,0 +1,16 @@ +Description: Debian specific: fix copyright path in manpage +Author: J.H.M. Dassen (Ray) +Forwarded: not-needed +Last-Update: 2010-07-10 + +--- a/pstotext.1 ++++ b/pstotext.1 +@@ -128,7 +128,7 @@ + .br + Distributed only by permission. + .br +-See file pstotext.txt for details. ++See file /usr/share/doc/pstotext/copyright for details. + .br + .BR + .PP diff -Nru pstotext-1.9/debian/patches/series pstotext-1.9/debian/patches/series --- pstotext-1.9/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/patches/series 2010-07-10 17:24:08.000000000 +0000 @@ -0,0 +1,2 @@ +1.9-3_and_1.9-4.patch +doc-path.patch diff -Nru pstotext-1.9/debian/postinst pstotext-1.9/debian/postinst --- pstotext-1.9/debian/postinst 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/postinst 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -#! /bin/sh -set -e - -#DEBHELPER# diff -Nru pstotext-1.9/debian/postrm pstotext-1.9/debian/postrm --- pstotext-1.9/debian/postrm 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/postrm 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -#! /bin/sh -set -e - -#DEBHELPER# diff -Nru pstotext-1.9/debian/preinst pstotext-1.9/debian/preinst --- pstotext-1.9/debian/preinst 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/preinst 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -#! /bin/sh -set -e - -#DEBHELPER# diff -Nru pstotext-1.9/debian/prerm pstotext-1.9/debian/prerm --- pstotext-1.9/debian/prerm 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/prerm 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -#! /bin/sh -set -e - -#DEBHELPER# diff -Nru pstotext-1.9/debian/README.debian pstotext-1.9/debian/README.debian --- pstotext-1.9/debian/README.debian 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/README.debian 2010-07-10 17:24:08.000000000 +0000 @@ -1,15 +1,16 @@ pstotext for DEBIAN ------------------- -This package was packaged for Debian GNU/Linux by J.H.M. Dassen -. +This package was originally packaged for Debian GNU/Linux by J.H.M. Dassen +. +The current Debian maintainer is Jan Jeroným Zvánovec NOTICE ------ In accordance with the USE RESTRICTIONS specified in the END USER LICENSE -AGREEMENT governing this package (available in /usr/doc/pstotext/copyright.gz), -please be aware that: +AGREEMENT governing this package (available in +/usr/share/doc/pstotext/copyright.gz), please be aware that: (i). THIS SOFTWARE HAS BEEN MODIFIED. (ii). The modifications were done by developers of Debian GNU/Linux, organized as Software in the Public Interest (SPI), contact diff -Nru pstotext-1.9/debian/rules pstotext-1.9/debian/rules --- pstotext-1.9/debian/rules 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/debian/rules 2010-07-10 17:24:08.000000000 +0000 @@ -13,7 +13,7 @@ ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else - CFLAGS += -O2 + CFLAGS += -O2 -fno-strict-aliasing endif @@ -30,22 +30,22 @@ dh_testroot rm -f build-stamp -rm -f core - -make clean + [ ! -f Makefile ] || make clean -rm -f `find . -name "*~"` - -rm -rf debian/tmp debian/files* debian/substvars + -rm -rf debian/pstotext debian/files* debian/substvars install: build dh_testdir dh_testroot - dh_clean -k + dh_prep dh_installdirs - install -d debian/tmp - cd debian/tmp; install -d `cat ../dirs` - install -p pstotext `pwd`/debian/tmp/usr/bin + install -d debian/pstotext + cd debian/pstotext; install -d `cat ../dirs` + install -p pstotext `pwd`/debian/pstotext/usr/bin dh_installdocs - cat pstotext.txt >> `pwd`/debian/tmp/usr/share/doc/pstotext/copyright - touch -r debian/copyright `pwd`/debian/tmp/usr/share/doc/pstotext/copyright + cat pstotext.txt >> `pwd`/debian/pstotext/usr/share/doc/pstotext/copyright + touch -r debian/copyright `pwd`/debian/pstotext/usr/share/doc/pstotext/copyright # Build architecture-independent files here. binary-indep: build install @@ -53,31 +53,20 @@ # Build architecture-dependent files here. binary-arch: build install -# dh_testversion dh_testdir dh_testroot -# dh_installdebconf dh_installdocs - cat pstotext.txt >> `pwd`/debian/tmp/usr/share/doc/pstotext/copyright - touch -r debian/copyright `pwd`/debian/tmp/usr/share/doc/pstotext/copyright - dh_installexamples - dh_installmenu + cat pstotext.txt >> `pwd`/debian/pstotext/usr/share/doc/pstotext/copyright + touch -r debian/copyright `pwd`/debian/pstotext/usr/share/doc/pstotext/copyright dh_installmime -# dh_installemacsen -# dh_installpam -# dh_installinit - dh_installcron - dh_installmanpages + dh_installman dh_installinfo -# dh_undocumented dh_installchangelogs #CHANGELOGS# dh_link dh_strip dh_compress dh_fixperms -# dh_makeshlibs dh_installdeb -# dh_perl dh_shlibdeps dh_gencontrol dh_md5sums diff -Nru pstotext-1.9/debian/source/format pstotext-1.9/debian/source/format --- pstotext-1.9/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/source/format 2010-10-15 16:02:48.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru pstotext-1.9/debian/watch pstotext-1.9/debian/watch --- pstotext-1.9/debian/watch 1970-01-01 00:00:00.000000000 +0000 +++ pstotext-1.9/debian/watch 2010-07-10 17:24:08.000000000 +0000 @@ -0,0 +1,5 @@ +# format version number, currently 3; this line is compulsory! +version=3 + +http://mirror.cs.wisc.edu/pub/mirrors/ghost/contrib/pstotext-(.*)\.tar\.gz + diff -Nru pstotext-1.9/main.c pstotext-1.9/main.c --- pstotext-1.9/main.c 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/main.c 2004-01-09 10:17:38.000000000 +0000 @@ -126,14 +126,12 @@ static int cleanup(void) { int gsstatus, status = 0; pstotextExit(instance); -#ifdef VMS if (gs!=NULL) { +#ifdef VMS gsstatus = fclose(gs); - } #else - waitpid(-1, &gsstatus, 0); + gsstatus = pclose(gs); #endif - if (gsstatus) { if (WIFEXITED(gsstatus)) { if (WEXITSTATUS(gsstatus)!=0) status = 3; else if (WIFSIGNALED(gsstatus)) status = 4; @@ -168,13 +166,8 @@ static int do_it(char *path) { /* If "path" is NULL, then "stdin" should be processed. */ - char *gs_argv[32]; - int gs_argc=0; -#ifdef DEBUG - int i; -#endif - int fd[2]; - pid_t p; + char *gs_cmdline; + char *input; int status; char norotate[] = ""; FILE *fileout; @@ -208,31 +201,47 @@ exit(1); } - 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; + 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++] = NULL; + + 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); #ifdef VMS cmdfile = tempnam("SYS$SCRATCH:","PS2TGS"); gsoutfile = tempnam("SYS$SCRATCH:","GSRES"); @@ -250,25 +259,8 @@ exit(1); } #else - 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("/usr/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); - } - } + gs = popen(gs_cmdline, "r"); + if (gs==0) {perror(cmd); exit(1);} #endif status = pstotextInit(&instance); if (status!=0) { diff -Nru pstotext-1.9/pstotext.1 pstotext-1.9/pstotext.1 --- pstotext-1.9/pstotext.1 2010-10-15 16:02:48.000000000 +0000 +++ pstotext-1.9/pstotext.1 2000-02-05 11:01:48.000000000 +0000 @@ -128,7 +128,7 @@ .br Distributed only by permission. .br -See file /usr/share/doc/pstotext/copyright for details. +See file pstotext.txt for details. .br .BR .PP