enscript:moved into main for pisi 2.0

This commit is contained in:
2015-10-29 00:17:31 +03:00
parent 5de873f662
commit 89c0213664
10 changed files with 719 additions and 0 deletions
@@ -0,0 +1,11 @@
--- src/main.c.org 2005-06-01 01:23:29.000000000 +0200
+++ src/main.c 2005-06-01 01:26:38.000000000 +0200
@@ -2001,7 +2001,7 @@
int i;
c = getopt_long (argc, argv,
- "#:123456789a:A:b:BcC::d:D:e::E::f:F:gGhH::i:I:jJ:kKlL:mM:n:N:o:Op:P:qrRs:S:t:T:u::U:vVW:X:zZ",
+ "#:123456789a:A:b:BcC::d:D:e::E::f:F:gGhH::i:I:jJ:kKlL:mM:n:N:o:Op:P:qrRs:S:t:T:u::U:vVw:W:X:zZ",
long_options, &option_index);
if (c == -1)
@@ -0,0 +1,177 @@
diff -u -p -Nr --exclude CVS orig/enscript-1.6.3/src/gsint.h enscript-1.6.3.CAN-2004-1184/src/gsint.h
--- orig/enscript-1.6.3/src/gsint.h 2000-07-11 17:28:06.000000000 +0200
+++ enscript-1.6.3.CAN-2004-1184/src/gsint.h 2005-01-04 20:45:24.000000000 +0100
@@ -701,4 +701,9 @@ FILE *printer_open ___P ((char *cmd, cha
*/
void printer_close ___P ((void *context));
+/*
+ * Escape filenames for shell usage
+ */
+char *shell_escape ___P ((const char *fn));
+
#endif /* not GSINT_H */
diff -u -p -Nr --exclude CVS orig/enscript-1.6.3/src/main.c enscript-1.6.3.CAN-2004-1184/src/main.c
--- orig/enscript-1.6.3/src/main.c 2005-01-04 20:52:31.000000000 +0100
+++ enscript-1.6.3.CAN-2004-1184/src/main.c 2005-01-05 10:57:44.000000000 +0100
@@ -1555,9 +1555,13 @@ name width\theight\tllx\tlly
buffer_append (&cmd, intbuf);
buffer_append (&cmd, " ");
- buffer_append (&cmd, "-Ddocument_title=\"");
- buffer_append (&cmd, title);
- buffer_append (&cmd, "\" ");
+ buffer_append (&cmd, "-Ddocument_title=\'");
+ if ((cp = shell_escape (title)) != NULL)
+ {
+ buffer_append (&cmd, cp);
+ free (cp);
+ }
+ buffer_append (&cmd, "\' ");
buffer_append (&cmd, "-Dtoc=");
buffer_append (&cmd, toc ? "1" : "0");
@@ -1574,8 +1578,14 @@ name width\theight\tllx\tlly
/* Append input files. */
for (i = optind; i < argc; i++)
{
- buffer_append (&cmd, " ");
- buffer_append (&cmd, argv[i]);
+ char *cp;
+ if ((cp = shell_escape (argv[i])) != NULL)
+ {
+ buffer_append (&cmd, " \'");
+ buffer_append (&cmd, cp);
+ buffer_append (&cmd, "\'");
+ free (cp);
+ }
}
/* And do the job. */
@@ -1636,7 +1645,7 @@ name width\theight\tllx\tlly
buffer_ptr (opts), buffer_len (opts));
}
- buffer_append (&buffer, " \"%s\"");
+ buffer_append (&buffer, " \'%s\'");
input_filter = buffer_copy (&buffer);
input_filter_stdin = "-";
diff -u -p -Nr --exclude CVS orig/enscript-1.6.3/src/util.c enscript-1.6.3.CAN-2004-1184/src/util.c
--- orig/enscript-1.6.3/src/util.c 1999-09-17 17:26:51.000000000 +0200
+++ enscript-1.6.3.CAN-2004-1184/src/util.c 2005-01-05 10:43:23.000000000 +0100
@@ -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);
- cmd = xrealloc (cmd, cmdlen);
+ if ((cp = shell_escape (fname)) != NULL)
+ {
+ cmdlen += strlen (cp);
+ cmd = xrealloc (cmd, cmdlen);
- /* Paste filename. */
- strcpy (cmd + pos, fname);
- pos += strlen (fname);
+ /* Paste filename. */
+ 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;
+}
diff -u -p -Nr --exclude CVS enscript-1.6.3.CAN-2004-1184/src/psgen.c enscript-1.6.3.CAN-2004-1185/src/psgen.c
--- enscript-1.6.3.CAN-2004-1184/src/psgen.c 2005-01-04 20:59:56.000000000 +0100
+++ enscript-1.6.3.CAN-2004-1185/src/psgen.c 2005-01-05 15:22:40.000000000 +0100
@@ -2385,9 +2385,10 @@ recognize_eps_file (Token *token)
MESSAGE (2, (stderr, "^@epsf=\"%s\"\n", token->u.epsf.filename));
i = strlen (token->u.epsf.filename);
+ /*
if (i > 0 && token->u.epsf.filename[i - 1] == '|')
{
- /* Read EPS data from pipe. */
+ / * Read EPS data from pipe. * /
token->u.epsf.pipe = 1;
token->u.epsf.filename[i - 1] = '\0';
token->u.epsf.fp = popen (token->u.epsf.filename, "r");
@@ -2400,6 +2401,7 @@ recognize_eps_file (Token *token)
}
}
else
+ */
{
char *filename;
diff -u -p -Nr --exclude CVS enscript-1.6.3.CAN-2004-1185/src/psgen.c enscript-1.6.3.CAN-2004-1186/src/psgen.c
--- enscript-1.6.3.CAN-2004-1185/src/psgen.c 2005-01-05 15:22:40.000000000 +0100
+++ enscript-1.6.3.CAN-2004-1186/src/psgen.c 2005-01-05 15:22:44.000000000 +0100
@@ -2034,8 +2034,9 @@ dump_ps_page_header (char *fname, int em
else
{
ftail++;
- strncpy (buf, fname, ftail - fname);
- buf[ftail - fname] = '\0';
+ i = ftail - fname >= sizeof (buf)-1 ? sizeof (buf)-1 : ftail - fname;
+ strncpy (buf, fname, i);
+ buf[i] = '\0';
}
if (nup > 1)
@@ -0,0 +1,91 @@
--- src/psgen.c
+++ src/psgen.c 2008-10-29 10:43:08.512598143 +0100
@@ -24,6 +24,7 @@
* Boston, MA 02111-1307, USA.
*/
+#include <limits.h>
#include "gsint.h"
/*
@@ -124,7 +125,7 @@ struct gs_token_st
double xscale;
double yscale;
int llx, lly, urx, ury; /* Bounding box. */
- char filename[512];
+ char filename[PATH_MAX];
char *skipbuf;
unsigned int skipbuf_len;
unsigned int skipbuf_pos;
@@ -135,11 +136,11 @@ struct gs_token_st
Color bgcolor;
struct
{
- char name[512];
+ char name[PATH_MAX];
FontPoint size;
InputEncoding encoding;
} font;
- char filename[512];
+ char filename[PATH_MAX];
} u;
};
@@ -248,7 +249,7 @@ static int do_print = 1;
static int user_fontp = 0;
/* The user ^@font{}-defined font. */
-static char user_font_name[256];
+static char user_font_name[PATH_MAX];
static FontPoint user_font_pt;
static InputEncoding user_font_encoding;
@@ -978,7 +979,8 @@ large for page\n"),
FATAL ((stderr,
_("user font encoding can be only the system's default or `ps'")));
- strcpy (user_font_name, token.u.font.name);
+ memset (user_font_name, 0, sizeof(user_font_name));
+ strncpy (user_font_name, token.u.font.name, sizeof(user_font_name) - 1);
user_font_pt.w = token.u.font.size.w;
user_font_pt.h = token.u.font.size.h;
user_font_encoding = token.u.font.encoding;
@@ -1444,7 +1446,7 @@ read_special_escape (InputStream *is, To
buf[i] = ch;
if (i + 1 >= sizeof (buf))
FATAL ((stderr, _("too long argument for %s escape:\n%.*s"),
- escapes[i].name, i, buf));
+ escapes[e].name, i, buf));
}
buf[i] = '\0';
@@ -1452,7 +1454,8 @@ read_special_escape (InputStream *is, To
switch (escapes[e].escape)
{
case ESC_FONT:
- strcpy (token->u.font.name, buf);
+ memset (token->u.font.name, 0, sizeof(token->u.font.name));
+ strncpy (token->u.font.name, buf, sizeof(token->u.font.name) - 1);
/* Check for the default font. */
if (strcmp (token->u.font.name, "default") == 0)
@@ -1465,7 +1468,8 @@ read_special_escape (InputStream *is, To
FATAL ((stderr, _("malformed font spec for ^@font escape: %s"),
token->u.font.name));
- strcpy (token->u.font.name, cp);
+ memset (token->u.font.name, 0, sizeof(token->u.font.name));
+ strncpy (token->u.font.name, cp, sizeof(token->u.font.name) - 1);
xfree (cp);
}
token->type = tFONT;
@@ -1544,7 +1548,8 @@ read_special_escape (InputStream *is, To
break;
case ESC_SETFILENAME:
- strcpy (token->u.filename, buf);
+ memset (token->u.filename, 0, sizeof(token->u.font.name));
+ strncpy (token->u.filename, buf, sizeof(token->u.filename) - 1);
token->type = tSETFILENAME;
break;
@@ -0,0 +1,95 @@
--- enscript-1.6.4/afm/Makefile.am.config 2003-03-05 07:26:16.000000000 +0000
+++ enscript-1.6.4/afm/Makefile.am 2005-12-23 09:56:52.000000000 +0000
@@ -36,11 +36,11 @@
EXTRA_DIST = font.map $(default_afm) $(public_fonts)
install-data-local:
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript/afm
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript/afm
for f in $(EXTRA_DIST); do \
- $(INSTALL_DATA) $(srcdir)/$$f $(datadir)/enscript/afm/$$f; \
+ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)/$(datadir)/enscript/afm/$$f; \
done
uninstall-local:
- rm -rf $(datadir)/enscript/afm
+ rm -rf $(DESTDIR)/$(datadir)/enscript/afm
--- enscript-1.6.4/afm/Makefile.in.config 2003-03-05 07:40:06.000000000 +0000
+++ enscript-1.6.4/afm/Makefile.in 2005-12-23 09:56:52.000000000 +0000
@@ -319,14 +319,14 @@
install-data-local:
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript/afm
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript/afm
for f in $(EXTRA_DIST); do \
- $(INSTALL_DATA) $(srcdir)/$$f $(datadir)/enscript/afm/$$f; \
+ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)/$(datadir)/enscript/afm/$$f; \
done
uninstall-local:
- rm -rf $(datadir)/enscript/afm
+ rm -rf $(DESTDIR)/$(datadir)/enscript/afm
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
--- enscript-1.6.4/lib/Makefile.in.config 2003-03-05 07:40:07.000000000 +0000
+++ enscript-1.6.4/lib/Makefile.in 2005-12-23 09:56:52.000000000 +0000
@@ -345,15 +345,16 @@
all-local: enscript.cfg
install-data-local: enscript.cfg
- $(top_srcdir)/mkinstalldirs $(sysconfdir)
- if test -r $(sysconfdir)/enscript.cfg; then \
- cp $(sysconfdir)/enscript.cfg $(sysconfdir)/enscript.cfg.old; \
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir)
+ if test -r $(DESTDIR)$(sysconfdir)/enscript.cfg; then \
+ cp $(DESTDIR)$(sysconfdir)/enscript.cfg \
+ $(DESTDIR)$(sysconfdir)/enscript.cfg.old; \
else :; \
fi
- $(INSTALL_DATA) enscript.cfg $(sysconfdir)/enscript.cfg
+ $(INSTALL_DATA) enscript.cfg $(DESTDIR)$(sysconfdir)/enscript.cfg
uninstall-local:
- rm -f $(sysconfdir)/enscript.cfg
+ rm -f $(DESTDIR)$(sysconfdir)/enscript.cfg
enscript.cfg: $(srcdir)/enscript.cfg.in Makefile
sed 's%@DATADIR@%$(datadir)%g; s%@media@%@MEDIA@%g; s%@BINDIR@%$(bindir)%g; s%@spooler@%@SPOOLER@%g; s%@pslevel@%@PSLEVEL@%g' \
--- enscript-1.6.4/states/hl/Makefile.am.config 2005-12-23 09:59:55.000000000 +0000
+++ enscript-1.6.4/states/hl/Makefile.am 2005-12-23 10:00:09.000000000 +0000
@@ -45,10 +45,10 @@
EXTRA_DIST = $(states)
install-data-local:
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript/hl
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript/hl
for f in $(states); do \
- $(INSTALL_DATA) $(srcdir)/$$f $(datadir)/enscript/hl/$$f; \
+ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)/$(datadir)/enscript/hl/$$f; \
done
uninstall-local:
--- enscript-1.6.4/states/hl/Makefile.in.config 2005-12-23 10:00:13.000000000 +0000
+++ enscript-1.6.4/states/hl/Makefile.in 2005-12-23 10:00:34.000000000 +0000
@@ -330,10 +330,10 @@
install-data-local:
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript
- $(top_srcdir)/mkinstalldirs $(datadir)/enscript/hl
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/enscript/hl
for f in $(states); do \
- $(INSTALL_DATA) $(srcdir)/$$f $(datadir)/enscript/hl/$$f; \
+ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)/$(datadir)/enscript/hl/$$f; \
done
uninstall-local:
@@ -0,0 +1,26 @@
--- src/main.c 2005/11/04 11:02:27 1.1
+++ src/main.c 2005/11/04 11:16:28
@@ -1695,7 +1695,7 @@ name width\theight\tllx\tlly
}
/* Table of Contents. */
- if (toc)
+ if (ofp != NULL && toc)
{
/* This is really cool... */
@@ -1714,9 +1714,11 @@ name width\theight\tllx\tlly
process_file (_("Table of Contents"), &is, 1);
is_close (&is);
}
-
- /* Clean up toc file. */
- fclose (toc_fp);
+ else
+ {
+ /* Clean up toc file. */
+ fclose (toc_fp);
+ }
}
/* Give trailer a chance to dump itself. */
@@ -0,0 +1,19 @@
--- states/hl/enscript.st.orig 2006-12-17 02:10:37.000000000 +0100
+++ states/hl/enscript.st 2006-12-17 02:10:13.000000000 +0100
@@ -489,6 +489,7 @@
/\.idl$/ idl;
/\.(hs|lhs|gs|lgs)$/ haskell;
/\.(pm|pl)$/ perl;
+ /\.(rb|rbw)$/ ruby;
/\.(eps|EPS|ps|PS)$/ postscript;
/\.py$/ python;
/\.pyx$/ pyrex;
@@ -531,6 +532,8 @@
/-\*- [Ii][Dd][Ll] -\*-/ idl;
/-\*- [Pp][Ee][Rr][Ll] -\*-/ perl;
/^#![ \t]*\/.*\/perl/ perl;
+ /-\*- [Rr][Uu][Bb][Yy] -\*-/ ruby;
+ /^#![ \t]*\/.*\/ruby/ ruby;
/^From:/ mail;
/^#![ \t]*(\/usr)?\/bin\/[ngmt]?awk/ awk;
/^#![ \t]*(\/usr)?\/bin\/sh/ sh;
+212
View File
@@ -0,0 +1,212 @@
/**
* Name: ruby
* Description: Ruby programming language.
* Author: Mike Wilson <m.v.wilson@home.com>
*/
state ruby_comment
{
/\*\\\// {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}
state ruby_dquot_string
{
/\\\\./ {
language_print ($0);
}
/\"/ {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}
state ruby_quot_string
{
/\\\\./ {
language_print ($0);
}
/[\']/ {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}
state ruby_bquot_string
{
/\\\\./ {
language_print ($0);
}
/`/ {
language_print ($0);
return;
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}
state ruby
{
BEGIN {
header ();
}
END {
trailer ();
}
/* Comments. */
/#[^{].*$/ {
comment_face (true);
language_print ($0);
comment_face (false);
}
/* Ignore escaped quote marks */
/\\\"/ {
language_print ($0);
}
/\\\'/ {
language_print ($0);
}
/\\\`/ {
language_print ($0);
}
/* In cgi files, JavaScript might be imbedded, so we need to look out
* for the JavaScript comments, because they might contain something
* we don't like, like a contraction (don't, won't, etc.)
* We won't put them in comment face, because they are not ruby
* comments.
*/
/\/\// {
language_print ($0);
call (eat_one_line);
}
/* String constants. */
/\"/ {
string_face (true);
language_print ($0);
call (ruby_dquot_string);
string_face (false);
}
/[\']/ {
string_face (true);
language_print ($0);
call (ruby_quot_string);
string_face (false);
}
/* Backquoted command string */
/`/ {
string_face (true);
language_print ($0);
call (ruby_bquot_string);
string_face (false);
}
/* Variables globals and instance */
/[$@]\w+/ {
variable_name_face (true);
language_print ($0);
variable_name_face (false);
}
/* Variables class variable */
/@@\w+/ {
variable_name_face (true);
language_print ($0);
variable_name_face (false);
}
/([ \t]*)(def)([ \t]+)([^(]*)/ {
/* indentation */
language_print ($1);
/* def */
keyword_face (true);
language_print ($2);
keyword_face (false);
/* middle */
language_print ($3);
/* Function name. */
function_name_face (true);
language_print ($4);
function_name_face (false);
}
/\$[!@&`'+~=\/\\,;.<>_*$?:"]/ {
variable_name_face (true);
language_print ($0);
variable_name_face (false);
}
/* Highlighting
--Type face
private protected public
--Builtin face (I consider these to be somewhat special)
alias alias_method attr attr_accessor attr_reader attr_writer
module_alias module_function self super
--Reference face
require include
--Keyword face
and begin break case class def defined? do else elsif end
ensure eval extend false for if in method module next nil not
or redo rescue retry return then true undef unless until when
while yield
*/
/\\b(private|protected|public)\\b/ {
type_face (true);
language_print ($0);
type_face (false);
}
/\\b(alias|alias_method|attr|attr_accessor|attr_reader|attr_writer\\
|module_alias|module_function|self|super)\\b/ {
builtin_face (true);
language_print ($0);
builtin_face (false);
}
/\\b(include|require)\\b/ {
reference_face (true);
language_print ($0);
reference_face (false);
}
/\\b(and|begin|break|case|class|def|defined?|do|else|elsif|end|ensure|eval\\
|extend|false|for|if|in|method|module|next|nil|not|or|raise|redo|rescue|retry\\
|return|then|true|undef|unless|until|when|while|yield)\\b/ {
keyword_face (true);
language_print ($0);
keyword_face (false);
}
LANGUAGE_SPECIALS {
language_print ($0);
}
}
/*
Local variables:
mode: c
End:
*/