automatic rebuild by autodist [release 1.9-3mamba;Thu Sep 05 2013]

This commit is contained in:
Automatic Build System 2024-01-06 10:34:29 +01:00
parent 62e88d59bc
commit fcf287a43a
3 changed files with 186 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# pstotext
Pstotext extracts text (in the ISO 8859-1 character set) from a PostScript or PDF (Portable Document Format) file.

View File

@ -0,0 +1,136 @@
diff -pur pstotext-1.9/main.c pstotext-1.9-fix/main.c
--- pstotext-1.9/main.c 2004-01-09 11:17:38.000000000 +0100
+++ pstotext-1.9-fix/main.c 2007-07-04 15:26:46.000000000 +0200
@@ -126,12 +126,14 @@ static char *cmdfile = NULL, *gsoutfile
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 void handler(int x) {
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,32 @@ static int do_it(char *path) {
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_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);
+ 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;
}
- 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 +251,25 @@ static int do_it(char *path) {
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) {

48
pstotext.spec Normal file
View File

@ -0,0 +1,48 @@
Name: pstotext
Version: 1.9
Release: 3mamba
Summary: Utility to extract plain text from PostScript
Group: Applications/Publishing
Vendor: openmamba
Distribution: openmamba
Packager: Davide Madrisan <davide.madrisan@qilinux.it>
URL: http://www.cs.wisc.edu/~ghost/doc/pstotext.htm
Source: ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/contrib/%{name}-%{version}.tar.gz
Patch: %{name}-1.9-deb_inputfromstdin.patch
License: Ghostgum Software Pty Ltd
BuildRequires: ghostscript >= 7.07.1
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
Pstotext extracts text (in the ISO 8859-1 character set) from a PostScript or PDF (Portable Document Format) file.
%prep
%setup -q
%patch -p1
%build
%make
%install
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
install -D -m 755 pstotext %{buildroot}%{_bindir}/pstotext
install -D -m 644 pstotext.1 %{buildroot}%{_mandir}/man1/pstotext.1
%clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot}
%files
%defattr(-,root,root)
%{_bindir}/pstotext
%{_mandir}/man1/pstotext.1.*
%doc pstotext.txt
%changelog
* Thu Sep 05 2013 Automatic Build System <autodist@mambasoft.it> 1.9-3mamba
- automatic rebuild by autodist
* Wed Jul 04 2007 Aleph0 <aleph0@openmamba.org> 1.9-2mamba
- applied patch from gentoo to unbreak pstotext on input from stdin
* Wed Dec 28 2005 Alessandro Ramazzina <alessandro.ramazzina@qilinux.it> 1.9-1qilnx
- package created by autospec