File source-psutils.dif of Package texlive
--- utils/psutils/Makefile.unix
+++ utils/psutils/Makefile.unix 2008-03-04 17:31:25.000000000 +0000
@@ -25,10 +25,10 @@ PAPER=a4
OS = UNIX
-BINDIR = /usr/local/bin
+BINDIR = /usr/bin
SCRIPTDIR = $(BINDIR)
-INCLUDEDIR = /usr/local/share/psutils
-PERL = /usr/local/bin/perl
+INCLUDEDIR = /usr/share/psutils
+PERL = /usr/bin/perl
BINMODE = 0755
MANMODE = 0644
@@ -36,9 +36,10 @@ CHMOD = chmod
INSTALL = install -c -m $(BINMODE)
INSTALLMAN = install -c -m $(MANMODE)
MANEXT = 1
-MANDIR = /usr/local/share/man/man$(MANEXT)
+MANDIR = /usr/share/man/man$(MANEXT)
-CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX -O
+CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX $(RPM_OPT_FLAGS) -pipe -Wall
+CCFLAGS = $(CFLAGS)
BIN = psbook psselect pstops epsffit psnup \
psresize
--- utils/psutils/epsffit.c
+++ utils/psutils/epsffit.c 2008-03-04 17:27:59.000000000 +0000
@@ -40,15 +40,15 @@ static void usage(void)
exit(1);
}
-void main(int argc, char **argv)
+int main(int argc, char **argv)
{
int bbfound = 0; /* %%BoundingBox: found */
- int urx, ury, llx, lly;
+ int urx = 0, ury = 0, llx = 0, lly = 0;
int furx, fury, fllx, flly;
int showpage = 0, centre = 0, rotate = 0, aspect = 0, maximise = 0;
char buf[BUFSIZ];
- FILE *input;
- FILE *output;
+ FILE *input = stdin;
+ FILE *output = stdout;
program = *argv++; argc--;
@@ -164,9 +164,14 @@ void main(int argc, char **argv)
yoffset -= lly * yscale;
}
fputs("%%EndComments\n", output);
- if (showpage)
- fputs("save /showpage{}def /copypage{}def /erasepage{}def\n", output);
- else
+ if (showpage) {
+ fputs("/startEpsffit {\n", output);
+ fputs(" /EpsffitSave {save} def\n", output);
+ fputs(" userdict 200 dict begin\n", output);
+ fputs(" /showpage{}def /copypage{}def /erasepage{}def\n", output);
+ fputs("}def\n", output);
+ fputs("startEpsffit\n", output);
+ } else
fputs("%%BeginProcSet: epsffit 1 0\n", output);
fputs("gsave\n", output);
fprintf(output, "%.3f %.3f translate\n", xoffset, yoffset);
@@ -182,7 +187,7 @@ void main(int argc, char **argv)
if (bbfound) {
fputs("grestore\n", output);
if (showpage)
- fputs("restore showpage\n", output); /* just in case */
+ fputs("end EpsffitSave restore showpage\n", output); /* just in case */
} else
message(FATAL, "no %%%%BoundingBox:\n");
--- utils/psutils/getafm.sh
+++ utils/psutils/getafm.sh 2008-03-04 17:27:59.000000000 +0000
@@ -1,7 +1,7 @@
#!/bin/sh
if [ $# -ne 1 ]; then
- echo "usage: $0 font-name | gsnd - >font-name.afm" >&2
+ echo "usage: $0 font-name | gsnd -q - >font-name.afm" >&2
exit 1
fi
@@ -66,8 +66,9 @@ cat << EOF
(isFixedPitch)(IsFixedPitch) prany
(UnderlinePosition)dup prany
(UnderlineThickness)dup prany
- (Version)(version) prany
+ (version)(Version) prany
(Notice)dup prany
+ (Copyright)dup prany
pop
}
{
--- utils/psutils/fixmacps.pl
+++ utils/psutils/fixmacps.pl 2008-03-06 16:17:27.000000000 +0000
@@ -5,7 +5,7 @@
# See file LICENSE for details.
$line = 0; # keep line count
-$predir = `kpsewhich -progname=psutils md71_0.ps`;
+$predir = `kpsewhich --progname=dvips/psutils --format='other text files' md71_0.ps`;
$dir=`basename $predir`;
$prefix = "md";
$default = "md71_0.ps";
--- utils/psutils/psbook.c
+++ utils/psutils/psbook.c 2008-03-04 17:27:59.000000000 +0000
@@ -32,7 +32,7 @@ static void usage(void)
}
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
int signature = 0;
int currentpg, maxpage;
--- utils/psutils/pserror.c
+++ utils/psutils/pserror.c 2008-03-04 17:27:55.000000000 +0000
@@ -17,16 +17,17 @@ extern char *program ; /* Defined by mai
warnings, and errors sent to stderr. If called with the flags MESSAGE_EXIT
set, the routine does not return */
-#define MAX_MESSAGE 256 /* maximum formatted message length */
+#define MAX_MESSAGE 1024 /* maximum formatted message length */
#define MAX_FORMAT 16 /* maximum format length */
#define MAX_COLUMN 78 /* maximum column to print upto */
void message(int flags, char *format, ...)
{
va_list args ;
- static column = 0 ; /* current screen column for message wrap */
- char msgbuf[MAX_MESSAGE] ; /* buffer in which to put the message */
- char *bufptr = msgbuf ; /* message buffer pointer */
+ static int column = 0 ; /* current screen column for message wrap */
+ char msgbuf[MAX_MESSAGE]; /* buffer in which to put the message */
+ char *bufptr = msgbuf; /* message buffer pointer */
+ char *tail = bufptr + MAX_MESSAGE;
if ( (flags & MESSAGE_NL) && column != 0 ) { /* new line if not already */
putc('\n', stderr) ;
@@ -34,8 +35,11 @@ void message(int flags, char *format, ..
}
if ( flags & MESSAGE_PROGRAM ) {
+ const size_t len = strlen(program);
+ if (len + 2 >= tail - bufptr)
+ goto out;
strcpy(bufptr, program) ;
- bufptr += strlen(program) ;
+ bufptr += len;
*bufptr++ = ':' ;
*bufptr++ = ' ' ;
}
@@ -55,13 +59,15 @@ void message(int flags, char *format, ..
fmtbuf[index] = '\0' ;
switch (c) {
case '%':
+ if (bufptr >= tail)
+ goto out;
*bufptr++ = '%' ;
case '\0':
break ;
case 'e': case 'E': case 'f': case 'g': case 'G':
{
double d = va_arg(args, double) ;
- sprintf(bufptr, fmtbuf, d) ;
+ snprintf(bufptr, tail - bufptr, fmtbuf, d);
bufptr += strlen(bufptr) ;
}
break ;
@@ -69,17 +75,17 @@ void message(int flags, char *format, ..
case 'p': case 'u': case 'x': case 'X':
if ( longform ) {
long l = va_arg(args, long) ;
- sprintf(bufptr, fmtbuf, l) ;
+ snprintf(bufptr, tail - bufptr, fmtbuf, l);
} else {
int i = va_arg(args, int) ;
- sprintf(bufptr, fmtbuf, i) ;
+ snprintf(bufptr, tail - bufptr, fmtbuf, i);
}
bufptr += strlen(bufptr) ;
break ;
case 's':
{
char *s = va_arg(args, char *) ;
- sprintf(bufptr, fmtbuf, s) ;
+ snprintf(bufptr, tail - bufptr, fmtbuf, s);
bufptr += strlen(bufptr) ;
}
break ;
@@ -92,6 +98,8 @@ void message(int flags, char *format, ..
} while ( !done ) ;
} else if ( c == '\n' ) { /* write out message so far and reset column */
int len = bufptr - msgbuf ; /* length of current message */
+ if (bufptr >= tail)
+ goto out;
*bufptr++ = '\n' ;
*bufptr = '\0' ;
if ( column + len > MAX_COLUMN && column > 0 ) {
@@ -100,8 +108,11 @@ void message(int flags, char *format, ..
}
fputs(bufptr = msgbuf, stderr) ;
column = 0 ;
- } else
+ } else {
+ if (bufptr >= tail)
+ goto out;
*bufptr++ = c ;
+ }
}
*bufptr = '\0' ;
{
@@ -117,6 +128,7 @@ void message(int flags, char *format, ..
}
va_end(args) ;
- if ( flags & MESSAGE_EXIT ) /* don't return to program */
+out:
+ if (flags & MESSAGE_EXIT) /* don't return to program */
exit(1) ;
}
--- utils/psutils/psmerge.man
+++ utils/psutils/psmerge.man 2008-03-04 17:27:59.000000000 +0000
@@ -24,6 +24,26 @@ standard output.
.I Psmerge
will merge multiple files concatenated into a single file as if they
were in separate files.
+.SH BUGS
+.I psmerge
+is for a very specific case; it does not merge files in the general case.
+.br
+For all those cases which can not be handled by
+.I psmerge
+the program
+.I gs
+(known as ghostscript) may help:
+
+.sp 1
+.in +1c
+.nf
+ gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=out.ps \\
+ file1.ps file2.ps ... -c quit
+.fi
+.in -1c
+.sp 1
+
+This is rather slow and generates bigger output files.
.SH AUTHOR
Copyright (C) Angus J. C. Duggan 1991-1995
.SH "SEE ALSO"
@@ -31,6 +51,3 @@ Copyright (C) Angus J. C. Duggan 1991-19
.SH TRADEMARKS
.B PostScript
is a trademark of Adobe Systems Incorporated.
-.SH BUGS
-.I psmerge
-is for a very specific case; it does not merge files in the general case.
--- utils/psutils/psnup.c
+++ utils/psutils/psnup.c 2008-03-04 17:27:59.000000000 +0000
@@ -66,12 +66,12 @@ static int nextdiv(int n, int m)
return (0);
}
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
- int horiz, vert, rotate, column, flip, leftright, topbottom;
+ int horiz = 0, vert = 0, rotate = 0, column, flip, leftright, topbottom;
int nup = 1;
double draw = 0; /* draw page borders */
- double scale; /* page scale */
+ double scale = 0; /* page scale */
double uscale = 0; /* user supplied scale */
double ppwid, pphgt; /* paper dimensions */
double margin, border; /* paper & page margins */
--- utils/psutils/psresize.c
+++ utils/psutils/psresize.c 2008-03-04 17:27:59.000000000 +0000
@@ -46,7 +46,7 @@ static void argerror(void)
#define MIN(x,y) ((x) > (y) ? (y) : (x))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
double scale, rscale; /* page scale */
double waste, rwaste; /* amount wasted */
--- utils/psutils/psselect.c
+++ utils/psutils/psselect.c 2008-03-04 17:27:59.000000000 +0000
@@ -52,6 +52,9 @@ static PageRange *addrange(char *str, Pa
{
int first=0;
int sign;
+
+ if(!str) return NULL;
+
sign = (*str == '_' && ++str) ? -1 : 1;
if (isdigit(*str)) {
first = sign*atoi(str);
@@ -91,7 +94,7 @@ static PageRange *addrange(char *str, Pa
}
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
int currentpg, maxpage = 0;
int even = 0, odd = 0, reverse = 0;
--- utils/psutils/psspec.c
+++ utils/psutils/psspec.c 2008-03-04 17:27:59.000000000 +0000
@@ -12,6 +12,9 @@
#include <string.h>
+/* #define SHOWPAGE_LOAD 1 */
+#undef SHOWPAGE_LOAD
+
double width = -1;
double height = -1;
--- utils/psutils/pstops.c
+++ utils/psutils/pstops.c 2008-03-04 17:27:59.000000000 +0000
@@ -120,7 +120,7 @@ static PageSpec *parsespecs(char *str)
return (head);
}
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
PageSpec *specs = NULL;
int nobinding = 0;
--- utils/psutils/pstops.man
+++ utils/psutils/pstops.man 2008-03-04 17:27:59.000000000 +0000
@@ -86,7 +86,7 @@ the document, instead of the start.
If page \fIspec\fRs are separated by
.B \+
the pages will be merged into one page; if they are separated by
-.B \,
+.B ,
they will be on separate pages.
If there is only one page specification, with
.I pageno
--- utils/psutils/psutil.c
+++ utils/psutils/psutil.c 2008-03-04 17:29:29.000000000 +0000
@@ -44,14 +44,45 @@ static long *pageptr;
/* list of paper sizes supported */
static Paper papersizes[] = {
- { "a3", 842, 1191 }, /* 29.7cm * 42cm */
- { "a4", 595, 842 }, /* 21cm * 29.7cm */
- { "a5", 421, 595 }, /* 14.85cm * 21cm */
- { "b5", 516, 729 }, /* 18.2cm * 25.72cm */
- { "A3", 842, 1191 }, /* 29.7cm * 42cm */
- { "A4", 595, 842 }, /* 21cm * 29.7cm */
- { "A5", 421, 595 }, /* 14.85cm * 21cm */
- { "B5", 516, 729 }, /* 18.2cm * 25.72cm */
+ { "a0", 2384, 3370 },
+ { "a1", 1684, 2384 },
+ { "a2", 1191, 1684 },
+ { "a3", 842, 1191 }, /* 29.7cm * 42cm */
+ { "a4", 595, 842 }, /* 21cm * 29.7cm */
+ { "a5", 421, 595 }, /* 14.85cm * 21cm */
+ { "a6", 297, 420 },
+ { "a7", 210, 297 },
+ { "a8", 148, 210 },
+ { "a9", 105, 148 },
+ { "a10", 73, 105 },
+ { "isob0", 2835, 4008 },
+ { "b0", 2835, 4008 },
+ { "isob1", 2004, 2835 },
+ { "b1", 2004, 2835 },
+ { "isob2", 1417, 2004 },
+ { "b2", 1417, 2004 },
+ { "isob3", 1001, 1417 },
+ { "b3", 1001, 1417 },
+ { "isob4", 709, 1001 },
+ { "b4", 709, 1001 },
+ { "isob5", 499, 709 },
+ { "b5", 499, 709 },
+ { "isob6", 354, 499 },
+ { "b6", 354, 499 },
+ { "jisb0", 2920, 4127 },
+ { "jisb1", 2064, 2920 },
+ { "jisb2", 1460, 2064 },
+ { "jisb3", 1032, 1460 },
+ { "jisb4", 729, 1032 },
+ { "jisb5", 516, 729 },
+ { "jisb6", 363, 516 },
+ { "c0", 2599, 3677 },
+ { "c1", 1837, 2599 },
+ { "c2", 1298, 1837 },
+ { "c3", 918, 1298 },
+ { "c4", 649, 918 },
+ { "c5", 459, 649 },
+ { "c6", 323, 459 },
{ "letter", 612, 792 }, /* 8.5in * 11in */
{ "legal", 612, 1008 }, /* 8.5in * 14in */
{ "ledger", 1224, 792 }, /* 17in * 11in */
@@ -61,6 +92,14 @@ static Paper papersizes[] = {
{ "folio", 612, 936 }, /* 8.5in * 13in */
{ "quarto", 610, 780 }, /* 8.5in * 10.83in */
{ "10x14", 720, 1008 }, /* 10in * 14in */
+ { "archE", 2592, 3456 },
+ { "archD", 1728, 2592 },
+ { "archC", 1296, 1728 },
+ { "archB", 864, 1296 },
+ { "archA", 648, 864 },
+ { "flsa", 612, 936 }, /* U.S. foolscap */
+ { "flse", 612, 936 }, /* European foolscap */
+ { "halfletter", 396, 612 },
{ NULL, 0, 0 }
};
@@ -69,7 +108,7 @@ Paper* findpaper(char *name)
{
Paper *pp;
for (pp = papersizes; PaperName(pp); pp++) {
- if (strcmp(PaperName(pp), name) == 0) {
+ if (strncasecmp(PaperName(pp), name, strlen(PaperName(pp))) == 0) {
return pp;
}
}
@@ -88,16 +127,15 @@ FILE *seekable(FILE *fp)
#if defined(WINNT) || defined(WIN32)
struct _stat fs ;
#else
- long fpos;
+ struct stat fs;
#endif
#if defined(WINNT) || defined(WIN32)
if (_fstat(fileno(fp), &fs) == 0 && (fs.st_mode&_S_IFREG) != 0)
return (fp);
#else
- if ((fpos = ftell(fp)) >= 0)
- if (!fseek(fp, 0L, SEEK_END) && !fseek(fp, fpos, SEEK_SET))
- return (fp);
+ if (fstat(fileno(fp), &fs) == 0 && S_ISREG(fs.st_mode))
+ return (fp);
#endif
#if defined(MSDOS)