Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site sdccsu3.UUCP
Path: utzoo!watmath!clyde!burl!mgnetp!ihnp4!zehntel!dual!amd!decwrl!decvax!ittvax!dcdwest!sdcsvax!sdccsu3!cons
From: cons@sdccsu3.UUCP
Newsgroups: net.bugs.4bsd
Subject: 'refer' sort problem and fix
Message-ID: <2123@sdccsu3.UUCP>
Date: Fri, 3-Aug-84 10:52:17 EDT
Article-I.D.: sdccsu3.2123
Posted: Fri Aug  3 10:52:17 1984
Date-Received: Sun, 5-Aug-84 05:48:16 EDT
Organization: U.C. San Diego, Computer Center
Lines: 47

Subject: REFER mis-sorts reference lists if duplicate citations occur.
Index:	usr.bin/refer/refer2.c 4.2BSD
      	usr.bin/refer/refer5.c 4.2BSD

Description:
	The putsig routine in refer5.c is responsible for placing
	signals (usually superscripts, or author-date labels) in the
	body of a document.  Putsig also makes the signals available
	for printing in the reference list by emitting strings such as
	".ds [F signal" into the reference list.

	If a reference is cited more than once, it is only put on the
	reference list the first time it is cited.  However putsig
	persists in emitting the ".ds [F ..." string for duplicate
	citations.

	This causes a problem if the reference list is sorted because
	the extraneous ".ds [F ..." material appears at the beginning
	of the next non-duplicate reference where it obscures the
	sortkey.  Thus the reference list is mis-sorted.

Repeat-By:
	Create a document which cites a reference twice, then cites a
	new reference.  Process the document using REFER with the -s
	option.  Notice the extra ".ds [F ..." line in the REFER
	output.  If the two references came out sorted properly, you
	were lucky, reverse their roles and you will see the failure.

Fix:
	Instead of providing the fixes in the form of diff output, the
	sources for refer2.c and refer5.c have been posted to
	net.sources.  Numerous comments and a feature to condense
	numeric signals (1,2,3 becomes 1-3) have been added. You may
	find these useful.

	Brief description of the fix:
	putsig is called at two places in refer2.c, in one context a
	duplicate citation is being processed and in the other a new
	citation is being processed.  Add a flag parameter to putsig to
	distinguish the two calls.  Modify the routine to suppress the
	emission of ".ds [F ..." when it is called for a
	duplicate citation.  (See sources posted to net.sources)

Rick Accurso
UUCP:  ...!ucbvax!sdcsvax!sdccsu3!accurso
ARPA:  sdcsvax!sdccsu3!accurso@nosc