[net.bugs.usg] Two problems with "ptx" and one with its manual page

guy@sun.uucp (Guy Harris) (09/26/85)

1) "ptx" will mis-sort on occasion, since it sorts the line as a unit when
it's doing its sorting.  The 4.2 version sorts the two components of the
line (the "before keyword" portion and the "keyword and after" portion) as
two separate fields.

2) Even if "ptx" executes successfully, it exits with an exit status of 1.

3) The S5 "ptx" manual page makes the claim under BUGS that:

	Lines that contain tildes (~) are botched, because *ptx*
	uses that character internally.

"ptx" hasn't used "~" internally for quite some time.  TILDE is defined as
0177 in both the 4.2 and S5 "ptx" (and was probably so defined in V7).

Here are the fixes to 1) and 2):

*** /arch/s5r2/usr/src/cmd/ptx/ptx.c	Wed Sep 21 13:46:51 1983
--- ptx.c	Mon Sep 23 13:57:29 1985
***************
*** 59,64
  FILE *outptr = stdout;
  
  char *sortfile;	/* output of sort program */
  FILE *sortptr;
  
  char *bfile;	/*contains user supplied break chars */

--- 59,67 -----
  FILE *outptr = stdout;
  
  char *sortfile;	/* output of sort program */
+ char nofold[] = {'-', 'd', 't', TILDE, 0};
+ char fold[] = {'-', 'd', 'f', 't', TILDE, 0};
+ char *sortopt = nofold;
  FILE *sortptr;
  
  char *bfile;	/*contains user supplied break chars */
***************
*** 71,77
  	register int c;
  	register char *bufp;
  	int pid;
- 	int foldf = 0;
  	char *pend;
  	extern onintr();
  

--- 74,79 -----
  	register int c;
  	register char *bufp;
  	int pid;
  	char *pend;
  	extern onintr();
  
***************
*** 96,102
  			rflag++;
  			break;
  		case 'f':
! 			foldf++;
  			break;
  
  		case 'w':

--- 98,104 -----
  			rflag++;
  			break;
  		case 'f':
! 			sortopt = fold;
  			break;
  
  		case 'w':
***************
*** 234,243
  		diag("Cannot fork",empty);
  
  	case 0:		/* child */
! 		if(foldf == 0)
! 			execl(SORT, SORT, "-d", sortfile, "-o", sortfile, 0);
! 		else
! 			execl(SORT, SORT, "-df", sortfile, "-o", sortfile, 0);
  
  	default:	/* parent */
  		while(wait(&status) != pid);

--- 236,243 -----
  		diag("Cannot fork",empty);
  
  	case 0:		/* child */
! 		execl(SORT, SORT, sortopt, "+0", "-1", "+1",
! 			sortfile, "-o", sortfile, (char *)0);
  
  	default:	/* parent */
  		while(wait(&status) != pid);
***************
*** 245,251
  
  
  	getsort();
! 	onintr();
  }
  
  msg(s,arg)

--- 245,252 -----
  
  
  	getsort();
! 	unlink(sortfile);
! 	exit(0);
  }
  
  msg(s,arg)

	Guy Harris