opt/a2ps/a2ps-4.13c.patch
2006-02-23 15:26:10 +00:00

122 lines
3.7 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff -Nru a2ps-4.13.orig/contrib/Makefile.in a2ps-4.13/contrib/Makefile.in
--- a2ps-4.13.orig/contrib/Makefile.in 2005-04-16 21:34:09.000000000 +0200
+++ a2ps-4.13/contrib/Makefile.in 2005-04-16 21:36:27.000000000 +0200
@@ -162,7 +162,7 @@
install_sh = @install_sh@
lispdir = @lispdir@
-SUBDIRS = sample emacs
+SUBDIRS = sample
bin_SCRIPTS = card fixps pdiff psmandup psset texi2dvi4a2ps
bin_PROGRAMS = fixnt
diff -Nru a2ps-4.13.orig/contrib/fixps.in a2ps-4.13/contrib/fixps.in
--- a2ps-4.13.orig/contrib/fixps.in 2005-04-16 21:34:09.000000000 +0200
+++ a2ps-4.13/contrib/fixps.in 2005-04-16 21:34:54.000000000 +0200
@@ -38,7 +38,7 @@
run_gs=0
# What action to perform: fixps, cat, check, and gs
task=fixps
-tmpdir=/tmp/$program.$$
+tmpdir=`mktemp -d -t fixps.XXXXXX` || { echo "$program: Cannot create temporary dir!" >&2 ; exit 1; }
verbose=echo
# The version/usage strings
@@ -191,7 +191,6 @@
trap "/bin/rm -rf $tmpdir" 0 1 2 3 13 15
fi
-mkdir $tmpdir
fixps_sed=$tmpdir/fixps.sed
# If printing from stdin, save into a tmp file
diff -Nru a2ps-4.13.orig/contrib/psmandup.in a2ps-4.13/contrib/psmandup.in
--- a2ps-4.13.orig/contrib/psmandup.in 2005-04-16 21:34:09.000000000 +0200
+++ a2ps-4.13/contrib/psmandup.in 2005-04-16 21:35:05.000000000 +0200
@@ -36,7 +36,7 @@
message=
psselect=${PSSELECT:-psselect}
psset=${PSSET:-psset}
-tmpdir=/tmp/$program.$$
+tmpdir=`mktemp -d -t fixps.XXXXXX` || { echo "$program: Cannot create temporary dir!" >&2 ; exit 1; }
# These two must be kept in synch. They are opposed.
verbose=echo
@@ -185,7 +185,6 @@
trap "/bin/rm -rf $tmpdir" 0 1 2 3 13 15
fi
-mkdir $tmpdir
# If printing from stdin, save into a tmp file
if test $file = '-'; then
diff -Nru a2ps-4.13.orig/lib/path-concat.c a2ps-4.13/lib/path-concat.c
--- a2ps-4.13.orig/lib/path-concat.c 2005-04-16 21:34:09.000000000 +0200
+++ a2ps-4.13/lib/path-concat.c 2005-04-16 21:36:01.000000000 +0200
@@ -31,7 +31,6 @@
#endif
#include <sys/types.h>
-char *malloc ();
#ifndef DIRECTORY_SEPARATOR
# define DIRECTORY_SEPARATOR '/'
diff -Nru a2ps-4.13.orig/src/select.c a2ps-4.13/src/select.c
--- a2ps-4.13.orig/src/select.c 2005-04-16 21:34:09.000000000 +0200
+++ a2ps-4.13/src/select.c 2005-04-16 21:35:11.000000000 +0200
@@ -131,6 +131,36 @@
return 1;
}
+/* escapes the name of a file so that the shell groks it in 'single' q.marks.
+ The resulting pointer has to be free()ed when not longer used. */
+char *
+shell_escape(const char *fn)
+{
+ size_t len = 0;
+ const char *inp;
+ char *retval, *outp;
+
+ for(inp = fn; *inp; ++inp)
+ switch(*inp)
+ {
+ case '\'': len += 4; break;
+ default: len += 1; break;
+ }
+
+ outp = retval = malloc(len + 1);
+ if(!outp)
+ return NULL; /* perhaps one should do better error handling here */
+ for(inp = fn; *inp; ++inp)
+ switch(*inp)
+ {
+ case '\'': *outp++ = '\''; *outp++ = '\\'; *outp++ = '\'', *outp++ = '\''; break;
+ default: *outp++ = *inp; break;
+ }
+ *outp = 0;
+
+ return retval;
+}
+
/* What says file about the type of a file (result is malloc'd). NULL
if could not be run. */
@@ -144,11 +174,15 @@
if (IS_EMPTY (job->file_command))
return NULL;
+ filename = shell_escape(filename);
+ if(filename == NULL)
+ return NULL;
/* Call file(1) with the correct option */
- command = ALLOCA (char, (2
+ command = ALLOCA (char, (4
+ strlen (job->file_command)
+ ustrlen (filename)));
- sprintf (command, "%s %s", job->file_command, (const char *) filename);
+ sprintf (command, "%s '%s'", job->file_command, (const char *) filename);
+ free(filename);
message (msg_tool, (stderr, "Reading pipe: `%s'\n", command));
file_out = popen (command, "r");