Subject: "lpr -p wastes paper, lives" problem explained.
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: current-users
Date: 03/01/1994 23:49:40
Seeing it happen again, I finally got motivated to track down the problem.
My previous workaround was bogus, even though it worked: lpr -p -l66 does
not set the page length to 66, it overrides the -p filter with the -l filter
(heaven only knows what it was doing with the 66).
First, I thought it was the fact that lpd was overriding the paper width
setting from /etc/printcap (a rather stupid thing to do, which is fixed
like so:
static char rcsid[] = "$Id: printjob.c,v 1.2 1993/08/01 17:58:51 mycroft Exp $";
*** printjob.c.orig Tue Mar 1 23:08:50 1994
--- printjob.c Tue Mar 1 23:12:05 1994
***************
*** 266,272 ****
*/
for (i = 0; i < 4; i++)
strcpy(fonts[i], ifonts[i]);
! strcpy(width+2, "0");
strcpy(indent+2, "0");
/*
--- 266,272 ----
*/
for (i = 0; i < 4; i++)
strcpy(fonts[i], ifonts[i]);
! sprintf(&width[2], "%d", PW);
strcpy(indent+2, "0");
/*
That didn't repair it, of course. I then looked at pr, and discovered
that I'd been completely misunderstanding the error message in the log;
because -w## only has an effect when printing multicolumn output, pr
INSISTS that you not supply a -w flag if you aren't in multicolumn mode,
despite apparent historical practice. This struck me as silly, and I fixed it
so:
static char *rcsid = "$Id: pr.c,v 1.1 1994/01/06 15:57:25 cgd Exp $";
*** pr.c.orig Thu Jan 6 10:57:25 1994
--- pr.c Tue Mar 1 23:32:59 1994
***************
*** 1745,1753 ****
pgwd = SPGWD;
else
pgwd = PGWD;
- } else if (clcnt == 1) {
- (void)fputs("pr: -w requires multiple columns\n", err);
- return(1);
}
if (cflag || merge) {
if (!eflag) {
--- 1745,1750 ----
However, it is probably silly for lpd to pass a -w flag to pr at any rate,
since lpr cannot instruct lpd to ask for multicolumn mode, and it's not like
-w would do something USEFUL like wrapping lines at the given width (grr).
If anyone has a POSIX.2 spec handy, could they determine if POSIX actually
requires pr to crap out if the -w flag is given inappropriately? If it
leaves the behavior unspecified, would anyone object if I made -w actually
do something useful like wrapping the output? (Alternatively, lpd should
have that code ripped out.)
John Woods, jfw@ksr.com
------------------------------------------------------------------------------