[net.bugs.usg] bug report and patch for newform

wescott@sauron.UUCP (Michael Wescott) (07/10/86)

The newform command does not expand tabs properly beyond column 80 with either
the default specs or with the -8 (or some other number) spec.

For example:
	echo "\t1\t2\t3\t4\t5\t6\t7\t8\t9\tA\tB\tC" | newform -i 
produces:
        1       2       3       4       5       6       7       8       9ABC
and
	echo "\t1\t2\t3\t4\t5\t6\t7\t8\t9\tA\tB\tC" | newform -i-9
gives:
         1        2        3        4        5        6        7        89ABC

patch follows which fixes problems and sets up a sufficiently large tabtbl for
the worst case (I think).

Your line numbers may differ...

*** newform.c.orig	Thu Jul 10 15:37:27 1986
--- newform.c	Thu Jul 10 15:45:29 1986
***************
*** 33,39
  #define	NCOLS	512
  #define	MAXLINE	512
  #define	NUMBER	'0'
- #define	LINELEN	80
  
  int	tabtbl[500] = {		/* Table containing tab stops		*/
  	1,9,17,25,33,41,49,57,65,73,0,

--- 33,38 -----
  #define	NCOLS	512
  #define	MAXLINE	512
  #define	NUMBER	'0'
  
  int	tabtbl[MAXLINE*2+2+87] = {		/* Table containing tab stops		*/
  	1,9,17,25,33,41,49,57,65,73,0,
***************
*** 35,41
  #define	NUMBER	'0'
  #define	LINELEN	80
  
! int	tabtbl[500] = {		/* Table containing tab stops		*/
  	1,9,17,25,33,41,49,57,65,73,0,
  				/* Default tabs				*/
  	1,10,16,36,72,0,	/* IBM 370 Assembler			*/

--- 34,40 -----
  #define	MAXLINE	512
  #define	NUMBER	'0'
  
! int	tabtbl[MAXLINE*2+2+87] = {		/* Table containing tab stops		*/
  	1,9,17,25,33,41,49,57,65,73,0,
  				/* Default tabs				*/
  	1,10,16,36,72,0,	/* IBM 370 Assembler			*/
***************
*** 258,264
  		case 0:
  			switch (type(c)) {
  			case '\0':
! 				spectype = 0;
  				state = -1;
  				break;
  			case NUMBER:

--- 257,264 -----
  		case 0:
  			switch (type(c)) {
  			case '\0':
! 				number[0] = 8;
! 				spectype = 10;
  				state = -1;
  				break;
  			case NUMBER:
***************
*** 443,449
  		spectbl[spectype] = nexttab;
  		*nexttab = 1;
  	 	if(number[0] == 0)number[0] = 1; /* Prevent infinite loop. */
! 		while (*nexttab < LINELEN) {
  			*(nexttab + 1) = *nexttab;
  			*++nexttab += number[0];
  			}

--- 443,449 -----
  		spectbl[spectype] = nexttab;
  		*nexttab = 1;
  	 	if(number[0] == 0)number[0] = 1; /* Prevent infinite loop. */
! 		while (*nexttab < MAXLINE) {
  			*(nexttab + 1) = *nexttab;
  			*++nexttab += number[0];
  			}


	-Mike Wescott
	ncrcae!wescott