summaryrefslogtreecommitdiff
path: root/print/enscript/patches/patch-ad
diff options
context:
space:
mode:
Diffstat (limited to 'print/enscript/patches/patch-ad')
-rw-r--r--print/enscript/patches/patch-ad78
1 files changed, 0 insertions, 78 deletions
diff --git a/print/enscript/patches/patch-ad b/print/enscript/patches/patch-ad
deleted file mode 100644
index 756cd2585aa..00000000000
--- a/print/enscript/patches/patch-ad
+++ /dev/null
@@ -1,78 +0,0 @@
-$NetBSD: patch-ad,v 1.2 2009/02/13 18:53:28 abs Exp $
-
---- src/util.c.orig 2003-03-05 07:26:32.000000000 +0000
-+++ src/util.c
-@@ -1239,6 +1239,8 @@ escape_string (char *string)
-
- /* Create result. */
- cp = xmalloc (len + 1);
-+ if (cp == NULL)
-+ return NULL;
- for (i = 0, j = 0; string[i]; i++)
- switch (string[i])
- {
-@@ -1879,6 +1881,7 @@ is_open (InputStream *is, FILE *fp, char
- char *cmd = NULL;
- int cmdlen;
- int i, pos;
-+ char *cp;
-
- is->is_pipe = 1;
-
-@@ -1902,12 +1905,16 @@ is_open (InputStream *is, FILE *fp, char
- {
- case 's':
- /* Expand cmd-buffer. */
-- cmdlen += strlen (fname);
-+ if ((cp = shell_escape (fname)) != NULL)
-+ {
-+ cmdlen += strlen (cp);
- cmd = xrealloc (cmd, cmdlen);
-
- /* Paste filename. */
-- strcpy (cmd + pos, fname);
-- pos += strlen (fname);
-+ strcpy (cmd + pos, cp);
-+ pos += strlen (cp);
-+ free (cp);
-+ }
-
- i++;
- break;
-@@ -2116,3 +2123,36 @@ buffer_len (Buffer *buffer)
- {
- return buffer->len;
- }
-+
-+/*
-+ * Escapes the name of a file so that the shell groks it in 'single'
-+ * quotation 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;
-+}