home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
11415
< prev
next >
Wrap
Text File
|
1994-11-01
|
16KB
|
607 lines
Newsgroups: alt.sources
From: zondo@hunting2.demon.co.uk (Zondo Pillock)
Path: wupost!sdd.hp.com!hpscit.sc.hp.com!news.dtc.hp.com!col.hp.com!csn!magnus.acs.ohio-state.edu!math.ohio-state.edu!caen!zip.eecs.umich.edu!panix!news.mathworks.com!udel!news.sprintlink.net!demon!hunting2.demon.co.uk!zondo
Subject: a4-a5 v1.1 (bugfix release)
Organization: Hunting Engineering Limited
Reply-To: zondo@hunting2.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.29
Lines: 594
Date: Mon, 31 Oct 1994 09:18:20 +0000
Message-ID: <783595100snz@hunting2.demon.co.uk>
Sender: usenet@demon.co.uk
This is a shell archive of a4-a5, version 1.1.
a4-a5 is a perl script which converts A4 PostScript files to A5, by
printing two pages per output page alongside each other.
This is a bug fix release: options now work properly, and there's a
usage message with invalid options.
To install: hack the customization section of the Makefile, and just
type 'make install'.
Save a tree today! Print those massive manuals with a4-a5!
__o
zondo@hunting2.demon.co.uk _`\<,_
............................(_)/ (_)
Submitted-by: zondo@hunting2.demon.co.uk
Archive-name: a4-a5/part01
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is a4-a5, a shell archive (produced by GNU shar 4.0)
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1994-10-31 09:03 GMT by <zondo@hunting2.demon.co.uk>.
# Source directory was `/work/utils/printing/a4-a5'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1091 -rw-r--r-- README
# 1515 -rw-r--r-- Makefile
# 3085 -r--r--r-- a4-a5.pl
# 1477 -r--r--r-- a4-a5.ps
# 1857 -r--r--r-- a4-a5.doc
# 1481 -rw-rw-r-- a4-a5.man
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo 'WARNING: not restoring timestamps'
fi
rm -f 1231235999 $$.touch
#
# ============= README ==============
if test -f 'README' && test X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
else
echo 'x - extracting README (text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
This is a4-a5, version 1.1.
X
a4-a5 is a perl script which converts A4 PostScript files to A5, by
printing two pages per output page alongside each other.
X
This is a bug fix release: options now work properly, and there's a
usage message with invalid options.
X
To install: hack the customization section of the Makefile, and just
type 'make install'.
X
It works on most of the PostScript files I've tried it on, with the
exception of files produced by FrameMaker - the first page screws up
for some weird reason. And, to get it to work on psroff output, I had
to undefine the save/restore commands, so PostScript files that rely
on save/restore may screw up bad. Best to check things out with a
previewer to be sure. If any PostScript boffin out there can tell me
why (or even better, give me a fix) I'd be well chuffed.
X
Save a tree today! Print those massive manuals with a4-a5!
X
X
X __o
X zondo@hunting2.demon.co.uk _`\<,_
X ............................(_)/ (_)
X
X
SHAR_EOF
$shar_touch -am 1031085694 'README' &&
chmod 0644 'README' ||
echo 'restore of README failed'
shar_count="`wc -c < 'README'`"
test 1091 -eq "$shar_count" ||
echo "README: original size 1091, current size $shar_count"
fi
# ============= Makefile ==============
if test -f 'Makefile' && test X"$1" != X"-c"; then
echo 'x - skipping Makefile (File already exists)'
else
echo 'x - extracting Makefile (text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
# ---------------- Makefile for a4-a5 PostScript converter --------------
X
# ------------------------- Customization section -----------------------
X
# Where to put the program
BINDIR = /work/bin
X
# Where to put the man page
MANDIR = /work/man/man1
X
# Where to put the PostScript header file
LIBDIR = /netdat/lib
X
# Pathname of your perl executable
PERL = /work/bin/perl
X
# ---------------------- End of customization section -------------------
X
CONFIG = sed -e 's^%%LIBDIR%%^$(LIBDIR)^' \
X -e 's^%%PERL%%^$(PERL)^'
X
install: a4-a5 a4-a5.ps a4-a5.1
X install -c -m 755 a4-a5 $(BINDIR)
X install -c -m 644 a4-a5.ps $(LIBDIR)
X install -c -m 644 a4-a5.1 $(MANDIR)
X
a4-a5: a4-a5.pl
X $(CONFIG) a4-a5.pl > a4-a5
X
a4-a5.1: a4-a5.man
X $(CONFIG) a4-a5.man > a4-a5.1
X
a4-a5.man: a4-a5.doc
X srctoman - a4-a5.doc > a4-a5.man
X
clean:; rm -f a4-a5 a4-a5.1 *.a5 *.orig
X
# ---------------------------- Distribution -----------------------------
X
NETNAME = zondo@hunting2.demon.co.uk
X
SHARDIR = /work/pc
SHARNAME = ashar
SHAROPTS = -n a4-a5 -o $(SHARNAME) -l 50 -s $(NETNAME) -acT
SHAR = README Makefile a4-a5.pl a4-a5.ps a4-a5.doc a4-a5.man
X
shar: $(SHAR) SHAR
X shar $(SHAROPTS) $(SHAR)
X for i in $(SHARNAME)*; do \
X cat SHAR $$i > $(SHARDIR)/$$i; \
X rm $$i; \
X done
X
# ----------------------------- Test stuff ------------------------------
X
X.SUFFIXES: .ps .a5 .orig .diff
X
X.ps.a5:; perl a4-a5.pl -h a4-a5.ps -o $*.a5 $*.ps
X
X.a5.orig:; perl a4-a5.pl -r -o $*.orig $*.a5
X
X.orig.diff:; diff $*.ps $*.orig
SHAR_EOF
$shar_touch -am 1027092594 'Makefile' &&
chmod 0644 'Makefile' ||
echo 'restore of Makefile failed'
shar_count="`wc -c < 'Makefile'`"
test 1515 -eq "$shar_count" ||
echo "Makefile: original size 1515, current size $shar_count"
fi
# ============= a4-a5.pl ==============
if test -f 'a4-a5.pl' && test X"$1" != X"-c"; then
echo 'x - skipping a4-a5.pl (File already exists)'
else
echo 'x - extracting a4-a5.pl (text)'
sed 's/^X//' << 'SHAR_EOF' > 'a4-a5.pl' &&
#!%%PERL%%
X
# PostScript A4-A5 converter (by G.Hutchings)
X
# $Id: a4-a5.pl,v 1.5 1994/10/31 09:02:59 glen Exp $
X
require "getopts.pl";
X
# Version
$version = "1.1";
X
# Parse arguments
&usage if !&Getopts('o:h:frv');
X
if (defined ($opt_v)) {
X print "a4-a5 version $version, (C) G. Hutchings 1994\n";
X exit 0;
}
X
if (defined ($opt_o)) {
X open(OUT, ">" . $opt_o) || die "$0: Error: can't open $opt_o: $!\n";
X $out = OUT;
} else {
X $out = STDOUT;
}
X
$header = "%%LIBDIR%%/a4-a5.ps";
$header = $opt_h if (defined ($opt_h));
X
# Get list of input files
@list = @ARGV;
if ($list[0] eq '') {
X $files = "<stdin>";
} else {
X do {
X $files = $files . $list[0];
X shift @list;
X } until ($list[0] eq '');
}
X
# Do what's requested
if (!defined($opt_r)) {
X &convert;
} else {
X &unconvert;
}
X
Xexit 0;
X
# Convert from a4 to a5
sub convert {
X $pages = 0;
X chop ($date = `date`);
X chop ($user = `whoami`);
X chop ($host = `hostname`);
X
X # Write header
X print $out "%!PS-Adobe-1.0\n";
X print $out "%%Title: $files converted to a5 format\n";
X print $out "%%Creator: a4-a5 ($user@$host)\n";
X print $out "%%CreationDate: $date\n";
X print $out "%%Pages: (atend)\n";
X print $out "%%EndComments\n";
X
X open (HDR, $header) || die "$0: Error: can't open $header: $!\n";
X print $out $_ while (<HDR>);
X close HDR;
X
X print $out "%%EndProlog\n";
X
X # Process input
X while (<>) {
X # Check first line for PostScript
X if ($. == 1) {
X if (!/^%!/ && !defined($opt_f)) {
X die "$0: Error: input doesn't look like PostScript\n";
X }
X }
X
X # Write page numbers if possible
X if (/^%%Page:.*([0-9]+)/) {
X if ($1 % 2 != 0) {
X $pages++;
X print $out "%%Page: $pages\n";
X }
X }
X
X # Print trailer
X print $out "%%Trailer\n" if (/^%%Trailer/);
X
X # Print no. of pages if known
X print $out "%%Pages: $pages\n" if (/^%%Pages:.*[0-9]+/);
X
X # Comment out all document formatting stuff
X print $out "%|" if (/^%%/);
X
X # Echo line
X print $out $_;
X }
X
X # Finish up
X print $out "a5finish\n";
}
X
# Reverse the a4-a5 operation
sub unconvert {
X $body = 0;
X while (<>) {
X # Check first line for PostScript
X if ($. == 1) {
X die "$0: Error: input doesn't look like PostScript\n" if (!/^%!/);
X }
X
X # Check second line for a4-a5 title
X if ($. == 2) {
X if (!/converted to a5/) {
X die "$0: Error: input hasn't been converted to a5 format\n";
X }
X }
X
X # Skip header
X if ($body == 0) {
X $body = 1 if (/^%%EndProlog/);
X next;
X }
X
X # Rip out document formatting comments
X next if (/^%%/);
X
X # De-comment the original ones
X $_ = $1 . "\n" if (/^%\|(%%.*)/);
X
X # Remove last line
X next if (/^a5finish/);
X
X # Echo input
X print $out $_;
X }
}
X
# Give a usage message and exit
sub usage {
X print STDERR "Usage: a4-a5 [options] [file...]\n\n";
X print STDERR "-o file write to specified file\n";
X print STDERR "-f force processing\n";
X print STDERR "-r reverse operation\n";
X print STDERR "-h file use alternate header file\n";
X print STDERR "-v print program version\n";
X exit 1;
}
SHAR_EOF
$shar_touch -am 1031090394 'a4-a5.pl' &&
chmod 0444 'a4-a5.pl' ||
echo 'restore of a4-a5.pl failed'
shar_count="`wc -c < 'a4-a5.pl'`"
test 3085 -eq "$shar_count" ||
echo "a4-a5.pl: original size 3085, current size $shar_count"
fi
# ============= a4-a5.ps ==============
if test -f 'a4-a5.ps' && test X"$1" != X"-c"; then
echo 'x - skipping a4-a5.ps (File already exists)'
else
echo 'x - extracting a4-a5.ps (text)'
sed 's/^X//' << 'SHAR_EOF' > 'a4-a5.ps' &&
% PostScript header for A4-A5 converter (by G.Hutchings)
X
% $Id: a4-a5.ps,v 1.3 1994/09/12 10:29:01 glen Exp $
X
% Debugging stuff
/debug false def
X
/msg { % MESSAGE msg --> -
X debug { print (\n) print } { pop } ifelse
} bind def
X
/val { % MESSAGE VAR val --> -
X debug { exch print == } { pop pop } ifelse
} bind def
X
% Setup
/inch { 72 mul } def
/a4-page-width 8.3 inch def
/a4-page-height 11.7 inch def
/a5-scale-factor a4-page-width a4-page-height div def
/do-showpage false def
X
% Undefine save/restore (this gets output from psroff to work, but why
% do I have to do this?)
/really-save /save load def
/really-restore /restore load def
/save { mark } def
/restore { pop } def
X
% Save old showpage and define new one
/really-showpage /showpage load def
X
/showpage {
X grestore
X do-showpage {
X (Flushing page...) msg
X really-showpage
X a5first
X /do-showpage false def
X }{
X a5second
X /do-showpage true def
X } ifelse
} bind def
X
% Translate to first a5 page
/a5first {
X (Starting first A5 page...) msg
X gsave
X a4-page-width 0 translate
X a5-scale-factor dup scale
X 90 rotate
} bind def
X
% Translate to second a5 page
/a5second {
X (Starting second A5 page...) msg
X gsave
X a4-page-width a4-page-height 2 div translate
X a5-scale-factor dup scale
X 90 rotate
} bind def
X
% Finish processing
/a5finish {
X (Finishing up...) msg
X grestore
X do-showpage { really-showpage } if
} bind def
X
% Start everything off
a5first
SHAR_EOF
$shar_touch -am 0912112994 'a4-a5.ps' &&
chmod 0444 'a4-a5.ps' ||
echo 'restore of a4-a5.ps failed'
shar_count="`wc -c < 'a4-a5.ps'`"
test 1477 -eq "$shar_count" ||
echo "a4-a5.ps: original size 1477, current size $shar_count"
fi
# ============= a4-a5.doc ==============
if test -f 'a4-a5.doc' && test X"$1" != X"-c"; then
echo 'x - skipping a4-a5.doc (File already exists)'
else
echo 'x - extracting a4-a5.doc (text)'
sed 's/^X//' << 'SHAR_EOF' > 'a4-a5.doc' &&
#++
# NAME
# a4-a5 1
# SUMMARY
# convert PostScript from A4 to A5
# SYNOPSIS
# a4-a5 [-rfv] [-o outfile] [-h header] files...
# DESCRIPTION
# .I a4-a5
# converts A4 PostScript files to A5 format, so that each A4
# output page contains two input pages side by side. If no
# files are specified,
# .I a4-a5
# takes input from stdin.
# OPTIONS
# .fi
# .TP 8
# .I -o outfile
# Write output to
# .I outfile
# instead of stdout.
# .TP
# .I -f
# Normally,
# .I a4-a5
# barfs on input that doesn't look like PostScript. This forces
# processing of the input in such a case.
# .TP
# .I -r
# Reverse the conversion. Assume that the input has been
# converted by
# .I a4-a5
# and reconstruct the original file.
# .TP
# .I -h header
# Use the specified header file instead of the default one. For
# those special customization moments.
# .TP
# .I -v
# Print program version.
# RESTRICTIONS
# .fi
# .I
# a4-a5
# attempts to deal with special PostScript document formatting
# comments, where present, and produce output that adheres to
# them. It's possible that files with weird comments can
# confuse it.
# BUGS
# .fi
# The first page screws up for some reason when trying to deal
# with files produced by FrameMaker. Also, to deal properly
# with
# .I psroff
# output, the save/restore commands have been disabled.
# PostScript input which relies on this construct will probably
# screw up.
# FILES
# .TS
# tab(@);
# l l .
# %%LIBDIR%%/a4-a5.ps@Standard header file
# .TE
# AUTHOR
# Glenn Hutchings (zondo@hunting2.demon.co.uk)
#--
SHAR_EOF
$shar_touch -am 1031090294 'a4-a5.doc' &&
chmod 0444 'a4-a5.doc' ||
echo 'restore of a4-a5.doc failed'
shar_count="`wc -c < 'a4-a5.doc'`"
test 1857 -eq "$shar_count" ||
echo "a4-a5.doc: original size 1857, current size $shar_count"
fi
# ============= a4-a5.man ==============
if test -f 'a4-a5.man' && test X"$1" != X"-c"; then
echo 'x - skipping a4-a5.man (File already exists)'
else
echo 'x - extracting a4-a5.man (text)'
sed 's/^X//' << 'SHAR_EOF' > 'a4-a5.man' &&
X.TH A4-A5 1
X.fi
X.SH NAME
a4-a5
\-
convert PostScript from A4 to A5
X.SH SYNOPSIS
X.na
X.nf
a4-a5 [-rfv] [-o outfile] [-h header] files...
X.SH DESCRIPTION
X.fi
X.I a4-a5
converts A4 PostScript files to A5 format, so that each A4
output page contains two input pages side by side. If no
files are specified,
X.I a4-a5
takes input from stdin.
X.SH OPTIONS
X.na
X.nf
X.fi
X.TP 8
X.I -o outfile
Write output to
X.I outfile
instead of stdout.
X.TP
X.I -f
Normally,
X.I a4-a5
barfs on input that doesn't look like PostScript. This forces
processing of the input in such a case.
X.TP
X.I -r
Reverse the conversion. Assume that the input has been
converted by
X.I a4-a5
and reconstruct the original file.
X.TP
X.I -h header
Use the specified header file instead of the default one. For
those special customization moments.
X.TP
X.I -v
Print program version.
X.SH RESTRICTIONS
X.na
X.nf
X.fi
X.I
a4-a5
attempts to deal with special PostScript document formatting
comments, where present, and produce output that adheres to
them. It's possible that files with weird comments can
confuse it.
X.SH BUGS
X.fi
X.fi
The first page screws up for some reason when trying to deal
with files produced by FrameMaker. Also, to deal properly
with
X.I psroff
output, the save/restore commands have been disabled.
PostScript input which relies on this construct will probably
screw up.
X.SH FILES
X.na
X.nf
X.TS
tab(@);
l l .
%%LIBDIR%%/a4-a5.ps@Standard header file
X.TE
X.SH AUTHOR
X.na
X.nf
Glenn Hutchings (zondo@hunting2.demon.co.uk)
SHAR_EOF
$shar_touch -am 1031090294 'a4-a5.man' &&
chmod 0664 'a4-a5.man' ||
echo 'restore of a4-a5.man failed'
shar_count="`wc -c < 'a4-a5.man'`"
test 1481 -eq "$shar_count" ||
echo "a4-a5.man: original size 1481, current size $shar_count"
fi
exit 0
--