🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.usg
Article #323

bug report and patch for newform(1)

#323
From: Michael Wescott
Date: Thu, 10 Jul 1986 20:03
95 lines
3067 bytes
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
Technical Details
Message-ID: <688@sauron.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!lll-crg!lll-lcc!qantel!hplabs!hp-sdd!ncr-sd!ncrcae!sauron!wescott

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!lll-crg!lll-lcc!qantel!hplabs!hp-sdd!ncr-sd!ncrcae!sauron!wescott
From: wescott@sauron.UUCP (Michael Wescott)
Newsgroups: net.bugs.usg
Subject: bug report and patch for newform(1)
Message-ID: <688@sauron.UUCP>
Date: Thu, 10-Jul-86 16:03:32 EDT
Article-I.D.: sauron.688
Posted: Thu Jul 10 16:03:32 1986
Date-Received: Sat, 12-Jul-86 04:19:26 EDT
Reply-To: wescott@sauron.UUCP (Michael Wescott)
Organization: NCR Corp., Advanced System Development, Columbia, SC
Lines: 95
Keywords: newform, tab expansion