Computer Old Farts Forum
 help / color / mirror / Atom feed
From: Larry McVoy <lm@mcvoy.com>
To: Ralph Corderoy <ralph@inputplus.co.uk>, coff@tuhs.org
Subject: [COFF] Re: On Bloat and the Idea of Small Specialized Tools
Date: Sat, 11 May 2024 14:33:51 -0700	[thread overview]
Message-ID: <20240511213351.GE9216@mcvoy.com> (raw)
In-Reply-To: <20240511211843.WS4s1gBI@steffen%sdaoden.eu>

On Sat, May 11, 2024 at 11:18:43PM +0200, Steffen Nurpmeso wrote:
> Ralph Corderoy wrote in
>  <20240511091822.B6691215AA@orac.inputplus.co.uk>:
>  |Hi Steffen,
>  |
>  |> pr has always been enscript here, for example.
>  |
>  |enscript turns text into PostScript.  That's not too handy to read.
>  |pr's output doesn't have to be sent to a printer.  I doubt there's
>  |a week goes by without my using it.  It just depends what your fingers
>  |know.
> 
> Nah, it can create text too (with control sequences, but that you
> can filter away again, and mostly there are none, anyway).
> I am actually not using it no more that often; i used it often to
> review (80 column) code via printout, and it can/could give you
> 8 pages on a single DIN A4 paper.  (Or two times 4 pages, to be
> more exact.)

Wow, that brings back memories.  Let me look.  Yeah here it is.  
Prints 8 pages per page from postscript.  Pretty sure I wrote it,
it looks like my style.  But 100% sure it was useful when my eyesight
was better :-)

#!/usr/bin/perl -w

open(STDOUT, "|mpage -a -P- -8");
# Print the starting stuff
while (<>) {
	print;
	last if /%%EndProlog/;
}

$base = "/tmp/psrev";
$page = 1;

# Save each page from 
#	%%Page to the next in a file
$_ = <>;
while ($_ && !/%%Trailer/) {
	$file = $base . $page++;
	#warn "Creating $file\n";
	open(OUT, ">$file");
	do {
		print OUT;
		$_ = <>;
	} while ($_ && !/%%Page/ && !/%%Trailer/);
	close(OUT);
}

# Take each 8 and print them in the right order
$here = 0;
while ($here < $page - 8) {
	foreach $i (2,4,6,8,1,3,5,7) {
		&show($here + $i);
	}
	$here += 8;
}

# One page left.
if ($here == $page - 2) {
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
}
# Two pages left
if ($here == $page - 3) {
	&show($here + 2);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
}
# Three pages left
if ($here == $page - 4) {
	&show($here + 2);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
	&show($here + 3);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
}
# Four pages left
if ($here == $page - 5) {
	&show($here + 2);
	&show($here + 4);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
	&show($here + 3);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
}
# Five pages left
if ($here == $page - 6) {
	&show($here + 2);
	&show($here + 4);
	print "%%Page: 0 0\nshowpage\n";
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
	&show($here + 3);
	&show($here + 5);
	print "%%Page: 0 0\nshowpage\n";
}
# Six pages left
if ($here == $page - 7) {
	&show($here + 2);
	&show($here + 4);
	&show($here + 6);
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
	&show($here + 3);
	&show($here + 5);
	print "%%Page: 0 0\nshowpage\n";
}
# Seven pages left
# foreach $i (2,4,6,8,1,3,5,7) {
if ($here == $page - 8) {
	&show($here + 2);
	&show($here + 4);
	&show($here + 6);
	print "%%Page: 0 0\nshowpage\n";
	&show($here + 1);
	&show($here + 3);
	&show($here + 5);
	&show($here + 7);
}

if ($_) {
	do {
		print;
	} while (defined($_ = <>));
}
exit;


sub show
{
	local($p) = $_[0];

	$file = $base . $p;
	if (-e $file) {
		#warn "Doing $file\n";
		open(IN, $file);
		while (defined($line = <IN>)) {
			print $line;
		}
		unlink($file);
	}
}

  reply	other threads:[~2024-05-11 21:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 16:36 [COFF] " Clem Cole
2024-05-10 23:02 ` [COFF] Re: [TUHS] " Steffen Nurpmeso
2024-05-11  9:18   ` [COFF] " Ralph Corderoy
2024-05-11 21:18     ` Steffen Nurpmeso
2024-05-11 21:33       ` Larry McVoy [this message]
2024-05-10 23:22 ` [COFF] Re: [TUHS] " Nevin Liber
2024-05-11  9:31   ` [COFF] " Ralph Corderoy
2024-05-11 12:51   ` [COFF] Re: [TUHS] " John P. Linderman
2024-05-11 13:12   ` Dan Cross
2024-05-11 14:41     ` Bakul Shah via COFF
2024-05-11 15:45     ` Grant Taylor via COFF
2024-05-11 17:18       ` [COFF] " Ralph Corderoy
2024-05-11 21:35     ` [COFF] Re: [TUHS] " Theodore Ts'o
2024-05-12  7:13       ` Gergely Buday
2024-05-12  7:29       ` [COFF] " Ralph Corderoy
2024-05-12 22:23         ` Dave Horsfall
2024-05-11 19:24   ` [COFF] Re: [TUHS] " Clem Cole
2024-05-13  6:20   ` [COFF] " Arno Griffioen via COFF

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240511213351.GE9216@mcvoy.com \
    --to=lm@mcvoy.com \
    --cc=coff@tuhs.org \
    --cc=ralph@inputplus.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).