[net.news.b] replacement compare routine for SORTACTIVE

crl@pur-phy.UUCP (Charles LaBrec) (10/31/84)

About a week ago I had an article complaining about how sortactive
worked.  Here is the replacement for the compare routine that it
uses.  One other change is that since findrcline() returns an int,
I changed the struct declaration of table so that it runs faster
on 11's, being able to use registers.  The compare routine is changed
in the following way:
	1.  groups not in .newsrc are always placed after any listed in
		the .newsrc
	2.  two groups not in .newsrc are compared by their active file
		positions, so that active file order is otherwise
		maintained.

Charles LaBrec
UUCP:		pur-ee!Physics:crl, purdue!Physics:crl
INTERNET:	crl @ pur-phy.UUCP

*** rfuncs.c.orig	Tue Oct 23 12:12:59 1984
--- rfuncs.c	Tue Oct 23 12:37:22 1984
***************
*** 553,559
   */
  
  struct table_elt {
! 	long actpos, rcpos;
  };
  
  static int

--- 553,560 -----
   */
  
  struct table_elt {
! 	long actpos;
! 	int rcpos;
  };
  
  static int
***************
*** 560,566
  rcsort(a,b)
  struct table_elt *a, *b;
  {
! 	return(a->rcpos - b->rcpos);
  }
  
  sortactive()

--- 561,583 -----
  rcsort(a,b)
  struct table_elt *a, *b;
  {
! 	register int arc, brc;
! 	
! 	arc = a->rcpos;
! 	brc = b->rcpos;
! 	
! 	if (arc < 0) {		/* a not in .newsrc */
! 		if (brc < 0)	/* b not in .newsrc */
! 			return(a->actpos - b->actpos);	/* sort by active */
! 		else
! 			return(1);	/* force b first */
! 	} else {
! 		if (brc < 0)
! 			return(-1);	/* force a first */
! 		else
! 			return(arc - brc); /* otherwise sort by .newsrc */
! 	}
! 	/*NOTREACHED*/
  }
  
  sortactive()