🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #1344

Speedup patch for rn (rrn) 4.4.1

#1344
From: Andrew Hastings
Date: Mon, 07 Oct 1991 21:38
1270 lines
36834 bytes
I sent a copy of this patch for rn 4.4, patchlevel 0, to rrn@lib.tmc.edu
a couple of weeks ago.  This copy is for rn 4.4, patchlevel 1.  These
changes affect only the NNTP version of rn, rrn.

-Andy Hastings			abh@cs.cmu.edu			412/268-8734


Index: NEW
Prereq: 4.4
*** rn4.4.1/NEW	Tue Sep 10 02:52:48 1991
--- rn/NEW	Mon Oct  7 16:45:41 1991
***************
*** 91,93 ****
--- 91,151 ----
  
  	
  
+ CHANGES MADE BY ANDREW HASTINGS (abh@cs.cmu.edu) TO RN4.4:
+ 
+ 1.  Added debug flag (-D16) to watch NNTP interaction.  Useful for
+     making subsequent changes.
+ 2.  Added "J" command which junks an article quickly.  It acts like the
+     "c" command in that it marks the article read only in the current
+     newsgroup, and doesn't bother fetching the article to discover where
+     the article appears in other newsgroups.  Useful when junking lots
+     of articles.
+ 3.  Use NNTP STAT, NEXT, and LAST commands to quickly skip unavailable
+     articles when caching subject lines.  Useful when looking at
+     newsgroups with lots of non-contiguously numbered articles.
+ 4.  Use NNTP STAT and LAST commands to quickly skip unavailable articles
+     when using the "p" command.
+ 4.  Fix bugs in subject search mode where rrn may miss unread articles.
+     For example, suppose NNTP LIST says the range of articles is 1-11,
+     but the following articles actually exist:
+ 	4   foo
+ 	5   foo
+ 	9   bar
+ 	10  foo
+ 	11  baz
+     The NNTP server's "current article pointer" is set at 4 initially.
+     It does NOT change when an attempt is made to access a nonexistent
+     article.
+     Without this fix, rrn will issue the following sequence of NNTP
+     commands:
+ 	ARTICLE 1	rrn asks for nonexistent article 1
+ 	HEAD 1		"Skipping unavailable article"
+ 	HEAD 2
+ 	HEAD 3
+ 	STAT 1		it still doesn't exist
+ 	HEAD 3		ditto
+ 	NEXT		oops! now we'll miss article 4:  1-4 marked as read
+ 	HEAD 5		This one exists
+ 	ARTICLE 5	User reads article 5: 5 marked as read
+ 	XHDR subject 1  in the meantime, rrn caches subjects
+ 	XHDR subject 2
+ 	XHDR subject 3
+ 	XHDR subject 4
+ 	XHDR subject 5
+ 	XHDR subject 6
+ 	XHDR subject 7
+ 	XHDR subject 8
+ 	XHDR subject 9
+ 	XHDR subject 10
+ 	XHDR subject 11
+ 	HEAD 10
+ 	ARTICLE 10	User reads next article with same subject: 10 marked
+ 	HEAD 6		"Skipping unavailable article"
+ 	HEAD 7
+ 	HEAD 8
+ 	NEXT		oops! now we'll miss article 9: 6-9 marked as read
+ 	HEAD 11
+ 	ARTICLE 11
+ 5.  Use ranges on NNTP XHDR command to quickly fetch subject lines of
+     several articles.  Fetch 5 at a time while cheating, 50 at a time while
+     searching, LINES at a time for "=" command.
+ 6.  Remove unused variable in finalize().
Index: addng.c
Prereq: 4.4
*** rn4.4.1/addng.c	Tue Sep 10 02:52:45 1991
--- rn/addng.c	Fri Oct  4 10:29:06 1991
***************
*** 136,143 ****
--- 136,151 ----
  #ifdef SERVER		/* ngsize not used */
      int x,tot,min,max;
      sprintf(tst,"GROUP %s",ngnam);
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf(">%s\n", tst) FLUSH;
+ #endif
      put_server(tst);
      (void) nntp_get(tst, sizeof(tst));
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf("<%s\n", tst) FLUSH;
+ #endif
      if (*tst != CHAR_OK) return(0); /* not a real group */
      (void) sscanf(tst,"%d%d%d%d",&x,&tot,&min,&max);
      if (tot > 0) return(time(Null(long *)));
Index: art.c
Prereq: 4.4
*** rn4.4.1/art.c	Tue Sep 10 02:52:02 1991
--- rn/art.c	Fri Oct  4 10:29:07 1991
***************
*** 775,781 ****
      case 'u':
      case 'w':	case 'W':
      case '|':
! 	mark_as_read();		/* mark article as read */
  	/* FALL THROUGH */
      case '#':
      case '$':
--- 775,781 ----
      case 'u':
      case 'w':	case 'W':
      case '|':
! 	mark_as_read(TRUE);		/* mark article as read */
  	/* FALL THROUGH */
      case '#':
      case '$':
***************
*** 793,799 ****
  #endif
      case 'E':
      case 'f':	case 'F':	
!     case 'j':
  				case Ctl('k'):
      case 'm':	case 'M':	
      case 'p':	case 'P':	case Ctl('p'):	
--- 793,799 ----
  #endif
      case 'E':
      case 'f':	case 'F':	
!     case 'j':	case 'J':
  				case Ctl('k'):
      case 'm':	case 'M':	
      case 'p':	case 'P':	case Ctl('p'):	
Index: artio.c
Prereq: 4.4
*** rn4.4.1/artio.c	Tue Sep 10 02:52:36 1991
--- rn/artio.c	Fri Oct  4 10:29:08 1991
***************
*** 130,140 ****
--- 130,148 ----
  		sprintf(ser_line, "ARTICLE %ld", (long)artnum);
  		break;
      }	    
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf(">%s\n", ser_line) FLUSH;
+ #endif
      put_server(ser_line);		/* ask the server for the article */
      if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
  	fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
  	finalize(1);
      }
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf("<%s\n", ser_line) FLUSH;
+ #endif
      if (*ser_line == CHAR_FATAL) {	/* Fatal error */
  		fprintf(stderr,"\nrrn: %s\n",ser_line);
  		finalize(1);
Index: artsrch.c
Prereq: 4.4
*** rn4.4.1/artsrch.c	Tue Sep 10 02:52:32 1991
--- rn/artsrch.c	Fri Oct  4 10:29:14 1991
***************
*** 62,69 ****
      char *pattern;			/* unparsed pattern */
      register char cmdchr = *patbuf;	/* what kind of search? */
      register char *s;
-     bool backward = cmdchr == '?' || cmdchr == Ctl('p');
- 					/* direction of search */
      COMPEX *compex;			/* which compiled expression */
      char *cmdlst = Nullch;		/* list of commands to do */
      int normal_return = SRCH_NOTFOUND;	/* assume no commands */
--- 62,67 ----
***************
*** 71,77 ****
--- 69,85 ----
      char howmuch;			/* search just the subjects */
      bool doread;			/* search read articles? */
      bool foldcase = TRUE;		/* fold upper and lower case? */
+ #ifndef SERVER
+ #ifndef CACHESUBJ
+     bool backward;
+ #endif
+ #endif
  
+     backward = cmdchr == '?' || cmdchr == Ctl('p');
+ 					/* direction of search */
+ #if defined(SERVER) && defined(CACHESUBJ)
+     fetchsize = 50;
+ #endif
      int_count = 0;
      if (cmdchr == '/' || cmdchr == '?') {	/* normal search? */
  	if (get_cmd && buf == patbuf)
***************
*** 141,147 ****
  	if (cmdchr == 'k') {
  	    normal_return = SRCH_DONE;
  	    cmdlst = savestr("j");
! 	    mark_as_read();		/* this article has this subject */
  	    if (!*h) {
  #ifdef VERBOSE
  		IF(verbose)
--- 149,155 ----
  	if (cmdchr == 'k') {
  	    normal_return = SRCH_DONE;
  	    cmdlst = savestr("j");
! 	    mark_as_read(TRUE);		/* this article has this subject */
  	    if (!*h) {
  #ifdef VERBOSE
  		IF(verbose)
Index: bits.c
Prereq: 4.4
*** rn4.4.1/bits.c	Tue Sep 10 02:52:12 1991
--- rn/bits.c	Fri Oct  4 10:29:15 1991
***************
*** 236,246 ****
  /* newsgroups, mark them read there also. */
  
  void
! mark_as_read()
  {
      oneless(art);			/* set the correct bit */
      checkcount++;			/* get more worried about crashes */
!     chase_xrefs(art,TRUE);
  }
  
  /* make sure we have bits set correctly down to firstbit */
--- 236,247 ----
  /* newsgroups, mark them read there also. */
  
  void
! mark_as_read(killxrefs)
  {
      oneless(art);			/* set the correct bit */
      checkcount++;			/* get more worried about crashes */
!     if (killxrefs)
! 	chase_xrefs(art,TRUE);
  }
  
  /* make sure we have bits set correctly down to firstbit */
***************
*** 630,633 ****
  	art = tmpart;
      }
  }
- 
--- 631,633 ----
Index: bits.h
Prereq: 4.4
*** rn4.4.1/bits.h	Tue Sep 10 02:52:54 1991
--- rn/bits.h	Fri Oct  4 10:29:16 1991
***************
*** 66,72 ****
  void	oneless ANSI((ART_NUM));
  void	unmark_as_read ANSI((void));
  void	delay_unmark ANSI((ART_NUM));
! void	mark_as_read ANSI((void));
  void	check_first ANSI((ART_NUM));
  #ifdef DELAYMARK
      void	yankback ANSI((void));
--- 66,72 ----
  void	oneless ANSI((ART_NUM));
  void	unmark_as_read ANSI((void));
  void	delay_unmark ANSI((ART_NUM));
! void	mark_as_read ANSI((int));
  void	check_first ANSI((ART_NUM));
  #ifdef DELAYMARK
      void	yankback ANSI((void));
Index: cheat.c
Prereq: 4.4
*** rn4.4.1/cheat.c	Tue Sep 10 02:52:50 1991
--- rn/cheat.c	Fri Oct  4 10:29:17 1991
***************
*** 88,93 ****
--- 88,97 ----
  	    srchahead = 0;
  	}
  	if (srchahead) {
+ #if defined(SERVER) && defined(CACHESUBJ)
+ 	    backward = FALSE;
+ 	    fetchsize = 5;
+ #endif
  	    srchahead = art;
  	    for (;;) {
  		srchahead++;	/* go forward one article */
***************
*** 147,152 ****
--- 151,160 ----
  	oldartpos = ftell(artfp);
      if (srchahead >= subj_to_get)
  	subj_to_get = srchahead+1;
+ #  ifdef SERVER
+     backward = FALSE;
+     fetchsize = 5;
+ #  endif
      while (!input_pending() && subj_to_get <= lastart)
  	fetchsubj(subj_to_get++,FALSE,FALSE);
      if (oldart) {
Index: common.h
Prereq: 4.4
*** rn4.4.1/common.h	Tue Sep 10 02:51:42 1991
--- rn/common.h	Fri Oct  4 10:29:18 1991
***************
*** 769,774 ****
--- 769,775 ----
  
  #ifdef DEBUGGING
      EXT int debug INIT(0);				/* -D */
+ #   define DEB_NNTP 16 
  #   define DEB_INNERSRCH 32 
  #   define DEB_FILEXP 64 
  #   define DEB_HASH 128
Index: final.c
Prereq: 4.4
*** rn4.4.1/final.c	Tue Sep 10 02:52:36 1991
--- rn/final.c	Fri Oct  4 10:29:19 1991
***************
*** 81,89 ****
  finalize(status)
  int status;
  {
- #ifdef SERVER
-     char artname[MAXFILENAME];
- #endif /* SERVER */
      termlib_reset();
      if (bizarre)
  	resetty();
--- 81,86 ----
Index: head.c
Prereq: 4.4
*** rn4.4.1/head.c	Tue Sep 10 02:52:25 1991
--- rn/head.c	Fri Oct  4 10:29:20 1991
***************
*** 26,32 ****
--- 26,35 ----
  #include "bits.h"
  #ifdef SERVER
  #include "server.h"
+ #ifdef CACHESUBJ
+ #include "ng.h"
  #endif
+ #endif /* SERVER */
  #include "util.h"
  #include "INTERN.h"
  #include "head.h"
***************
*** 201,206 ****
--- 204,213 ----
  #ifdef SERVER
      static int xhdr = 1;		/* Can we use xhdr command? */
      int eoo;				/* End of server output */
+ #ifdef CACHESUBJ
+     register ART_NUM i;
+     ART_NUM prevart, nextart;
+ #endif
  #endif /* SERVER */
  
  #ifdef CACHESUBJ
***************
*** 232,257 ****
  	    *s = '\0';
  #ifdef SERVER
  	    if (xhdr) {
  	    	sprintf(ser_line, "XHDR subject %ld", artnum);
  	    	put_server(ser_line);
  		if (nntp_get(ser_line, sizeof (ser_line)) >= 0) {
  			if (ser_line[0] == CHAR_FATAL) {
! 				fprintf(stderr,"\nrrn: %s\n",ser_line);
! 				finalize(1);
! /*			    xhdr = 0; */
  			} else {
  			    while (nntp_get(ser_line, sizeof (ser_line)) >= 0) {
  				if (ser_line[0] == '.')
  				    break;
  				else {
  				    t = index(ser_line, ' ');
  				    if (t++) {
! 					strcpy(s, t);
! 					if (t = index(s, '\r'))
! 						*t = '\0';
  				    }
  				}
  			    }
  			}
  		} else {
  		    fprintf(stderr,
--- 239,314 ----
  	    *s = '\0';
  #ifdef SERVER
  	    if (xhdr) {
+ #ifdef CACHESUBJ
+ 		if (backward) {
+ 		    prevart = artnum-fetchsize+1 < absfirst ? absfirst :
+ 							    artnum-fetchsize+1;
+ 		    if (subj_list[OFFSET(prevart)])
+ 			prevart = artnum;
+ 		    nextart = artnum;
+ 		} else {
+ 		    prevart = artnum;
+ 		    nextart = artnum+fetchsize-1 > lastart ? lastart :
+ 							   artnum+fetchsize-1;
+ 		    if (subj_list[OFFSET(nextart)])
+ 			nextart = artnum;
+ 		}
+ 	    	sprintf(ser_line, "XHDR subject %ld-%ld", prevart, nextart);
+ #else
  	    	sprintf(ser_line, "XHDR subject %ld", artnum);
+ #endif
+ #ifdef DEBUGGING
+ 		if (debug & DEB_NNTP)
+ 		    printf(">%s\n", ser_line) FLUSH;
+ #endif
  	    	put_server(ser_line);
  		if (nntp_get(ser_line, sizeof (ser_line)) >= 0) {
+ #ifdef DEBUGGING
+ 			if (debug & DEB_NNTP)
+ 			    printf("<%s\n", ser_line) FLUSH;
+ #endif
  			if (ser_line[0] == CHAR_FATAL) {
! /*
!  *				fprintf(stderr,"\nrrn: %s\n",ser_line);
!  *				finalize(1);
!  */
! 			    xhdr = 0;
  			} else {
  			    while (nntp_get(ser_line, sizeof (ser_line)) >= 0) {
+ #ifdef DEBUGGING
+ 				if (debug & DEB_NNTP)
+ 				    printf("<%s\n", ser_line) FLUSH;
+ #endif
  				if (ser_line[0] == '.')
  				    break;
  				else {
  				    t = index(ser_line, ' ');
  				    if (t++) {
! #ifdef CACHESUBJ
! 				        if ((i=atol(ser_line)) == artnum) {
! #endif
! 					    strcpy(s, t);
! 					    if (t = index(s, '\r'))
! 						    *t = '\0';
! #ifdef CACHESUBJ
! 					} else {
! 					    char *p;
! 					    
! 					    if (p = index(t, '\r'))
! 						*p = '\0';
! 					    subj_list[OFFSET(i)] =
! 					      safemalloc((MEM_SIZE)strlen(t)+1);
! 					    strcpy(subj_list[OFFSET(i)], t);
! 					}
! #endif
  				    }
  				}
  			    }
+ #ifdef CACHESUBJ
+ 			    for (i=OFFSET(prevart); i<=OFFSET(nextart); i++)
+ 				if (!subj_list[i])
+ 				    subj_list[i] = nullstr;
+ #endif CACHESUBJ
  			}
  		} else {
  		    fprintf(stderr,
***************
*** 261,284 ****
  	    }
  
  	    if (!xhdr) {
  		sprintf(ser_line, "HEAD %ld", artnum);
  		put_server(ser_line);
  		eoo = 0;
! 		if (nntp_get(ser_line, sizeof (ser_line)) >= 0 && 
! 			ser_line[0] == CHAR_OK) {
! 		    do {
! 			if (nntp_get(s, LBUFLEN) < 0 || (*s == '.')) {
! 			strcpy(s, "Title: \n");
! 			eoo = 1;
! 		        }
! 		    } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8));
  
! 		    if (!eoo)
! 			while (nntp_get(ser_line, sizeof (ser_line)) >= 0 &&
! 				ser_line[0] != '.');
! 		    t = index(s,':')+1;
! 		    while (*t == ' ') t++;
! 		    strcpy(s, t);
  	        }
  	    }
  #else /* not SERVER */
--- 318,361 ----
  	    }
  
  	    if (!xhdr) {
+ #ifdef CACHESUBJ
+ 		prevart = nextart = artnum;
+ #endif
  		sprintf(ser_line, "HEAD %ld", artnum);
+ #ifdef DEBUGGING
+ 		if (debug & DEB_NNTP)
+ 		    printf(">%s\n", ser_line) FLUSH;
+ #endif
  		put_server(ser_line);
  		eoo = 0;
! 		if (nntp_get(ser_line, sizeof (ser_line)) >= 0) {
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf("<%s\n", ser_line) FLUSH;
! #endif
! 		    if (ser_line[0] == CHAR_OK) {
! 			do {
! 			    if (nntp_get(s, LBUFLEN) < 0 || (*s == '.')) {
! 				strcpy(s, "Title: \n");
! 				eoo = 1;
! 			    }
! 			} while (strnNE(s,"Title:",6) &&
! 				 strnNE(s,"Subject:",8));
  
! 			if (!eoo)
! 			    while (nntp_get(ser_line, sizeof (ser_line)) >= 0) {
! 				if (ser_line[0] == '.') {
! #ifdef DEBUGGING
! 				    if (debug & DEB_NNTP)
! 					printf("<%s\n", ser_line) FLUSH;
! #endif
! 				    break;
! 				}
! 			    }
! 			t = index(s,':')+1;
! 			while (*t == ' ') t++;
! 			strcpy(s, t);
! 		    }
  	        }
  	    }
  #else /* not SERVER */
***************
*** 297,303 ****
  	    s = saferealloc(s, (MEM_SIZE)strlen(s)+1);
  #ifdef CACHESUBJ
  	    subj_list[OFFSET(artnum)] = s;
! #endif 
  	}
      }
  #ifdef CACHESUBJ
--- 374,502 ----
  	    s = saferealloc(s, (MEM_SIZE)strlen(s)+1);
  #ifdef CACHESUBJ
  	    subj_list[OFFSET(artnum)] = s;
! #ifdef SERVER
! 	    if (!*s) {
! 		/*
! 		 * The article we're looking for didn't exist.  Use the
! 		 * "NEXT" ("LAST") command to skip quickly to the next
! 		 * (previous) existing article.
! 		 */
! 		ART_NUM badart = 0;
! 
! 		prevart = prevart-1 < absfirst ? absfirst : prevart-1;
! 		nextart = nextart+1 > lastart  ? lastart  : nextart+1;
! 		if (!backward && !subj_list[OFFSET(nextart)]) {
! 		    /*
! 		     * STAT first valid article before this one,
! 		     * and issue NEXT command.
! 		     */
! 		    for (; prevart>absfirst; prevart--)
! 			if (subj_list[OFFSET(prevart)] &&
! 			    *subj_list[OFFSET(prevart)])
! 			    break;
! 		    sprintf(ser_line, "STAT %ld", prevart);
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf(">%s\n", ser_line) FLUSH;
! #endif
! 		    put_server(ser_line);
! 		    if (nntp_get(ser_line, sizeof (ser_line)) < 0) {
! 			fprintf(stderr,
! 			    "\nrrn: Unexpected close of server socket.\n");
! 			finalize(1);
! 		    }
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf("<%s\n", ser_line) FLUSH;
! #endif
! 		    if (ser_line[0] == CHAR_OK) {
! #ifdef DEBUGGING
! 			if (debug & DEB_NNTP)
! 			    printf(">NEXT\n");
! #endif
! 			put_server("NEXT");
! 			if (nntp_get(ser_line, sizeof (ser_line)) < 0) {
! 			    fprintf(stderr,
! 				"\nrrn: Unexpected close of server socket.\n");
! 			    finalize(1);
! 			}
! #ifdef DEBUGGING
! 			if (debug & DEB_NNTP)
! 			    printf("<%s\n", ser_line) FLUSH;
! #endif
! 			if (ser_line[0] == CHAR_OK)
! 			    nextart = atol(ser_line+4);
! 			else
! 			    nextart = lastart+1;
! 			for (i=OFFSET(prevart); i<OFFSET(nextart); i++)
! 			    if (!subj_list[i])
! 				subj_list[i] = nullstr;
! 		    } else
! 			badart = prevart;
! 		} else if (backward && !subj_list[OFFSET(prevart)]) {
! 		    /*
! 		     * STAT first valid article after this one,
! 		     * and issue LAST command.
! 		     */
! 		    for (; nextart<lastart; nextart++)
! 			if (subj_list[OFFSET(nextart)] &&
! 			    *subj_list[OFFSET(nextart)])
! 			    break;
! 		    sprintf(ser_line, "STAT %ld", nextart);
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf(">%s\n", ser_line) FLUSH;
! #endif
! 		    put_server(ser_line);
! 		    if (nntp_get(ser_line, sizeof (ser_line)) < 0) {
! 			fprintf(stderr,
! 			    "\nrrn: Unexpected close of server socket.\n");
! 			finalize(1);
! 		    }
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf("<%s\n", ser_line) FLUSH;
! #endif
! 		    if (ser_line[0] == CHAR_OK) {
! #ifdef DEBUGGING
! 			if (debug & DEB_NNTP)
! 			    printf(">LAST\n");
! #endif
! 			put_server("LAST");
! 			if (nntp_get(ser_line, sizeof (ser_line)) < 0) {
! 			    fprintf(stderr,
! 				"\nrrn: Unexpected close of server socket.\n");
! 			    finalize(1);
! 			}
! #ifdef DEBUGGING
! 			if (debug & DEB_NNTP)
! 			    printf("<%s\n", ser_line) FLUSH;
! #endif
! 			if (ser_line[0] == CHAR_OK)
! 			    prevart = atol(ser_line+4);
! 			else
! 			    prevart = absfirst-1;
! 			for (i=OFFSET(nextart); i>OFFSET(prevart); i--)
! 			    if (!subj_list[i])
! 				subj_list[i] = nullstr;
! 		    } else
! 			badart = nextart;
! 		}
! 		if (badart) {
! 		    /*
! 		     * The article we tried to STAT doesn't exist.  If it is
! 		     * before the minimum article from the GROUP response,
! 		     * ignore the whole range.
! 		     */
! 		    if (badart < minart) {
! 			for (i=OFFSET(badart); i<OFFSET(minart); i++)
! 			    if (!subj_list[i])
! 				subj_list[i] = nullstr;
! 		    }
! 		}
! 	    }
! #endif
! #endif /* CACHESUBJ */
  	}
      }
  #ifdef CACHESUBJ
Index: head.h
Prereq: 4.4
*** rn4.4.1/head.h	Tue Sep 10 02:51:33 1991
--- rn/head.h	Fri Oct  4 10:29:21 1991
***************
*** 133,138 ****
--- 133,142 ----
  
  #ifdef CACHESUBJ
      EXT char **subj_list INIT(Null(char **));
+ #  ifdef SERVER
+ EXT bool backward INIT(FALSE);
+ EXT int fetchsize INIT(1);
+ #  endif
  #endif
  
  void	head_init ANSI((void));
Index: help.c
Prereq: 4.4
*** rn4.4.1/help.c	Tue Sep 10 02:52:15 1991
--- rn/help.c	Fri Oct  4 10:29:22 1991
***************
*** 63,68 ****
--- 63,69 ----
  TAB	Search for next line beginning with a different character.\n\
  q	Quit the pager, go to end of article.  Leave article read or unread.\n\
  j	Junk this article (mark it read).  Goes to end of article.\n\
+ J	Same as j but doesn't junk this article in other newsgroups.\n\
  \n\
  ",NOMARKING)) ||
      (cmd = print_lines("\
***************
*** 118,124 ****
  	the current article, and $ for the last article.\n\
  ",NOMARKING)) ||
      (cmd = print_lines("\
!  	Valid commands are: e, j, m, M, s, S, and |.\n\
  ",NOMARKING)) ||
      (cmd = print_lines("\
  /pattern/modifiers\n\
--- 119,125 ----
  	the current article, and $ for the last article.\n\
  ",NOMARKING)) ||
      (cmd = print_lines("\
!  	Valid commands are: e, j, J, m, M, s, S, and |.\n\
  ",NOMARKING)) ||
      (cmd = print_lines("\
  /pattern/modifiers\n\
***************
*** 163,168 ****
--- 164,170 ----
  &&	Print current macro definitions.\n\
  &&def	Define a new macro.\n\
  j	Junk this article (mark it read).  Stays at end of article.\n\
+ J	Same as j but doesn't junk this article in other newsgroups.\n\
  ",NOMARKING)) ||
      (cmd = print_lines("\
  m	Mark article as still unread.\n\
Index: ng.c
Prereq: 4.4
*** rn4.4.1/ng.c	Tue Sep 10 02:51:53 1991
--- rn/ng.c	Fri Oct  4 10:29:23 1991
***************
*** 137,147 ****
--- 137,155 ----
  
  #ifdef SERVER
      sprintf(ser_line, "GROUP %s", ngname);
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf(">%s\n", ser_line) FLUSH;
+ #endif
      put_server(ser_line);
      if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
  	fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
  	finalize(1);
      }
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf("<%s\n", ser_line) FLUSH;
+ #endif
      if (*ser_line != CHAR_OK) {
  	if (atoi(ser_line) != ERR_NOGROUP){
  		fprintf(stderr, "\nrrn: server response to GROUP %s:\n%s\n",
***************
*** 149,154 ****
--- 157,166 ----
  		finalize(1);
  	}
  	return (-1);
+     } else {
+ 	int x, tot;
+ 
+ 	(void) sscanf(ser_line,"%d%d%d%d",&x,&tot,&minart,&maxart);
      }
  #else /* not SERVER */
      if (eaccess(ngdir,5)) {		/* directory read protected? */
***************
*** 373,408 ****
  #endif /* READDIR */
  #else
  		{
! 			char	ser_line[NNTP_STRLEN];
! 			ART_NUM	newart;
  
! 			if (isfirstart) {
! 				sprintf(ser_line, "STAT %d",absfirst);
! 				put_server(ser_line);
! 				if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
! 					fprintf(stderr, 
! 					"\nrrn: Unexpected close of server socket.\n");
! 					finalize(1);
! 				}
! 				newart=absfirst;
! 				isfirstart=FALSE;
! 			} 
! 			else {
! 				put_server("NEXT");
! 				if  (nntp_get(ser_line, sizeof(ser_line)) < 0) {
! 					fprintf(stderr,
! 					"\nrrn: unexpected close of server socket.\n");
! 					finalize(1);
! 				}
! 				if (ser_line[0] != CHAR_OK) {
! 					newart = lastart + 1;
! 				}
! 				else
! 					newart = atoi(ser_line+4);
  			}				
! 			for (i=art; i<newart; i++)
! 				oneless(i);
! 			art = newart - 1;
  		}
  #endif /* SERVER */
  		break;
--- 385,455 ----
  #endif /* READDIR */
  #else
  		{
! 		    char	ser_line[NNTP_STRLEN];
! 		    ART_NUM	newart;
  
! 		    /*
! 		     * Before doing a "NEXT", make sure the
! 		     * "current article pointer" is pointing to
! 		     * the nearest existing article before this
! 		     * one.  (If we're in subject search mode,
! 		     * the "current article pointer" might be
! 		     * at an article much later than art.)
! 		     */
! 		    if (art < minart)
! 			newart = minart;
! 		    else {
! 			newart = art-1 < absfirst ? absfirst : art-1;
! 			for (; newart>=absfirst; newart--) {
! #ifdef CACHESUBJ
! 			    if (subj_list &&
! 				subj_list[OFFSET(newart)] &&
! 				!*subj_list[OFFSET(newart)])
! 				/* We already know it doesn't exist. */
! 				continue;
! #endif
! 			    sprintf(ser_line, "STAT %ld", newart);
! #ifdef DEBUGGING
! 			    if (debug & DEB_NNTP)
! 				printf(">%s\n", ser_line) FLUSH;
! #endif
! 			    put_server(ser_line);
! 			    if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
! 				    fprintf(stderr, 
! 				"\nrrn: Unexpected close of server socket.\n");
! 				    finalize(1);
! 			    }
! #ifdef DEBUGGING
! 			    if (debug & DEB_NNTP)
! 				printf("<%s\n", ser_line) FLUSH;
! #endif
! 			    if (ser_line[0] == CHAR_OK)
! 				break;
! 			}
! 			if (newart < art) {
! #ifdef DEBUGGING
! 			    if (debug & DEB_NNTP)
! 				printf(">NEXT\n") FLUSH;
! #endif
! 			    put_server("NEXT");
! 			    if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
! 				fprintf(stderr,
! 				"\nrrn: unexpected close of server socket.\n");
! 				finalize(1);
! 			    }
! #ifdef DEBUGGING
! 			    if (debug & DEB_NNTP)
! 				printf("<%s\n", ser_line) FLUSH;
! #endif
! 			    if (ser_line[0] != CHAR_OK)
! 				newart = lastart + 1;
! 			    else
! 				newart = atol(ser_line+4);
  			}				
! 		    }
! 		    for (i=art; i<newart; i++)
! 			oneless(i);
! 		    art = newart - 1;
  		}
  #endif /* SERVER */
  		break;
***************
*** 444,451 ****
  		    break;
  		}
  	    }
! 	    if (art >= absfirst)	/* don't mark non-existant articles */
! 		mark_as_read();		/* mark current article as read */
  	    do_hiding = TRUE;
  #ifdef ROTATION
  	    rotate = FALSE;
--- 491,498 ----
  		    break;
  		}
  	    }
! 	    if (art >= absfirst)	/* don't mark non-existent articles */
! 		mark_as_read(TRUE);	/* mark current article as read */
  	    do_hiding = TRUE;
  #ifdef ROTATION
  	    rotate = FALSE;
***************
*** 532,538 ****
  #ifdef CACHESUBJ
      if (subj_list) {
  	for (i=OFFSET(lastart); i>=0; --i)
! 	    if (subj_list[i])
  		free(subj_list[i]);
  #ifndef lint
  	free((char*)subj_list);
--- 579,585 ----
  #ifdef CACHESUBJ
      if (subj_list) {
  	for (i=OFFSET(lastart); i>=0; --i)
! 	    if (subj_list[i] && subj_list[i] != nullstr)
  		free(subj_list[i]);
  #ifndef lint
  	free((char*)subj_list);
***************
*** 569,580 ****
  
      switch (*buf) {
      case 'p':			/* find previous unread article */
  	do {
  	    if (art <= firstart)
  		break;
  	    art--;
  #ifdef SERVER
! 	} while (was_read(art) || nntpopen(art,GET_HEADER) == Nullfp);
  #else
  	} while (was_read(art) || artopen(art) == Nullfp);
  #endif
--- 616,675 ----
  
      switch (*buf) {
      case 'p':			/* find previous unread article */
+ #ifdef SERVER
+ 	i = art;
+ #endif
  	do {
  	    if (art <= firstart)
  		break;
  	    art--;
  #ifdef SERVER
! 	    if (!was_read(art))
! 		if (nntpopen(art, GET_HEADER) != Nullfp) {
! 		    break;
! 		} else while (i > art) {
! 		    sprintf(ser_line, "STAT %ld", i);
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf(">%s\n", ser_line) FLUSH;
! #endif
! 		    put_server(ser_line);
! 		    if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
! 			fprintf(stderr,
! 			    "\nrrn: unexpected close of server socket.\n");
! 			finalize(1);
! 		    }
! #ifdef DEBUGGING
! 		    if (debug & DEB_NNTP)
! 			printf("<%s\n", ser_line) FLUSH;
! #endif
! 		    if (ser_line[0] != CHAR_OK) {
! 			i = firstart;
! 		    } else {
! #ifdef DEBUGGING
! 			if (debug & DEB_NNTP)
! 			    printf(">LAST\n") FLUSH;
! #endif
! 			put_server("LAST");
! 			if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
! 			    fprintf(stderr,
! 				"\nrrn: unexpected close of server socket.\n");
! 			    finalize(1);
! 			}
! #ifdef DEBUGGING
! 			if (debug & DEB_NNTP)
! 			    printf("<%s\n", ser_line) FLUSH;
! #endif
! 			if (ser_line[0] != CHAR_OK)
! 			    i = art = firstart;
! 			else {
! 			    i = atol(ser_line+4);
! 			    if (i < art)
! 				art = i+1;
! 			}
! 		    }
! 		}
! 	} while (1);
  #else
  	} while (was_read(art) || artopen(art) == Nullfp);
  #endif
***************
*** 834,842 ****
      case 'q':			/* go back up to newsgroup level? */
  	return AS_CLEAN;
      case 'j':
  	putchar('\n') FLUSH;
  	if (art <= lastart)
! 	    mark_as_read();
  	return AS_ASK;
      case 'h': {			/* help? */
  	int cmd;
--- 929,938 ----
      case 'q':			/* go back up to newsgroup level? */
  	return AS_CLEAN;
      case 'j':
+     case 'J':
  	putchar('\n') FLUSH;
  	if (art <= lastart)
! 	    mark_as_read(*buf == 'j');
  	return AS_ASK;
      case 'h': {			/* help? */
  	int cmd;
***************
*** 870,875 ****
--- 966,975 ----
  
  	page_init();
  #ifdef CACHESUBJ
+ # ifdef SERVER
+ 	backward = FALSE;
+ 	fetchsize = LINES;
+ # endif
  	if (!subj_list)
  	    fetchsubj(art,TRUE,FALSE);
  #endif
***************
*** 922,927 ****
--- 1022,1031 ----
  #if defined(CACHESUBJ) && defined(DEBUGGING)
      case 'D':
  	printf("\nFirst article: %ld\n",(long)firstart) FLUSH;
+ # ifdef SERVER
+ 	backward = FALSE;
+ 	fetchsize = 1;
+ # endif
  	if (!subj_list)
  	    fetchsubj(art,TRUE,FALSE);
  	if (subj_list != Null(char **)) {
Index: ng.h
Prereq: 4.4
*** rn4.4.1/ng.h	Tue Sep 10 02:53:04 1991
--- rn/ng.h	Fri Oct  4 10:29:24 1991
***************
*** 32,38 ****
  #endif
  EXT char *mailcall INIT(nullstr);
  #ifdef SERVER
! EXT bool isfirstart INIT(TRUE);
  #endif
  EXT bool forcelast INIT(FALSE);		/* ought we show "End of newsgroup"? */
  EXT bool forcegrow INIT(FALSE);		/* do we want to recalculate size */
--- 32,39 ----
  #endif
  EXT char *mailcall INIT(nullstr);
  #ifdef SERVER
! EXT ART_NUM minart INIT(0);		/* min article from GROUP response */
! EXT ART_NUM maxart INIT(0);		/* max article from GROUP response */
  #endif
  EXT bool forcelast INIT(FALSE);		/* ought we show "End of newsgroup"? */
  EXT bool forcegrow INIT(FALSE);		/* do we want to recalculate size */
Index: ngdata.c
Prereq: 4.4.1.1
*** rn4.4.1/ngdata.c	Fri Oct  4 10:10:09 1991
--- rn/ngdata.c	Fri Oct  4 10:33:16 1991
***************
*** 68,75 ****
--- 68,83 ----
      /* open the active file */
  
  #ifdef SERVER
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf(">LIST\n") FLUSH;
+ #endif
      put_server("LIST");		/* tell server we want the active file */
      nntp_get(ser_line, sizeof(ser_line));
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf("<%s\n", ser_line) FLUSH;
+ #endif
      if (*ser_line != CHAR_OK) {		/* and then see if that's ok */
  	fprintf(stdout, "Can't get active file from server: \n%s\n", ser_line);
  	finalize(1);
***************
*** 95,100 ****
--- 103,112 ----
  	fputs(ser_line, actfp);
  	putc('\n', actfp);
      }
+ #ifdef DEBUGGING
+ 	if (debug & DEB_NNTP)
+ 	    printf("<%s\n", ser_line) FLUSH;
+ #endif
  
      if (ferror(actfp)) {
  	printf("Error writing to active file %s.\n", active_name) FLUSH;
***************
*** 270,280 ****
--- 282,300 ----
  #else
      getngsize(ngnum); /* set moderated as side effect */
      sprintf(ser_line,"GROUP %s",rcline[ngnum]);
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf(">%s\n", ser_line) FLUSH;
+ #endif
      put_server(ser_line);
      if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
  	fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
  	finalize(1);
      }
+ #ifdef DEBUGGING
+     if (debug & DEB_NNTP)
+ 	printf("<%s\n", ser_line) FLUSH;
+ #endif
      if (*ser_line == CHAR_FATAL){
  	fprintf(stderr,"\nrrn: %s\n",ser_line);
  	finalize(1);
Index: ngstuff.c
Prereq: 4.4
*** rn4.4.1/ngstuff.c	Tue Sep 10 02:52:33 1991
--- rn/ngstuff.c	Fri Oct  4 10:29:26 1991
***************
*** 239,247 ****
      for (; ch = *cmdlst; cmdlst++) {
  	if (isspace(ch) || ch == ':')
  	    continue;
! 	if (ch == 'j') {
  	    if (!was_read(art)) {
! 		mark_as_read();
  #ifdef VERBOSE
  		IF(verbose)
  		    fputs("\tJunked",stdout);
--- 239,247 ----
      for (; ch = *cmdlst; cmdlst++) {
  	if (isspace(ch) || ch == ':')
  	    continue;
! 	if (ch == 'j' || ch == 'J') {
  	    if (!was_read(art)) {
! 		mark_as_read(ch == 'j');
  #ifdef VERBOSE
  		IF(verbose)
  		    fputs("\tJunked",stdout);
Index: patchlevel
Prereq: 1
*** rn4.4.1/patchlevel	Fri Oct  4 10:10:02 1991
--- rn/patchlevel	Fri Oct  4 10:30:54 1991
***************
*** 1 ****
! Patch:  1
--- 1 ----
! Patch:  1abh
Index: rcstuff.c
Prereq: 4.4
*** rn4.4.1/rcstuff.c	Tue Sep 10 02:51:39 1991
--- rn/rcstuff.c	Fri Oct  4 10:29:27 1991
***************
*** 319,329 ****
--- 319,337 ----
  
  #ifdef SERVER
  	sprintf(ser_line, "GROUP %s", ngname);
+ #ifdef DEBUGGING
+ 	if (debug & DEB_NNTP)
+ 	    printf(">%s\n", ser_line) FLUSH;
+ #endif
  	put_server(ser_line);
  	if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
  	    fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
  	    finalize(1);
  	}
+ #ifdef DEBUGGING
+ 	if (debug & DEB_NNTP)
+ 	    printf("<%s\n", ser_line) FLUSH;
+ #endif
  	if (*ser_line != CHAR_OK) {
  	    if (atoi(ser_line) != ERR_NOGROUP) {
  		fprintf(stderr, "\nServer response to GROUP %s:\n%s\n",
Index: rn.1
Prereq: 4.4.1.1
*** rn4.4.1/rn.1	Fri Oct  4 10:10:13 1991
--- rn/rn.1	Fri Oct  4 10:29:29 1991
***************
*** 404,410 ****
  sign \*(L'$\*(R' represents the last article.
  .Sp
  Applicable commands include \*(L'm\*(R' (mark as unread), \*(L'M\*(R'
! (delayed mark as unread), \*(L'j\*(R' (mark as read), \*(L"s dest\*(R"
  (save to a destination), \*(L"!command\*(R" (shell escape), \*(L"=\*(R"
  (print the subject) and \*(L"C\*(R" (cancel).
  .Ip j 8
--- 404,411 ----
  sign \*(L'$\*(R' represents the last article.
  .Sp
  Applicable commands include \*(L'm\*(R' (mark as unread), \*(L'M\*(R'
! (delayed mark as unread), \*(L'j\*(R' (mark as read),
! \*(L'J\*(R' (mark as read in current newsgroup), \*(L"s dest\*(R"
  (save to a destination), \*(L"!command\*(R" (shell escape), \*(L"=\*(R"
  (print the subject) and \*(L"C\*(R" (cancel).
  .Ip j 8
***************
*** 411,416 ****
--- 412,420 ----
  Junk the current article\*(--mark it as read.
  If this command is used from within an article, you are left at the end of
  the article, unlike \*(L'n\*(R', which looks for the next article.
+ .Ip J 8
+ Junk the current article only in the current newsgroup.  If the article
+ was posted to multiple newsgroups you may see it again.
  .Ip m 8
  Mark the current article as still unread.
  (If you are in subject search mode you probably want to use M instead of m.
***************
*** 451,457 ****
  Apply the commands listed to articles matching the search command (possibly
  with h, a, or r modifiers).
  Applicable commands include \*(L'm\*(R' (mark as unread), \*(L'M\*(R'
! (delayed mark as unread), \*(L'j\*(R' (mark as read), \*(L"s dest\*(R"
  (save to a destination), \*(L"!command\*(R" (shell escape), \*(L"=\*(R"
  (print the subject) and \*(L"C\*(R" (cancel).
  If the first command is \*(L'm\*(R' or \*(L'M\*(R', modifier r is assumed.
--- 455,462 ----
  Apply the commands listed to articles matching the search command (possibly
  with h, a, or r modifiers).
  Applicable commands include \*(L'm\*(R' (mark as unread), \*(L'M\*(R'
! (delayed mark as unread), \*(L'j\*(R' (mark as read),
! \*(L'J\*(R' (mark as read in current newsgroup), \*(L"s dest\*(R"
  (save to a destination), \*(L"!command\*(R" (shell escape), \*(L"=\*(R"
  (print the subject) and \*(L"C\*(R" (cancel).
  If the first command is \*(L'm\*(R' or \*(L'M\*(R', modifier r is assumed.
***************
*** 707,712 ****
--- 712,720 ----
  .Ip j 8
  Junk the current article.
  Mark it read and go to the end of the article.
+ .Ip J 8
+ Junk the current article in the current newsgroup.
+ Mark it read only in the current newsgroup and go to the end of the article.
  .Ip ^L 8
  Refresh the screen.
  .Ip X 8
Index: rn.c
Prereq: 4.4
*** rn4.4.1/rn.c	Fri Oct  4 10:10:14 1991
--- rn/rn.c	Fri Oct  4 10:38:48 1991
***************
*** 25,31 ****
   */
  
  static char rnid[] = "@(#)$Id: rn.c,v 4.4.1.1 1991/09/25 19:38:08 sob Exp sob $";
! static char patchlevel[] = "Patchlevel 1";
  
  /* $Log: rn.c,v $
   * Revision 4.4.1.1  1991/09/25  19:38:08  sob
--- 25,31 ----
   */
  
  static char rnid[] = "@(#)$Id: rn.c,v 4.4.1.1 1991/09/25 19:38:08 sob Exp sob $";
! static char patchlevel[] = "Patchlevel 1abh";
  
  /* $Log: rn.c,v $
   * Revision 4.4.1.1  1991/09/25  19:38:08  sob
Technical Details
Message-ID: <1991Oct07.213817.103802@cs.cmu.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.sources.bugs.mbox.zip!gmdzi!unido!unidui!math.fu-berlin.de!ox.com!caen!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!rochester!pt.cs.cmu.edu!abh

Show Full Headers
Complete Article Headers
Message-ID: <1991Oct07.213817.103802@cs.cmu.edu>
Subject: Speedup patch for rn (rrn) 4.4.1
Date: Mon, 07 Oct 1991 21:38:17 +0000
From: abh+@cs.cmu.edu (Andrew Hastings)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.sources.bugs.mbox.zip!gmdzi!unido!unidui!math.fu-berlin.de!ox.com!caen!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!rochester!pt.cs.cmu.edu!abh
Newsgroups: news.software.readers,news.software.nntp,news.software.b,comp.sources.bugs
Organization: School of Computer Science, Carnegie Mellon
Lines: 1269
Nntp-Posting-Host: m.gp.cs.cmu.edu
Originator: abh@M.GP.CS.CMU.EDU