From: davison@borland.com (Wayne Davison)
Subject: Patch #4 for trn 2
Organization: Borland International
Date: Fri, 8 Jan 1993 06:59:11 GMT

[This patch and the full source are also available on ftp.uu.net in the
news/trn subdirectory.]

----------------------------------------------------------------------------

Here's patch #4 for trn 2 -- this creates version 2.4.  To apply it, you
need either a unified version of Larry Wall's patch program (such as 12u8),
or the unidiff filter (included with trn) and an old version of patch.

To apply this from within trn, you would type:

	| patch -p -d /trn/source/dir
or
	| unipatch | patch -p -d /trn/source/dir

After installing the patch you should do the following:

	make
	make install

This patch corrects some release problems with trn 2.3, and provides a few
minor enhancements.  If you have already applied the temporary "fix-it"
patch to trn 2.3, you can remove it by using "patch -R <fixes" to reverse-
apply the patch before applying this one.

Areas of enhancement:
   o	The reference line trimming has been modified to save the first
	reference on the line (just in case it is the root article).
   o	Made trn/mthreads more supportive of systems that don't update their
	min field in the active file.
   o	If no SIGEMT is available, use signal 0 instead.
   o	Changed the definition of fseek for Linux users.
   o	If SYSTYPE is defined to a bsd* value, use the sh from /SYSTYPE/bin.
   o	Changed the variable "daylight" in getdate.y to avoid conflict with
	a global variable of the same name on certain systems.
   o	Restored the newsgroup-growth tracking while in the group.
   o	Support for AIX returning an non-zero value > 255 from isupper().

These release glitches were also covered in the "fix-it" patch:
   o	Fixed various glitches with strcmp/bcmp, strchr/index, <stdlib.h>,
	and <string.h>.
   o	Fixed the missing "line" reference in mthreads.
   o	Fixed the void*/char* mismatch in the rawget_server definition.
   o	Fixed the -c command-line option.

..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index:patchlevel
Prereq: v2.3
@@ -1,1 +1,1 @@
-trn v2.3
+trn v2.4
Index:Configure
@@ -829,5 +829,8 @@
 echo " "
 echo "Checking out how to guarantee sh startup..."
-startsh=$sharpbang'/bin/sh'
+case "$SYSTYPE" in
+bsd*)	startsh=$sharpbang'/$SYSTYPE/bin/sh' ;;
+*)	startsh=$sharpbang'/bin/sh' ;;
+esac
 echo "Let's see if '$startsh' works..."
 cat >try <<EOSS
Index:MANIFEST
@@ -42,4 +42,7 @@
 getactive.c        Program used by shell scripts to the active file (trrn only).
 getdate.y          A yacc script for date parsing.
+hdbm.c             Hashing database manager.
+hdbm.h             Public info for hdbm.
+hdbmint.h          Internal defines for hdbm.
 head.c             Header parsing routines.
 head.h             Public info regarding head.c.
@@ -77,4 +80,5 @@
 ngdata.c           General data fetching routines for a newsgroup.
 ngdata.h           Public info regarding ngdata.c.
+nghash.c           Some hashing routines to speed up active file handling.
 ngsrch.c           Routines to search among newsgroups.
 ngsrch.h           Public info regarding ngsrch.c.
Index:common.h
@@ -910,5 +910,9 @@
 /* miscellania */
 
+#ifdef linux
+long int fseek();
+#else
 int fseek();
+#endif
 long atol(), ftell();
 EXT bool in_ng INIT(FALSE);		/* current state of rn */
Index:config.h.SH
@@ -142,4 +142,5 @@
 #$memcpy bcopy(s,d,n) memcpy((char*)d,(char*)s,(int)n)	/* Different */
 #$memcpy bzero(d,n)   memset((char*)d,0,(int)n)		/*  flavors. */
+#$memcpy bcmp(s,s2,n) memcmp((char*)s,(char*)s2,(int)n)
 #$rename RENAME		/* is rename() a system call? */
 #$ftruncate FTRUNCATE	/* is ftruncate() available? */
Index:getdate.y
@@ -10,5 +10,7 @@
 #include <time.h>
 
+#ifndef NULL
 #define	NULL	0
+#endif
 
 #define daysec (24L*60L*60L)
@@ -16,5 +18,5 @@
 	static int timeflag, zoneflag, dateflag, dayflag, relflag;
 	static time_t relsec, relmonth;
-	static int hh, mm, ss, merid, daylight;
+	static int hh, mm, ss, merid, daylite;
 	static int dayord, dayreq;
 	static int month, day, year;
@@ -56,5 +58,5 @@
 	| NUMBER ':' NUMBER NUMBER =
 		{hh = $1; mm = $3; merid = 24;
-		daylight = STANDARD; ourzone = -($4%100 + 60*$4/100);}
+		daylite = STANDARD; ourzone = -($4%100 + 60*$4/100);}
 	| NUMBER ':' NUMBER ':' NUMBER =
 		{hh = $1; mm = $3; ss = $5; merid = 24;}
@@ -63,10 +65,10 @@
 	| NUMBER ':' NUMBER ':' NUMBER NUMBER =
 		{hh = $1; mm = $3; ss = $5; merid = 24;
-		daylight = STANDARD; ourzone = -($6%100 + 60*$6/100);};
+		daylite = STANDARD; ourzone = -($6%100 + 60*$6/100);};
 
 zone:	ZONE =
-		{ourzone = $1; daylight = STANDARD;}
+		{ourzone = $1; daylite = STANDARD;}
 	| DAYZONE =
-		{ourzone = $1; daylight = DAYLIGHT;};
+		{ourzone = $1; daylite = DAYLIGHT;};
 
 dyspec:	DAY =
@@ -485,5 +487,5 @@
 	relsec = 0; relmonth = 0;
 	timeflag=zoneflag=dateflag=dayflag=relflag=0;
-	daylight = MAYBE;
+	daylite = MAYBE;
 	hh = mm = ss = 0;
 	merid = 24;
@@ -499,5 +501,5 @@
 	if (err) return (-1);
 	if (dateflag || timeflag || dayflag) {
-		sdate = dateconv(month,day,year,hh,mm,ss,merid,ourzone,daylight);
+		sdate = dateconv(month,day,year,hh,mm,ss,merid,ourzone,daylite);
 		if (sdate < 0) return -1;
 	}
Index:hdbm.c
@@ -29,7 +29,6 @@
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "EXTERN.h"
+#include "common.h"
 #include "hdbm.h"
 #include "hdbmint.h"
@@ -149,5 +148,5 @@
 		hpkeydat = hp->he_key.dat_ptr;
 		if (hp->he_key.dat_len == keylen && hpkeydat[0] == keydat[0] &&
-		    memcmp(hpkeydat, keydat, keylen) == 0)
+		    bcmp(hpkeydat, keydat, keylen) == 0)
 			break;
 	}
Index:init.c
@@ -221,4 +221,8 @@
 }
 
+#ifndef SIGEMT
+#define SIGEMT 0
+#endif
+
 /* make sure there is no rn out there already */
 
Index:intrp.c
@@ -777,6 +777,7 @@
 			refs_buf = fetchlines(art,REFS_LINE);
 			refscpy(scrbuf,(sizeof scrbuf),refs_buf);
-			/* no more than 3 prior references allowed,
-			** including the one concatenated below */
+			/* no more than 3 prior references PLUS the
+			** root article allowed, including the one
+			** concatenated below */
 			if ((s = rindex(scrbuf,'<')) > scrbuf) {
 			    *s = '\0';
@@ -783,6 +784,9 @@
 			    h = rindex(scrbuf,'<');
 			    *s = '<';
-			    if (h > scrbuf)
-				strcpy(scrbuf,h);
+			    if (h > scrbuf) {
+				s = index(scrbuf+1,'<');
+				if (s < h)
+				    strcpy(s,h);
+			    }
 			}
 		    }
Index:mt-write.c
@@ -51,8 +51,10 @@
     }
 
+#ifndef TMPTHREAD
     /* If there's no roots, there's no data.  Leave the file with no length. */
-    if (!total.root && !failure) {
+    if (!failure && total.last < total.first) {
 	failure = -1;
     }
+#endif
 
     write_item(&total, sizeof (TOTAL));
Index:mthreads.c
@@ -46,5 +46,5 @@
 char buf[LBUFLEN+1];
 
-static char line[256];
+char line[256];
 static char line2[256];
 
@@ -928,5 +928,7 @@
 			    if (grevious_error) {
 				unlink(filename); /* blow away the .thread, */
-				(void) init_data(Nullch); /* zero totals & */
+				(void) init_data(Nullch); /* set totals */
+				total.last = first-1;
+				total.first = first;
 				(void) write_data(filename); /* write it null */
 			    }
Index:ngdata.c
@@ -126,4 +126,5 @@
 #endif
     oldsoft = softptr[num];
+    fseek(actfp,100000L,1);    /* hopefully this forces a reread */
     if ((softptr[num] = findact(tmpbuf, nam, len, (long)oldsoft)) >= 0) {
 	if (softptr[num] != oldsoft) {
Index:nghash.c
@@ -28,6 +28,4 @@
 #endif
 #include "ngdata.h"
-
-#include <string.h>
 #include "hdbm.h"
 
@@ -73,5 +71,5 @@
     rewind(actfp);
     for (activeitems = 0; fgets(buf, LBUFLEN, actfp) != NULL; activeitems++) {
-	register char *p = strchr(buf, ' ');
+	register char *p = index(buf, ' ');
 	HDBMDATUM key, data;
 
@@ -120,5 +118,5 @@
 	    return -1;
 	else {
-	    (void) memcpy(outbuf, data.dat_ptr, (int)data.dat_len);
+	    (void) bcopy(data.dat_ptr, outbuf, (int)data.dat_len);
 	    outbuf[data.dat_len] = '\0';
 	    return data.dat_ptr - actfile;
Index:respond.c
@@ -47,4 +47,6 @@
 static char nullart[] = "\nNull article\n";
 
+bool cut_line();
+
 void
 respond_init()
@@ -56,5 +58,5 @@
 save_article()
 {
-    bool use_pref, cut_line();
+    bool_int use_pref;
     register char *s, *c;
     char altbuf[CBUFLEN];
Index:rn.c
@@ -33,5 +33,5 @@
 
 static char rnid[] = "@(#)$Id: rn.c,v 4.4.3.1 1991/11/22 04:12:14 davison Trn $";
-static char patchlevel[] = "Trn-2.3 based on rn-4.4PL4";
+static char patchlevel[] = "Trn-2.4 based on rn-4.4PL4";
 
 /* $Log: rn.c,v $
Index:rthreads.c
@@ -62,5 +62,4 @@
     if (size < 0) {
 	printf("\nYour NNTP server isn't XTHREAD-compliant.\n") FLUSH;
-	use_threads = FALSE;
 	return;
     }
@@ -199,4 +198,7 @@
     } else if (!total.root) {
 	fclose(fp);
+	for (i = firstbit; i <= lastart; i++) {
+	    oneless(i);
+	}
 	return 0;
     }
Index:server.c
@@ -84,5 +84,5 @@
 long
 rawget_server(buf, n)
-void	*buf;
+char	*buf;
 long	n;
 {
Index:sw.c
@@ -207,4 +207,7 @@
 #endif
 	    break;
+	case 'c':
+	    checkflag = upordown;
+	    break;
 	case 'C':
 	    s++;
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Newsgroups: news.software.readers