From: syd@dsinc.DSI.COM (Syd Weinstein)
Subject: elm 2.4 Patch #10
Followup-To: poster
Summary: This is an official patch for elm 2.4 system.  Please apply it.
Priority: HIGH
Organization: Datacomp Systems, Inc., Huntingdon Valley, PA 19006
Date: Tue, 17 Nov 1992 19:19:05 GMT

part 2 of a 2 part patch

Fix:	From rn, say "| patch -p -N -d DIR", where DIR is your elm source
	directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
	If you don't have the patch program, apply the following by hand,
	or get patch (version 2.0, latest patchlevel).

	After patching:
		sh Configure -d
		make
		make install

	If patch indicates that patchlevel is the wrong version, you may need
	to apply one or more previous patches, or the patch may already
	have been applied.  See the patchlevel.h file to find out what has or
	has not been applied.  In any event, don't continue with the patch.

	If you are missing previous patches they can be obtained from our:
	archive server.

	Syd Weinstein
	elm@DSI.COM

	The patches are available from the dsinc archive server
	Send the following message to archive-server@DSI.COM for
	a list of available patches:

	Subject: patch list
	send index elm

Index: hdrs/patchlevel.h
Prereq: "9"
*** ../elm2.4/hdrs/patchlevel.h	Tue Nov 10 15:20:28 1992
--- hdrs/patchlevel.h	Sat Nov 14 16:40:24 1992
***************
*** 1 ****
! #define PATCHLEVEL "9"
--- 1 ----
! #define PATCHLEVEL "10"

Index: filter/rules.c
Prereq: 5.1
*** ../elm2.4/filter/rules.c	Sat Oct  3 18:18:29 1992
--- filter/rules.c	Mon Nov 16 23:10:02 1992
***************
*** 1,8 ****
  
! static char rcsid[] ="@(#)$Id: rules.c,v 5.1 1992/10/03 22:18:09 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] ="@(#)$Id: rules.c,v 5.3 1992/11/17 04:10:01 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,33 ----
   *
   *******************************************************************************
   * $Log: rules.c,v $
+  * Revision 5.3  1992/11/17  04:10:01  syd
+  * The changes to filter/regexp.c are to correct compiler warnings about
+  * unreachable statements.
+  *
+  * The changes to filter/rules.c are to correct the fact that we are passing
+  * a pointer to a condition_rec structore to a function expecting a pointer to
+  * a character string.
+  * From: Tom Moore <tmoore@fievel.DaytonOH.NCR.COM>
+  *
+  * Revision 5.2  1992/11/15  01:40:43  syd
+  * Add regexp processing to filter.
+  * Add execc operator
+  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+  *
   * Revision 5.1  1992/10/03  22:18:09  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 43,48 ****
--- 57,97 ----
  
  char *listrule();
  
+ static struct regexp *last_regexp = NULL;
+ 
+ static int
+ matches(str, relation, cond)
+ char *str;
+ int relation;
+ struct condition_rec *cond;
+ {
+ 	if (relation == RE) {
+ 	  if (cond->regex == NULL) cond->regex = regcomp(cond->argument1);
+ 	  if (regexec(cond->regex, str)) {
+ 	    last_regexp = cond->regex;
+ 	    return TRUE;
+ 	  } else {
+ 	    return FALSE;
+ 	  }
+ 	} else {
+ 	  return contains(str, cond->argument1);
+ 	}
+ }
+ 
+ void
+ regerror(s)
+ char *s;
+ {
+ 	if (outfd != NULL)
+ 	  fprintf(outfd,
+ 	    catgets(elm_msg_cat,
+ 		    FilterSet,FilterCantCompileRegexp,
+ 		    "filter (%s): Error: can't compile regexp: \"%s\"\n"),
+ 		 username, s);
+ 	if (outfd != NULL) fclose(outfd);
+ 	exit(1); 		
+ }
+ 
  int
  action_from_ruleset()
  {
***************
*** 65,75 ****
  	
  	    switch (cond->matchwhat) {
  
! 	      case TO     : x = contains(to, cond->argument1); 		break;
! 	      case FROM   : x = contains(from, cond->argument1); 	break;
! 	      case SENDER : x = contains(sender, cond->argument1);	break;
! 	      case SUBJECT: x = contains(subject, cond->argument1);	break;
! 	      case LINES  : x = compare(lines, relation, cond->argument1);break;
  		       
  	      case CONTAINS: if (outfd != NULL) fprintf(outfd,
  				catgets(elm_msg_cat,
--- 114,124 ----
  	
  	    switch (cond->matchwhat) {
  
! 	      case TO     : x = matches(to, relation, cond);		break;
! 	      case FROM   : x = matches(from, relation, cond); 		break;
! 	      case SENDER : x = matches(sender, relation, cond);	break;
! 	      case SUBJECT: x = matches(subject, relation, cond);	break;
! 	      case LINES  : x = compare(lines, relation, cond);		break;
  		       
  	      case CONTAINS: if (outfd != NULL) fprintf(outfd,
  				catgets(elm_msg_cat,
***************
*** 105,110 ****
--- 154,175 ----
  			   gotten_time++; 		  \
  			}
  
+ static struct {
+ 	int	id;
+ 	char	*str;
+ } regmessage[] = {
+ 	FilterWholeRegsub,	"<match>",
+ 	FilterRegsubOne,	"<submatch-1>",
+ 	FilterRegsubTwo,	"<submatch-2>",
+ 	FilterRegsubThree,	"<submatch-3>",
+ 	FilterRegsubFour,	"<submatch-4>",
+ 	FilterRegsubFive,	"<submatch-5>",
+ 	FilterRegsubSix,	"<submatch-6>",
+ 	FilterRegsubSeven,	"<submatch-7>",
+ 	FilterRegsubEight,	"<submatch-8>",
+ 	FilterRegsubNine,	"<submatch-9>",
+ };
+ 
  expand_macros(word, buffer, line, display)
  char *word, *buffer;
  int  line, display;
***************
*** 120,125 ****
--- 185,192 ----
  	   	%S	= "Re: subject of message"  (only add Re: if not there)
  		%t	= hour:minute 	
  		%y	= year		  
+ 		%&	= the whole string that matched last regexp
+ 		%1-%9	= matched subexpressions in last regexp
  	    or simply copies word into buffer. If "display" is set then
  	    instead it puts "<day-of-month>" etc. etc. in the output.
  	**/
***************
*** 131,137 ****
  	struct tm *timerec;
  	time_t	thetime;
  	register int i, j=0, gotten_time = 0, reading_a_percent_sign = 0,
!                      len, backslashed=0;
  
  	for (i = 0, len = strlen(word); i < len; i++) {
  	  if (reading_a_percent_sign) {
--- 198,204 ----
  	struct tm *timerec;
  	time_t	thetime;
  	register int i, j=0, gotten_time = 0, reading_a_percent_sign = 0,
!                      len, backslashed=0, regsub;
  
  	for (i = 0, len = strlen(word); i < len; i++) {
  	  if (reading_a_percent_sign) {
***************
*** 251,256 ****
--- 318,345 ----
  	                 j = strlen(buffer);
  			 break;
  
+ 	      case '&': case '1': case '2': case '3': case '4':
+ 	      case '5': case '6': case '7': case '8': case '9':
+ 
+ 			 if (word[i] == '&') regsub = 0;
+ 			 else regsub = word[i] - '0';
+ 
+ 			 if (display) {
+ 			   strcat(buffer,catgets(elm_msg_cat,
+ 						 FilterSet,
+ 						 regmessage[regsub].id,
+ 						 regmessage[regsub].str));
+ 			   j = strlen(buffer);
+ 			 } else {
+ 			   if (last_regexp != NULL) {
+ 			     char *sp = last_regexp->startp[regsub];
+ 			     char *ep = last_regexp->endp[regsub];
+ 			     if (sp != NULL && ep != NULL && ep > sp)
+ 			       while (sp < ep) buffer[j++] = *sp++;
+ 			   }
+ 			 }
+ 			 break;
+ 
  	      default  : if (outfd != NULL) fprintf(outfd,
  				catgets(elm_msg_cat,
  					FilterSet,FilterErrorTranslatingMacro,
***************
*** 379,384 ****
--- 468,476 ----
  	  case EXEC       : return(catgets(elm_msg_cat,
  					   FilterSet,FilterExecute,
  					   "Execute"));
+ 	  case EXECC       : return(catgets(elm_msg_cat,
+ 					   FilterSet,FilterExecuteAndSave,
+ 					   "Execute and Save"));
  	  default         : return(catgets(elm_msg_cat,
  					   FilterSet,FilterAction,
  					   "?action?"));
***************
*** 386,394 ****
  }
  
  int
! compare(line, relop, arg)
  int line, relop;
! char *arg;
  {
  	/** Given the actual number of lines in the message, the relop
  	    relation, and the number of lines in the rule, as a string (!),
--- 478,486 ----
  }
  
  int
! compare(line, relop, cond)
  int line, relop;
! struct condition_rec *cond;
  {
  	/** Given the actual number of lines in the message, the relop
  	    relation, and the number of lines in the rule, as a string (!),
***************
*** 397,403 ****
  
  	int rule_lines;
  
! 	rule_lines = atoi(arg);
  
  	switch (relop) {
  	  case LE: return(line <= rule_lines);
--- 489,495 ----
  
  	int rule_lines;
  
! 	rule_lines = atoi(cond->argument1);
  
  	switch (relop) {
  	  case LE: return(line <= rule_lines);

Index: filter/summarize.c
Prereq: 5.3
*** ../elm2.4/filter/summarize.c	Tue Nov 10 15:20:23 1992
--- filter/summarize.c	Sat Nov 14 20:40:43 1992
***************
*** 1,8 ****
  
! static char rcsid[] ="@(#)$Id: summarize.c,v 5.3 1992/11/07 20:48:55 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] ="@(#)$Id: summarize.c,v 5.4 1992/11/15 01:40:43 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: summarize.c,v $
+  * Revision 5.4  1992/11/15  01:40:43  syd
+  * Add regexp processing to filter.
+  * Add execc operator
+  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+  *
   * Revision 5.3  1992/11/07  20:48:55  syd
   * fix applied rule count message
   *
***************
*** 199,208 ****
  			  "(left in mailbox and forwarded to \"%s\")"),
  					    rules[rule].argument2);
  		                    break;
! 		  case EXEC  :      fprintf(outfd,catgets(elm_msg_cat,
  							  FilterSet,
  							  FilterExecMesg,
  					  "(given to command \"%s\")"),
  					    rules[rule].argument2);
  		                    break;
  	      }
--- 204,219 ----
  			  "(left in mailbox and forwarded to \"%s\")"),
  					    rules[rule].argument2);
  		                    break;
! 		  case EXEC :      fprintf(outfd,catgets(elm_msg_cat,
  							  FilterSet,
  							  FilterExecMesg,
  					  "(given to command \"%s\")"),
+ 					    rules[rule].argument2);
+ 		                    break;
+ 		  case EXECC :      fprintf(outfd,catgets(elm_msg_cat,
+ 							  FilterSet,
+ 							  FilterExecCMesg,
+ 			   "(left in mailbox and given to command \"%s\")"),
  					    rules[rule].argument2);
  		                    break;
  	      }

Index: filter/utils.c
Prereq: 5.1
*** ../elm2.4/filter/utils.c	Sat Oct  3 18:18:29 1992
--- filter/utils.c	Sat Nov 14 20:40:45 1992
***************
*** 1,8 ****
  
! static char rcsid[] ="@(#)$Id: utils.c,v 5.1 1992/10/03 22:18:09 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] ="@(#)$Id: utils.c,v 5.2 1992/11/15 01:40:43 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: utils.c,v $
+  * Revision 5.2  1992/11/15  01:40:43  syd
+  * Add regexp processing to filter.
+  * Add execc operator
+  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+  *
   * Revision 5.1  1992/10/03  22:18:09  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 141,146 ****
--- 146,156 ----
  	  case EXEC       : fprintf(fd,catgets(elm_msg_cat,
  					       FilterSet,FilterExecutedMesg,
  					       "\tEXECUTED \"%s\""),
+ 				    rules[rule_choosen].argument2);
+ 	                    break;
+ 	  case EXECC      : fprintf(fd,catgets(elm_msg_cat,
+ 					       FilterSet,FilterExecutedSMesg,
+ 				"\tEXECUTED \"%s\" AND PUT in mailbox"),
  				    rules[rule_choosen].argument2);
  	                    break;
  	  case LEAVE      : fprintf(fd,catgets(elm_msg_cat,

Index: hdrs/filter.h
Prereq: 5.2
*** ../elm2.4/hdrs/filter.h	Tue Oct 27 11:17:24 1992
--- hdrs/filter.h	Sat Nov 14 20:42:57 1992
***************
*** 1,8 ****
  
! /* $Id: filter.h,v 5.2 1992/10/24 14:20:24 syd Exp $ */
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! /* $Id: filter.h,v 5.3 1992/11/15 01:42:57 syd Exp $ */
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: filter.h,v $
+  * Revision 5.3  1992/11/15  01:42:57  syd
+  * Add regexp processing to filter.
+  * Add execc operator
+  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+  *
   * Revision 5.2  1992/10/24  14:20:24  syd
   * remove the 25 (MAXRULES) limitation.
   * Basically it mallocs rules in hunks of RULESINC (25) as it goes along.
***************
*** 29,34 ****
--- 34,41 ----
  
  **/
  
+ #include "regexp.h"
+ 
  #ifdef   BSD
  # undef  tolower
  #endif
***************
*** 83,88 ****
--- 90,96 ----
  #define  EXEC		12
  #define  FORWARDC	13
  #define  SENDER		14
+ #define  EXECC		15
  
  #define  FAILED_SAVE	20
  
***************
*** 94,99 ****
--- 102,108 ----
  #define GT		4
  #define NE		5
  #define EQ		6
+ #define RE		7
  
  /** A funky way to open a file using open() to avoid file locking hassles **/
  
***************
*** 170,180 ****
  	int     matchwhat;			/* type of 'if' clause      */
  	int     relation;			/* type of match (eq, etc)  */
  	char    argument1[SLEN];		/* match against this       */
  	struct  condition_rec  *next;		/* next condition...	    */
        };
  
  struct ruleset_record {
! 	char  	printable[SLEN];		/* straight from file...    */
  	struct  condition_rec  *condition;
  	int     action;				/* what action to take      */
  	char    argument2[SLEN];		/* argument for action      */
--- 179,190 ----
  	int     matchwhat;			/* type of 'if' clause      */
  	int     relation;			/* type of match (eq, etc)  */
  	char    argument1[SLEN];		/* match against this       */
+ 	regexp	*regex;				/* compiled regexp	    */
  	struct  condition_rec  *next;		/* next condition...	    */
        };
  
  struct ruleset_record {
! 	int	line;				/* line in rules file	    */
  	struct  condition_rec  *condition;
  	int     action;				/* what action to take      */
  	char    argument2[SLEN];		/* argument for action      */

Index: hdrs/regexp.h
*** /dev/null	Sat Nov 14 05:48:13 1992
--- hdrs/regexp.h	Sat Nov 14 20:38:25 1992
***************
*** 0 ****
--- 1,45 ----
+ 
+ /* $Id: regexp.h,v 5.3 1992/11/15 01:38:23 syd Exp $ */
+ 
+ /*******************************************************************************
+  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
+  *
+  * 			Copyright (c) 1992 USENET Community Trust
+  *******************************************************************************
+  * Bug reports, patches, comments, suggestions should be sent to:
+  *
+  *	Syd Weinstein, Elm Coordinator
+  *	elm@DSI.COM			dsinc!elm
+  *
+  *******************************************************************************
+  * $Log: regexp.h,v $
+  * Revision 5.3  1992/11/15  01:38:23  syd
+  * fix headers
+  *
+  * Revision 5.2  1992/11/15  01:37:57  syd
+  * add proper headers
+  *
+  *
+  ******************************************************************************/
+ 
+ /*
+  * Definitions etc. for regexp(3) routines.
+  *
+  * Caveat:  this is V8 regexp(3) [actually, a reimplementation thereof],
+  * not the System V one.
+  */
+ #define NSUBEXP  10
+ typedef struct regexp {
+ 	char *startp[NSUBEXP];
+ 	char *endp[NSUBEXP];
+ 	char regstart;		/* Internal use only. */
+ 	char reganch;		/* Internal use only. */
+ 	char *regmust;		/* Internal use only. */
+ 	int regmlen;		/* Internal use only. */
+ 	char program[1];	/* Unwarranted chumminess with compiler. */
+ } regexp;
+ 
+ extern regexp *regcomp();
+ extern int regexec();
+ extern void regsub();
+ extern void regerror();

Index: hdrs/s_elm.h
*** ../elm2.4/hdrs/s_elm.h	Tue Nov 10 15:20:23 1992
--- hdrs/s_elm.h	Sat Nov 14 16:48:43 1992
***************
*** 1,4 ****
! /* s_elm.h created from s_elm.us by gencat on Sat Nov  7 14:37:14 EST 1992 */
  
  #define ElmSet	0x3
  #define ElmYes	0x1
--- 1,4 ----
! /* s_elm.h created from s_elm.us by gencat on Sat Nov 14 16:48:42 EST 1992 */
  
  #define ElmSet	0x3
  #define ElmYes	0x1
***************
*** 748,750 ****
--- 748,751 ----
  #define ElmPrintJobSpooled	0x333
  #define ElmPrintFailCode	0x334
  #define ElmPrintFailStatus	0x335
+ #define ElmCouldntSeekBytesIntoTempFile	0x336

Index: hdrs/s_filter.h
*** ../elm2.4/hdrs/s_filter.h	Tue Oct 27 11:17:25 1992
--- hdrs/s_filter.h	Sat Nov 14 20:42:26 1992
***************
*** 1,4 ****
! /* s_filter.h created from s_filter.us by gencat on Sat Oct  3 18:34:14 EDT 1992 */
  
  #define FilterSet	0x10
  #define FilterCantGetPasswdEntry	0x1
--- 1,4 ----
! /* s_filter.h created from s_filter.us by gencat on Sat Nov 14 21:02:00 EST 1992 */
  
  #define FilterSet	0x10
  #define FilterCantGetPasswdEntry	0x1
***************
*** 33,39 ****
  #define FilterCouldntMallocNew	0x1e
  #define FilterErrorReadingRules2	0x1f
  #define FilterErrorReadingRules3	0x20
! #define FilterCantAllocRules 0x21
  #define FilterContainsNotImplemented	0x22
  #define FilterSender	0x23
  #define FilterReturnAddress	0x24
--- 33,39 ----
  #define FilterCouldntMallocNew	0x1e
  #define FilterErrorReadingRules2	0x1f
  #define FilterErrorReadingRules3	0x20
! #define FilterCantAllocRules	0x21
  #define FilterContainsNotImplemented	0x22
  #define FilterSender	0x23
  #define FilterReturnAddress	0x24
***************
*** 93,96 ****
  #define FilterTheDefaultAction	0x5a
  #define FilterForkSaveFailed	0x5b
  #define FilterRuleNum	0x5c
! #define FilterOutOfMemory 0x5d
--- 93,110 ----
  #define FilterTheDefaultAction	0x5a
  #define FilterForkSaveFailed	0x5b
  #define FilterRuleNum	0x5c
! #define FilterOutOfMemory	0x5d
! #define FilterExecuteAndSave	0x5e
! #define FilterExecCMesg	0x5f
! #define FilterExecutedSMesg	0x60
! #define FilterCantCompileRegexp	0x61
! #define FilterWholeRegsub	0x62
! #define FilterRegsubOne	0x63
! #define FilterRegsubTwo	0x64
! #define FilterRegsubThree	0x65
! #define FilterRegsubFour	0x66
! #define FilterRegsubFive	0x67
! #define FilterRegsubSix	0x68
! #define FilterRegsubSeven	0x69
! #define FilterRegsubEight	0x6a
! #define FilterRegsubNine	0x6b

Index: lib/mk_aliases.c
Prereq: 5.3
*** ../elm2.4/lib/mk_aliases.c	Tue Nov 10 15:20:25 1992
--- lib/mk_aliases.c	Sat Nov 14 20:15:28 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: mk_aliases.c,v 5.3 1992/11/07 16:32:14 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: mk_aliases.c,v 5.4 1992/11/15 01:15:28 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,34 ----
   *
   *******************************************************************************
   * $Log: mk_aliases.c,v $
+  * Revision 5.4  1992/11/15  01:15:28  syd
+  * The alias message_count isn't set to zero if the last alias has
+  * been deleted from the alias table. As no aliases are reread from
+  * the aliases database the message_count is left as it was before.
+  *
+  * Fixed that the function do_newalias() sometimes returns without freeing
+  * the buffer allocated before. The patch adds these free calls.
+  *
+  * When you erroneously type a number in your folder elm asks you for
+  * a new current message number. But now if you erase this one number
+  * and leave the string empty elm will set the new current message to
+  * the second message on our sun4! The patch adds a check for an empty
+  * string and returns the current number if no number was entered.
+  * From: vogt@isa.de (Gerald Vogt)
+  *
   * Revision 5.3  1992/11/07  16:32:14  syd
   * comments should be allowed anywhere in the alias file.
   * From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
***************
*** 518,523 ****
--- 533,539 ----
  	            "Couldn't open %s for input!"), inputname);
  	        error(msg_buff);
  	    }
+ 	    free(buffer);
  	    return(-1);
  	}
  
***************
*** 527,532 ****
--- 543,549 ----
  		    "Couldn't open %s.pag or %s.dir for output!"),
  	        dataname, dataname);
  	    error(msg_buff);
+ 	    free(buffer);
  	    return(-1);
  	}
  
***************
*** 535,540 ****
--- 552,558 ----
  	            NewaliasSet, NewaliasNoOpenOut,
  	            "Couldn't open %s for output!"), dataname);
  	    error(msg_buff);
+ 	    free(buffer);
  	    return(-1);
  	}
  
***************
*** 550,555 ****
--- 568,574 ----
  	    if (fromelm) sleep(2);
  	    error(catgets(elm_msg_cat, NewaliasSet, NewaliasNoSave,
  	            "** Not saving tables!  Please fix and re-run!"));
+ 	    free(buffer);
  	    return(-1);
  	}
  	else {

Index: nls/C/C/C/s_aliases.m
*** ../elm2.4/nls/C/C/C/s_aliases.m	Sat Oct  3 18:35:18 1992
--- nls/C/C/C/s_aliases.m	Sat Nov 14 17:59:30 1992
***************
*** 1,9 ****
  $set 5 #Aliases
  $quote "
  $ #Delete
! 1	"Delete 1 alias? (%s/%s) "
  $ #DeletePlural
! 2	"Delete %d aliases? (%s/%s) "
  $ #KeepDelete
  3	[Keeping 1 alias and deleting %d.]
  $ #KeepDeletePlural
--- 1,9 ----
  $set 5 #Aliases
  $quote "
  $ #Delete
! 1	"Delete 1 alias? (%c/%c) "
  $ #DeletePlural
! 2	"Delete %d aliases? (%c/%c) "
  $ #KeepDelete
  3	[Keeping 1 alias and deleting %d.]
  $ #KeepDeletePlural

Index: nls/C/C/C/s_elm.m
*** ../elm2.4/nls/C/C/C/s_elm.m	Tue Nov 10 15:20:25 1992
--- nls/C/C/C/s_elm.m	Sat Nov 14 16:48:36 1992
***************
*** 1588,1590 ****
--- 1588,1592 ----
  820	Printout failed with return code %d.
  $ #PrintFailStatus
  821	Printout failed with status 0x%04x.
+ $ #CouldntSeekBytesIntoTempFile
+ 822	\r\nCouldn't seek %ld bytes into temp file.\r\n

Index: nls/C/C/C/s_filter.m
*** ../elm2.4/nls/C/C/C/s_filter.m	Tue Oct 27 11:17:27 1992
--- nls/C/C/C/s_filter.m	Sat Nov 14 20:34:45 1992
***************
*** 193,195 ****
--- 193,223 ----
  $quote 
  $ #OutOfMemory
  93	filter (%s): Out of memory [malloc failed]\n
+ $ #ExecuteAndSave
+ 94	Execute and Save
+ $ #ExecCMesg
+ 95	(left in mailbox and given to command "%s")
+ $ #ExecutedSMesg
+ 96	\tEXECUTED "%s" AND PUT in mailbox
+ $ #CantCompileRegexp
+ 97	filter (%s): Error: can't compile regexp: "%s"\n
+ $ #WholeRegsub
+ 98	<match>
+ $ #RegsubOne
+ 99	<submatch-1>
+ $ #RegsubTwo
+ 100	<submatch-2>
+ $ #RegsubThree
+ 101	<submatch-3>
+ $ #RegsubFour
+ 102	<submatch-4>
+ $ #RegsubFive
+ 103	<submatch-5>
+ $ #RegsubSix
+ 104	<submatch-6>
+ $ #RegsubSeven
+ 105	<submatch-7>
+ $ #RegsubEight
+ 106	<submatch-8>
+ $ #RegsubNine
+ 107	<submatch-9>

Index: nls/gencat/genlib.c
*** ../elm2.4/nls/gencat/genlib.c	Sun Oct 20 09:59:51 1991
--- nls/gencat/genlib.c	Sat Nov 14 20:05:11 1992
***************
*** 709,714 ****
--- 709,715 ----
  	    newSet->next = set;
  	    if (set->prev) set->prev->next = newSet;
  	    else cat->first = newSet;
+ 	    set->prev = newSet;
  	    set = newSet;
  	    break;
  	}
***************
*** 769,774 ****
--- 770,776 ----
  	    newMsg->next = msg;
  	    if (msg->prev) msg->prev->next = newMsg;
  	    else curSet->first = newMsg;
+ 	    msg->prev = newMsg;
  	    msg = newMsg;
  	    break;
  	}

Index: src/alias.c
Prereq: 5.9
*** ../elm2.4/src/alias.c	Tue Oct 27 11:17:27 1992
--- src/alias.c	Sat Nov 14 20:24:35 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: alias.c,v 5.9 1992/10/24 13:35:39 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.9 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: alias.c,v 5.11 1992/11/15 01:24:34 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.11 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,44 ----
   *
   *******************************************************************************
   * $Log: alias.c,v $
+  * Revision 5.11  1992/11/15  01:24:34  syd
+  * The situation is that the .elm/aliases file is missing, but
+  * .elm/aliases.dir and .elm/aliases.pag exist (isn't serendipity
+  * wonderful?).  The ndbz functions tolerate this and just put a NULL
+  * pointer in the db structure for the data file FILE pointer.  However,
+  * get_one_alias() in listalias and elm doesn't account for the db_open()
+  * succeeding but the dbz_basef field being NULL, so it passes the NULL
+  * pointer to fread().  Detect null and return 0
+  * From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+  *
+  * Revision 5.10  1992/11/15  01:15:28  syd
+  * The alias message_count isn't set to zero if the last alias has
+  * been deleted from the alias table. As no aliases are reread from
+  * the aliases database the message_count is left as it was before.
+  *
+  * Fixed that the function do_newalias() sometimes returns without freeing
+  * the buffer allocated before. The patch adds these free calls.
+  *
+  * When you erroneously type a number in your folder elm asks you for
+  * a new current message number. But now if you erase this one number
+  * and leave the string empty elm will set the new current message to
+  * the second message on our sun4! The patch adds a check for an empty
+  * string and returns the current number if no number was entered.
+  * From: vogt@isa.de (Gerald Vogt)
+  *
   * Revision 5.9  1992/10/24  13:35:39  syd
   * changes found by using codecenter on Elm 2.4.3
   * From: Graham Hudspith <gwh@inmos.co.uk>
***************
*** 1043,1048 ****
--- 1068,1074 ----
  	 *  message that was put to the screen by the do_newalias()
  	 *  call.
  	 */
+ 	    message_count = 0;
  	    sleep(2);
  	}
  }
***************
*** 1284,1289 ****
--- 1310,1318 ----
  	register struct alias_rec	**new_aliases, *a;
  	struct alias_rec	ar;
  	FILE *data_file = db->dbz_basef;
+ 
+ 	if (data_file == NULL)
+ 	    return(0);	/* no alias file, but hash exists, error condition */
  
  	if (fread((char *) &ar, sizeof(ar), 1, data_file) <= 0)
  	    return(0);

Index: src/edit.c
Prereq: 5.1
*** ../elm2.4/src/edit.c	Sat Oct  3 18:58:49 1992
--- src/edit.c	Sat Nov 14 16:53:49 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: edit.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: edit.c,v 5.2 1992/11/14 21:53:49 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,28 ----
   *
   *******************************************************************************
   * $Log: edit.c,v $
+  * Revision 5.2  1992/11/14  21:53:49  syd
+  * When elm copies the temp mailbox back to the mail spool to resync or
+  * quit, it changes to the mailgroup before attempting to diddle in the
+  * mail spool, but when it copies the temp mailbox back to the mail spool
+  * after editing, it forgets to change to mailgroup.  This patch appears
+  * to work, but I haven't exhaustively checked for some path that leaves
+  * the gid set
+  * wrong.  From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 21,27 ****
   ******************************************************************************/
  
  /** This routine is for allowing the user to edit their current folder
!     as they wish. 
  
  **/
  
--- 30,36 ----
   ******************************************************************************/
  
  /** This routine is for allowing the user to edit their current folder
!     as they wish.
  
  **/
  
***************
*** 45,51 ****
  	    file.  The mailer will ALWAYS resync on the folder
  	    even if nothing has changed since, not unreasonably, it's
  	    hard to figure out what occurred in the edit session...
! 	
  	    Also note that if the user wants to edit their incoming
  	    mailbox they'll actually be editing the tempfile that is
  	    an exact copy.  More on how we resync in that case later
--- 54,60 ----
  	    file.  The mailer will ALWAYS resync on the folder
  	    even if nothing has changed since, not unreasonably, it's
  	    hard to figure out what occurred in the edit session...
! 
  	    Also note that if the user wants to edit their incoming
  	    mailbox they'll actually be editing the tempfile that is
  	    an exact copy.  More on how we resync in that case later
***************
*** 65,71 ****
  	    return(0);
  	  }
  	}
! 	  
  	strcpy(edited_file,
  	    (folder_type == NON_SPOOL ? cur_folder : cur_tempfolder));
  	if (edit_a_file(edited_file) == 0) {
--- 74,80 ----
  	    return(0);
  	  }
  	}
! 
  	strcpy(edited_file,
  	    (folder_type == NON_SPOOL ? cur_folder : cur_tempfolder));
  	if (edit_a_file(edited_file) == 0) {
***************
*** 85,103 ****
  	     CleartoEOLN();
  
  	     if ((temp_folder = fopen(edited_file, "a")) == NULL) {
! 	       dprint(1, (debugfile, 
! 		    "Attempt to open \"%s\" to append failed in %s\n", 
  		    edited_file, "edit_mailbox"));
  	       set_error(catgets(elm_msg_cat, ElmSet, ElmCouldntReopenTemp,
  		 "Couldn't reopen tempfile. Edit LOST!"));
  	       return(1);
  	     }
! 	     /** Now let's lock the folder up and stream the new stuff 
  		 into the temp file... **/
  
! 	     lock(OUTGOING);	
  	     if ((real_folder = fopen(cur_folder, "r")) == NULL) {
! 	       dprint(1, (debugfile, 
  	           "Attempt to open \"%s\" for reading new mail failed in %s\n",
   		   cur_folder, "edit_mailbox"));
  	       sprintf(buffer, catgets(elm_msg_cat, ElmSet, ElmCouldntOpenFolder,
--- 94,112 ----
  	     CleartoEOLN();
  
  	     if ((temp_folder = fopen(edited_file, "a")) == NULL) {
! 	       dprint(1, (debugfile,
! 		    "Attempt to open \"%s\" to append failed in %s\n",
  		    edited_file, "edit_mailbox"));
  	       set_error(catgets(elm_msg_cat, ElmSet, ElmCouldntReopenTemp,
  		 "Couldn't reopen tempfile. Edit LOST!"));
  	       return(1);
  	     }
! 	     /** Now let's lock the folder up and stream the new stuff
  		 into the temp file... **/
  
! 	     lock(OUTGOING);
  	     if ((real_folder = fopen(cur_folder, "r")) == NULL) {
! 	       dprint(1, (debugfile,
  	           "Attempt to open \"%s\" for reading new mail failed in %s\n",
   		   cur_folder, "edit_mailbox"));
  	       sprintf(buffer, catgets(elm_msg_cat, ElmSet, ElmCouldntOpenFolder,
***************
*** 115,121 ****
  	       unlock();
  	       return(1);
  	     }
! 	
  	     /** Now we can finally stream the new mail into the tempfile **/
  
  	     while ((len = mail_gets(buffer, SLEN, real_folder)) != 0)
--- 124,130 ----
  	       unlock();
  	       return(1);
  	     }
! 
  	     /** Now we can finally stream the new mail into the tempfile **/
  
  	     while ((len = mail_gets(buffer, SLEN, real_folder)) != 0)
***************
*** 140,145 ****
--- 149,158 ----
  
   	   } else lock(OUTGOING);
  
+ #ifdef SAVE_GROUP_MAILBOX_ID
+       	   setgid(mailgroupid);
+ #endif
+ 
  	   /* remove real mail_file and then
  	    * link or copy the edited mailfile to real mail_file */
  
***************
*** 180,192 ****
  	     Raw(ON);
  	     sleep(2);
  	   }
! 	      
  	   unlock();
  	   unlink(edited_file);	/* remove the edited mailfile */
  	   error(catgets(elm_msg_cat, ElmSet, ElmChangesIncorporated,
  	     "Changes incorporated into new mail..."));
  
! 	} else 
  	  error(catgets(elm_msg_cat, ElmSet, ElmResyncingNewVersion,
  	    "Resynchronizing with new version of folder..."));
  
--- 193,209 ----
  	     Raw(ON);
  	     sleep(2);
  	   }
! 
! #ifdef SAVE_GROUP_MAILBOX_ID
! 	   setgid(groupid);
! #endif
! 
  	   unlock();
  	   unlink(edited_file);	/* remove the edited mailfile */
  	   error(catgets(elm_msg_cat, ElmSet, ElmChangesIncorporated,
  	     "Changes incorporated into new mail..."));
  
! 	} else
  	  error(catgets(elm_msg_cat, ElmSet, ElmResyncingNewVersion,
  	    "Resynchronizing with new version of folder..."));
  

Index: src/in_utils.c
Prereq: 5.1
*** ../elm2.4/src/in_utils.c	Sat Oct  3 18:58:58 1992
--- src/in_utils.c	Sat Nov 14 20:15:30 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: in_utils.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: in_utils.c,v 5.2 1992/11/15 01:15:28 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,34 ----
   *
   *******************************************************************************
   * $Log: in_utils.c,v $
+  * Revision 5.2  1992/11/15  01:15:28  syd
+  * The alias message_count isn't set to zero if the last alias has
+  * been deleted from the alias table. As no aliases are reread from
+  * the aliases database the message_count is left as it was before.
+  *
+  * Fixed that the function do_newalias() sometimes returns without freeing
+  * the buffer allocated before. The patch adds these free calls.
+  *
+  * When you erroneously type a number in your folder elm asks you for
+  * a new current message number. But now if you erase this one number
+  * and leave the string empty elm will set the new current message to
+  * the second message on our sun4! The patch adds a check for an empty
+  * string and returns the current number if no number was entered.
+  * From: vogt@isa.de (Gerald Vogt)
+  *
   * Revision 5.1  1992/10/03  22:58:40  syd
   * Initial checkin as of 2.4 Release at PL0
   *
***************
*** 95,100 ****
--- 110,118 ----
  	PutLine1(LINES-3, COLUMNS-40,catgets(elm_msg_cat, ElmSet, ElmSetCurrentTo,
  		"Set current %s to :"), item);
  	if (optionally_enter(buff, LINES-3, COLUMNS-15, TRUE, FALSE) == -1)
+ 	  return(current);
+ 
+ 	if (buff[0] == '\0')
  	  return(current);
  
  	sscanf(buff,"%d", &num);

Index: src/newmbox.c
Prereq: 5.6
*** ../elm2.4/src/newmbox.c	Tue Nov 10 15:20:28 1992
--- src/newmbox.c	Sat Nov 14 16:49:43 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: newmbox.c,v 5.6 1992/11/07 20:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.6 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: newmbox.c,v 5.7 1992/11/14 21:49:42 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.7 $   $State: Exp $
   *
   *			Copyright (c) 1988-1992 USENET Community Trust
   *			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,25 ----
   *
   *******************************************************************************
   * $Log: newmbox.c,v $
+  * Revision 5.7  1992/11/14  21:49:42  syd
+  * I think that the code in 'newmbox.c' which handles bad 'Content-length'
+  * entries is incomplete. The file-ptr for the mail file is
+  * backed up, but the file-ptr of the temp file WAS LEFT UNMODIFIED !
+  * From langesw.ssw.de!root Wed Nov 11 14:28:57 1992
+  *
   * Revision 5.6  1992/11/07  20:05:52  syd
   * change to use header_cmp to allow for linear white space around the colon
   * From: Syd
***************
*** 608,613 ****
--- 614,631 ----
  		   cur_folder, mailfile_size, error_description(err), "reset - read_headers"));
  		emergency_exit();
  	      }
+ 	      if (copyit)
+ 		if (fseek(temp, content_start, 0) == -1) {
+ 		  err = errno;
+ 		  Write_to_screen(catgets(elm_msg_cat, ElmSet, ElmCouldntSeekBytesIntoTempFile,
+ 		     "\n\rCouldn't seek %ld bytes into temp file.\n\r"),
+ 		     1, mailfile_size);
+ 		  Write_to_screen("** %s. **\n\r", 1, error_description(err));
+ 		  dprint(1, (debugfile,
+ 	"Error: Couldn't seek temp file %s: (offset %ld) Errno %s (%s)\n",
+ 		     cur_tempfolder, mailfile_size, error_description(err), "reset - read_headers"));
+ 		  emergency_exit();
+ 		}
  	      fbytes = content_start;
  	      line = lines_start;
  	      content_length_found = FALSE;

Index: src/showmsg.c
Prereq: 5.5
*** ../elm2.4/src/showmsg.c	Tue Nov 10 15:20:29 1992
--- src/showmsg.c	Sat Nov 14 20:29:37 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: showmsg.c,v 5.5 1992/11/07 16:23:48 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: showmsg.c,v 5.6 1992/11/15 01:29:37 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.6 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,23 ----
   *
   *******************************************************************************
   * $Log: showmsg.c,v $
+  * Revision 5.6  1992/11/15  01:29:37  syd
+  * Clear the screen before displaying MIME:
+  * From: marius@rhi.hi.is (Marius Olafsson)
+  *
   * Revision 5.5  1992/11/07  16:23:48  syd
   * fix null dereferences from patch 5
   * From: Jukka Ukkonen <ukkonen@csc.fi>
***************
*** 148,153 ****
--- 152,158 ----
  		    copy_message("", fpout, FALSE, FALSE, FALSE, FALSE, FALSE);
  		    (void) fclose (fpout);
  		    sprintf(Cmd, "metamail -p -z -m Elm %s", fname);
+                   ClearScreen();
  		    Raw(OFF);
  		    code = system_call(Cmd, SY_ENAB_SIGINT);
  		    Raw(ON);

Index: utils/listalias.c
Prereq: 5.4
*** ../elm2.4/utils/listalias.c	Mon Nov  2 15:51:50 1992
--- utils/listalias.c	Sat Nov 14 20:24:36 1992
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: listalias.c,v 5.4 1992/11/02 20:49:19 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: listalias.c,v 5.5 1992/11/15 01:24:34 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,29 ----
   *
   *******************************************************************************
   * $Log: listalias.c,v $
+  * Revision 5.5  1992/11/15  01:24:34  syd
+  * The situation is that the .elm/aliases file is missing, but
+  * .elm/aliases.dir and .elm/aliases.pag exist (isn't serendipity
+  * wonderful?).  The ndbz functions tolerate this and just put a NULL
+  * pointer in the db structure for the data file FILE pointer.  However,
+  * get_one_alias() in listalias and elm doesn't account for the db_open()
+  * succeeding but the dbz_basef field being NULL, so it passes the NULL
+  * pointer to fread().  Detect null and return 0
+  * From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+  *
   * Revision 5.4  1992/11/02  20:49:19  syd
   * Resolve a linking error in listalias when DEBUG is enabled.
   * From cs.utexas.edu!chinacat!chip Sun Nov  1 22:04:02 1992
***************
*** 159,164 ****
--- 169,177 ----
   */
  
  	FILE *data_file = db->dbz_basef;
+ 
+ 	if (data_file == NULL)
+ 	    return(0);	/* no alias file, but hash exists, error condition */
  
  	if (fread((char *) ar, sizeof(struct alias_rec), 1, data_file) <= 0)
  	    return(0);

Index: filter/Makefile.SH
Prereq: 5.1
*** ../elm2.4/filter/Makefile.SH	Sat Oct  3 18:18:26 1992
--- filter/Makefile.SH	Sat Nov 14 20:40:45 1992
***************
*** 21,27 ****
  fi
  cat >Makefile <<!GROK!THIS!
  #
! # @(#)$Id: Makefile.SH,v 5.1 1992/10/03 22:18:09 syd Exp $
  #  Makefile for the Elm system filter program
  #
  #         (C) Copyright 1986,1987, by Dave Taylor
--- 21,27 ----
  fi
  cat >Makefile <<!GROK!THIS!
  #
! # @(#)$Id: Makefile.SH,v 5.2 1992/11/15 01:40:43 syd Exp $
  #  Makefile for the Elm system filter program
  #
  #         (C) Copyright 1986,1987, by Dave Taylor
***************
*** 33,38 ****
--- 33,43 ----
  #			dsinc!elm
  #
  #  $Log: Makefile.SH,v $
+ # Revision 5.2  1992/11/15  01:40:43  syd
+ # Add regexp processing to filter.
+ # Add execc operator
+ # From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+ #
  # Revision 5.1  1992/10/03  22:18:09  syd
  # Initial checkin as of 2.4 Release at PL0
  #
***************
*** 80,85 ****
--- 85,91 ----
  			filter.c	\
  			lock.c		\
  			parse.c		\
+ 			regexp.c	\
  			rules.c		\
  			summarize.c	\
  			utils.c
***************
*** 89,94 ****
--- 95,101 ----
  			filter.o	\
  			lock.o		\
  			parse.o		\
+ 			regexp.o	\
  			rules.o		\
  			summarize.o	\
  			utils.o		\
***************
*** 148,153 ****
--- 155,161 ----
  filter.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h $(INCLDIR)/s_filter.h
  lock.o:			$(INCLDIR)/defs.h $(INCLDIR)/filter.h $(INCLDIR)/s_filter.h
  parse.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h $(INCLDIR)/s_filter.h
+ regexp.o:		$(INCLDIR)/defs.h $(INCLDIR)/regexp.h
  rules.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h $(INCLDIR)/s_filter.h
  summarize.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h $(INCLDIR)/s_filter.h
  utils.o:		$(INCLDIR)/defs.h $(INCLDIR)/filter.h $(INCLDIR)/s_filter.h

Index: filter/filter.c
Prereq: 5.2
*** ../elm2.4/filter/filter.c	Tue Nov 10 15:20:22 1992
--- filter/filter.c	Sat Nov 14 20:40:44 1992
***************
*** 1,8 ****
  
! static char rcsid[] ="@(#)$Id: filter.c,v 5.2 1992/11/07 16:20:56 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] ="@(#)$Id: filter.c,v 5.3 1992/11/15 01:40:43 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: filter.c,v $
+  * Revision 5.3  1992/11/15  01:40:43  syd
+  * Add regexp processing to filter.
+  * Add execc operator
+  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+  *
   * Revision 5.2  1992/11/07  16:20:56  syd
   * The first is that when doing a summary, macros are expanded when printing the
   * rule. IMHO they should be printed as with the -r option (i.e. %t is
***************
*** 77,82 ****
--- 82,88 ----
  	struct passwd  *getpwuid();		/* for /etc/passwd          */
  #endif
  	char filename[SLEN],			/* name of the temp file    */
+ 	     action_argument[SLEN], 		/* action arg, per rule    */
  	     buffer[MAX_LINE_LEN];		/* input buffer space       */
  	int  in_header = TRUE,			/* for header parsing       */
  	     in_to     = FALSE,			/* are we on 'n' line To: ? */
***************
*** 260,267 ****
  	if (get_filter_rules() == -1)
  	  mail_message(username);
  	else {
! 	  switch (action_from_ruleset()) {
  
  	    case DELETE_MSG : if (verbose && outfd != NULL)
  			    fprintf(outfd,
  				    catgets(elm_msg_cat,FilterSet,
--- 266,282 ----
  	if (get_filter_rules() == -1)
  	  mail_message(username);
  	else {
! 	  int action = action_from_ruleset();
! 
! 	  if (rule_choosen >= 0) {
! 	    expand_macros(rules[rule_choosen].argument2, action_argument,
! 			rules[rule_choosen].line, printing_rules);
! 	    /* Got to do this because log_msg() uses argument2 in rules[] */
! 	    strcpy(rules[rule_choosen].argument2, action_argument);
! 	  }
  
+ 	  switch (action) {
+ 
  	    case DELETE_MSG : if (verbose && outfd != NULL)
  			    fprintf(outfd,
  				    catgets(elm_msg_cat,FilterSet,
***************
*** 291,296 ****
--- 306,316 ----
  	                  break;
  	    case FORWARD: mail_message(rules[rule_choosen].argument2);
  			  log_msg(FORWARD);
+ 	                  break;
+ 
+ 	    case EXECC	: mail_message(username);
+ 	    		  execute(rules[rule_choosen].argument2);
+ 			  log_msg(EXECC);
  	                  break;
  
  	    case EXEC   : execute(rules[rule_choosen].argument2);

Index: filter/parse.c
Prereq: 5.3
*** ../elm2.4/filter/parse.c	Mon Nov  2 15:51:41 1992
--- filter/parse.c	Sat Nov 14 20:40:46 1992
***************
*** 1,8 ****
  
! static char rcsid[] ="@(#)$Id: parse.c,v 5.3 1992/10/28 14:52:25 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
--- 1,8 ----
  
! static char rcsid[] ="@(#)$Id: parse.c,v 5.4 1992/11/15 01:40:43 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
   *
   * 			Copyright (c) 1988-1992 USENET Community Trust
   * 			Copyright (c) 1986,1987 Dave Taylor
***************
*** 14,19 ****
--- 14,24 ----
   *
   *******************************************************************************
   * $Log: parse.c,v $
+  * Revision 5.4  1992/11/15  01:40:43  syd
+  * Add regexp processing to filter.
+  * Add execc operator
+  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+  *
   * Revision 5.3  1992/10/28  14:52:25  syd
   * fix compiler warning
   * From: steve@nshore.org (Stephen J. Walick)
***************
*** 234,242 ****
  
  	        if (relop == NONE) relop = EQ;	/* otherwise can't do -relop */
  	        cond->relation  = (not_condition? - (relop) : relop);
  
! 		for (i=strlen(cond_argument); --i >= 0;)
! 	          if (cond_argument[i] == '_') cond_argument[i] = ' ';
  
  		strcpy(cond->argument1, cond_argument);
  	        if ((newcond = (struct condition_rec *)
--- 239,249 ----
  
  	        if (relop == NONE) relop = EQ;	/* otherwise can't do -relop */
  	        cond->relation  = (not_condition? - (relop) : relop);
+ 		cond->regex = NULL;
  
! 		if (relop != RE)
! 		  for (i=strlen(cond_argument); --i >= 0;)
! 	            if (cond_argument[i] == '_') cond_argument[i] = ' ';
  
  		strcpy(cond->argument1, cond_argument);
  	        if ((newcond = (struct condition_rec *)
***************
*** 273,278 ****
--- 280,286 ----
  
  		cond->matchwhat = lasttype;
  	        cond->relation  = (not_condition? - (relop) : relop);
+ 		cond->regex = NULL;
  		strcpy(cond->argument1, cond_argument);
  	        if ((newcond = (struct condition_rec *)
  	             malloc(sizeof(struct condition_rec))) == NULL) {
***************
*** 318,323 ****
--- 326,333 ----
  	         else if (the_same(word, "<>")||
  		          the_same(word, "!="))	relop = NE;
  	         else if (the_same(word, "<"))	relop = LT;
+ 	         else if (the_same(word, "~")||
+ 			  the_same(word, "matches")) relop = RE;
  
  		 /* maybe there isn't a relop at all!! */
  
***************
*** 327,340 ****
  	    }
  		 
  	    if (state == READING_ARGUMENT) {
! 	      if (relop != NONE) {
! 	        if ((word = strtok(str, " ()[]'\"\t\n")) == NULL)
! 	          continue;
! 	      }
! 	      for (i=strlen(word); --i>=0;)
! 	        if (word[i] == '_') word[i] = ' ';
  
! 	      strcpy(cond_argument, word);
  	      state = NEXT_CONDITION;
  	    }
  
--- 337,367 ----
  	    }
  		 
  	    if (state == READING_ARGUMENT) {
! 	      if (relop == RE){
! 		/* Special for regular expressions (enclosed between //) */
! 		cond_argument[0] = '\0';
! 		for (;;) {
! 	          if ((word = strtok(str, "/")) == NULL)
! 	            break;
! 		  strcat(cond_argument, word);
! 		  if (word[strlen(word)-1] == '\\') /* If / was escaped ... */
! 		    strcat(cond_argument, "/");
! 		  else
! 		    break;
! 		}
! 		if (word == NULL)
! 		  continue;
! 
! 	      } else {
! 		if (relop != NONE) {
! 	          if ((word = strtok(str, " ()[]'\"\t\n")) == NULL)
! 	            continue;
! 	        }
! 	        for (i=strlen(word); --i>=0;)
! 	          if (word[i] == '_') word[i] = ' ';
  
! 	        strcpy(cond_argument, word);
! 	      }
  	      state = NEXT_CONDITION;
  	    }
  
***************
*** 348,353 ****
--- 375,381 ----
  	      else if (the_same(word, "save"))    action = SAVE;
  	      else if (the_same(word, "forwardc")) action = FORWARDC;
  	      else if (the_same(word, "forward")) action = FORWARD;
+ 	      else if (the_same(word, "executec")) action = EXECC;
  	      else if (the_same(word, "exec"))    action = EXEC;
  	      else if (the_same(word, "leave"))   action = LEAVE;
  	      else {
***************
*** 394,401 ****
  	      /** add this to the rules section and alloc next... **/
  
  	      rules[total_rules].action = action;
! 	      expand_macros(action_argument, rules[total_rules].argument2,line,
! 			    printing_rules);
  
  	      if (++total_rules >= sizeof_rules)
  	        sizeof_rules = grow(&rules, sizeof_rules, RULESINC);
--- 422,437 ----
  	      /** add this to the rules section and alloc next... **/
  
  	      rules[total_rules].action = action;
! 	      rules[total_rules].line = line;
! 
! 	      /** if we are not printing rules we can't expand macros
! 		  until after we applied the rule, due to the regexp macros
! 	      **/
! 	      if (printing_rules)
! 	        expand_macros(action_argument, rules[total_rules].argument2,
! 			      line, printing_rules);
! 	      else
! 		strcpy(rules[total_rules].argument2, action_argument);
  
  	      if (++total_rules >= sizeof_rules)
  	        sizeof_rules = grow(&rules, sizeof_rules, RULESINC);

Index: Patchlist
*** ../elm2.4/Patchlist	Tue Nov 10 15:20:31 1992
--- Patchlist	Sat Nov 14 21:34:54 1992
***************
*** 1,4 ****
--- 1,64 ----
  =========================================================
+ Patch Set - Patches 9 and 10 : Sat Nov 14 21:34:44 EST 1992
+ Elm 2.4PL8 -> Elm 2.4PL10
+ 
+ I think that the code in 'newmbox.c' which handles bad 'Content-length'
+ entries is incomplete. The file-ptr for the mail file is
+ backed up, but the file-ptr of the temp file WAS LEFT UNMODIFIED !
+ From langesw.ssw.de!root Wed Nov 11 14:28:57 1992
+ 
+ When elm copies the temp mailbox back to the mail spool to resync or
+ quit, it changes to the mailgroup before attempting to diddle in the
+ mail spool, but when it copies the temp mailbox back to the mail spool
+ after editing, it forgets to change to mailgroup.  This patch appears
+ to work, but I haven't exhaustively checked for some path that leaves
+ the gid set
+ wrong.  From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+ 
+ There's an error in two messages in s_aliases.m which causes elm2.4
+ to core dump when resyncronize aliases. (%s/%s) should be (%c/%c).
+ 
+ This bug doesn't show up unless you use message cataloges, since the default
+ message in a_quit.c is correct.
+ From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+ 
+ Fix how nls emulation lib gencat links prev pointers
+ From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+ 
+ The alias message_count isn't set to zero if the last alias has
+ been deleted from the alias table. As no aliases are reread from
+ the aliases database the message_count is left as it was before.
+ 
+ Fixed that the function do_newalias() sometimes returns without freeing
+ the buffer allocated before. The patch adds these free calls.
+ 
+ When you erroneously type a number in your folder elm asks you for
+ a new current message number. But now if you erase this one number
+ and leave the string empty elm will set the new current message to
+ the second message on our sun4! The patch adds a check for an empty
+ string and returns the current number if no number was entered.
+ From: vogt@isa.de (Gerald Vogt)
+ 
+ The situation is that the .elm/aliases file is missing, but
+ .elm/aliases.dir and .elm/aliases.pag exist (isn't serendipity
+ wonderful?).  The ndbz functions tolerate this and just put a NULL
+ pointer in the db structure for the data file FILE pointer.  However,
+ get_one_alias() in listalias and elm doesn't account for the db_open()
+ succeeding but the dbz_basef field being NULL, so it passes the NULL
+ pointer to fread().  Detect null and return 0
+ From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
+ 
+ Clear the screen before displaying MIME:
+ From: marius@rhi.hi.is (Marius Olafsson)
+ 
+ Add regexp processing to filter.
+ Add execc operator
+ From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
+ 
+ 
+ 
+ 
+ =========================================================
  Patch Set - Patches 7 and 8 : Sat Nov  7 15:54:44 EST 1992
  Elm 2.4PL6 -> Elm 2.4PL8
  

-- 
========================================================================
Sydney S. Weinstein, CDP, CCP          Elm Coordinator - Current 2.4PL08
Datacomp Systems, Inc.                 Projected 3.0 Release: ??? ?,1994
syd@DSI.COM or dsinc!syd      Voice: (215) 947-9900, FAX: (215) 938-0235
Xref: sparky comp.mail.elm:3360 comp.unix.bsd:9030