a summary of bugs in lpd.c on 4.1

utzoo!decvax!microsof!uw-beave!jim utzoo!decvax!microsof!uw-beave!jim
Thu Dec 30 10:40:38 AEST 1982


While we are on the subject of line printers ...

A lot of people seem to be using Printronix printers, and the standard
lpf doesn't handle underlining or plot mode correctly for a Printronix.
Here is my diff listing to lpf.c to make them work.

*** lpf.c_o	Tue Sep 15 08:02:34 1981
--- lpf.c	Tue Sep  7 16:44:43 1982
***************
*** 1,6
  static	char *sccsid = "@(#)lpf.c	4.5 (Berkeley) 81/06/10";
  /*
   * lpf -- Line printer filter
   */
  
  #include <stdio.h>

--- 1,11 -----
  static	char *sccsid = "@(#)lpf.c	4.5 (Berkeley) 81/06/10";
  /*
   * lpf -- Line printer filter
+  *
+  * Jim Rees  Added baud rate to ttyb
+  * 8 July 82 Jim Rees  Fixed underlining for Printronix
+  * 23 Aug 82 Jim Rees  Fixed plot mode for Printronix
+  * 7 Sept 82 Joe Kelsey Fixed formfeed for Printronix
   */
  
  #include <stdio.h>
***************
*** 7,12
  #include <sgtty.h>
  #include <signal.h>
  
  #define	LINELN	132
  #define	EJLINE	66
  #define SKPLINE	0

--- 12,19 -----
  #include <sgtty.h>
  #include <signal.h>
  
+ #define PRINTRONIX	/* Special modes for Printronix */
+ 
  #define	LINELN	132
  #define	EJLINE	66
  #define SKPLINE	0
***************
*** 14,19
  int	anydone;
  char	linebuf[LINELN+2];
  int	ov;
  char	ovbuf[LINELN];
  FILE	*in	= {stdin};
  FILE	*out;

--- 21,27 -----
  int	anydone;
  char	linebuf[LINELN+2];
  int	ov;
+ int	plotmode;
  char	ovbuf[LINELN];
  FILE	*in	= {stdin};
  FILE	*out;
***************
*** 122,127
  	register int col, maxcol, c;
  
  	ov = 0;
  	for (col=0; col<LINELN; col++) {
  		linebuf[col] = ' ';
  		ovbuf[col] = 0;

--- 130,136 -----
  	register int col, maxcol, c;
  
  	ov = 0;
+ 	plotmode = 0;
  	for (col=0; col<LINELN; col++) {
  		linebuf[col] = ' ';
  		ovbuf[col] = 0;
***************
*** 147,152
  		}
  		continue;
  
  	case '\f':
  		lineno = EJLINE;
  		continue;

--- 156,168 -----
  		}
  		continue;
  
+ #ifdef PRINTRONIX
+ 	case '\05':
+ 		plotmode = 1;
+ 		lineno = 1;	/* To prevent SKPLINE, EJLINE */
+ 		continue;
+ #endif PRINTRONIX
+ 
  	case '\f':
  		lineno = EJLINE;
  #ifdef PRINTRONIX
***************
*** 149,154
  
  	case '\f':
  		lineno = EJLINE;
  		continue;
  
  	case ' ':

--- 165,176 -----
  
  	case '\f':
  		lineno = EJLINE;
+ #ifdef PRINTRONIX
+ 		if (maxcol >= LINELN)
+ 			maxcol = LINELN;
+ 		linebuf[maxcol] = 0;
+ 		return 1;
+ #else
  		continue;
  #endif PRINTRONIX
  	case ' ':
***************
*** 150,156
  	case '\f':
  		lineno = EJLINE;
  		continue;
! 
  	case ' ':
  		col++;
  		continue;

--- 172,178 -----
  		return 1;
  #else
  		continue;
! #endif PRINTRONIX
  	case ' ':
  		col++;
  		continue;
***************
*** 201,215
  	int i, j;
  
  	errno = 0;
! /*
! 	if (ov) do {
! 		for (ep= &ovbuf[LINELN-1]; *ep == 0; ep--)
! 			continue;
! 		for (lp=ovbuf; lp <= ep; lp++)
! 			output(*lp ? *lp : ' ', out);
! 	};
! */
! again:
  	if (ff >= 0) {
  		lp = linebuf;
  		while (c = *lp++)

--- 223,229 -----
  	int i, j;
  
  	errno = 0;
! 
  	if (ff >= 0) {
  		lp = linebuf;
  #ifdef PRINTRONIX
***************
*** 212,217
  again:
  	if (ff >= 0) {
  		lp = linebuf;
  		while (c = *lp++)
  			output(c,out);
  	}

--- 226,235 -----
  
  	if (ff >= 0) {
  		lp = linebuf;
+ #ifdef PRINTRONIX
+ 		if (plotmode)
+ 			output('\05', out);
+ #endif PRINTRONIX
  		while (c = *lp++)
  			output(c,out);
  	}
***************
*** 215,220
  		while (c = *lp++)
  			output(c,out);
  	}
  	if (ff > 0) {
  		putc('\014', out);
  		putc('\r', out);

--- 233,249 -----
  		while (c = *lp++)
  			output(c,out);
  	}
+ 
+ #ifdef PRINTRONIX
+ 	if (ov) {
+ 		output('\r', out);
+ 		for (ep= &ovbuf[LINELN-1]; *ep == 0; ep--)
+ 			continue;
+ 		for (lp=ovbuf; lp <= ep; lp++)
+ 			output(*lp ? *lp : ' ', out);
+ 	}
+ #endif PRINTRONIX
+ 
  	if (ff > 0) {
  		putc('\014', out);
  		putc('\r', out);
***************
*** 298,304
  	if (c == -1)
  		return;
  	c &= 0177;
! 	if (c == 0177)
  		putc('^',fp), c = '?';
  	if (c == 033)
  		c = '$';

--- 327,333 -----
  	if (c == -1)
  		return;
  	c &= 0177;
! 	if (c == 0177 && !plotmode)
  		putc('^',fp), c = '?';
  	if (c == 033)
  		c = '$';
***************
*** 311,316
  	case '\b':
  	case '\t':
  	case '\r':
  		break;
  
  	default:

--- 340,348 -----
  	case '\b':
  	case '\t':
  	case '\r':
+ #ifdef PRINTRONIX
+ 	case '\05':
+ #endif PRINTRONIX
  		break;
  
  	default:



More information about the Comp.bugs.4bsd.ucb-fixes mailing list