Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site pur-phy.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!inuxc!pur-ee!CS-Mordred!Pucc-H:pur-phy!crl From: crl@pur-phy.UUCP (Charles LaBrec) Newsgroups: net.news.b Subject: replacement compare routine for SORTACTIVE Message-ID: <1498@pur-phy.UUCP> Date: Wed, 31-Oct-84 13:21:34 EST Article-I.D.: pur-phy.1498 Posted: Wed Oct 31 13:21:34 1984 Date-Received: Sat, 3-Nov-84 02:46:38 EST Distribution: net Organization: Purdue Univ. Physics Dept., IN Lines: 71 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()