[comp.mail.elm] Another set of ELM bug fixes

baur@spp3.UUCP (Steven L. Baur) (05/19/87)

Here are some  more ELM fixes (as context diffs this time).
Here are the problems found and how they were fixed:

1.	ELM:debug.last was not being  properly updated  defeating its
	entire purpose.  In intialize.c I found that the OLDDEBUG file
	was not being unlinked before the ELM:debug.info was  being
	linked on top of it.  My System V user's manual states that
	the second argument to link(2) should not be a current valid
	link (ie file exists).  If there is some wierd  UNIX where this
	is not so,  then an ifdef for that version  of  UNIX should
	be inserted around  my patch.

2.	(Far more serious).  As soon  as I deleted my version 1.5 .elmrc
	by updating it  with 1.5b, I found out that elm 1.5b does not
	create valid .elmrc files.  The basic  problem I had was
	an error in read_rc when encountering  a line  starting
	"weedout =", and an error message printed by save_opts:
	"** Couldn't find  and store "ask"".
	The problem with "ask" was that it was not alphabetized in the
	save_info array in save_opts.h (the algorithm  to find strings
	in this array uses binary search which assumes ordering).
	The fix involved putting "ask"  in its place alphabetically,  and
	rearranging the numbers on all the prior  define statements.

	The second problem  involved adding a sentinel to the  weedout
	list similar to  the "*end-of-defaults"  sentinel.   I called
	this  sentinel "*end-user-headers*".

3.	The final problem  involved  .old.elmrc itself.  As .elmrc is
	defined in  syshdrs.h, it  is called  "/.elmrc".  The filename
	thus  constructed  for .old.elmrc ended with .old/.elmrc, which
	does  not match the  comments,  so I  assume  it  is  incorrect.
	The fix I made calls  for ignoring the first character of
	elmrcfile if  it is  a slash "/".


Context diffs follow:  (Files with extensions of .patch are the  patched
	versions recently posted  here, the fixed versions have only .[hc]
	extensions.

*** hdrs/save_opts.h	Mon May 18 16:20:39 1987
--- hdrs/save_opts.h.patch	Mon May 18 13:21:56 1987
***************
*** 9,49
  #define ALWAYSDELETE		1
  #define ALWAYSLEAVE		2
  #define ARROW			3
! #define ASK			4
! #define AUTOCOPY		5
! #define BOUNCEBACK		6
! #define CALENDAR		7
! #define COPY			8
! #define EDITOR			9
! #define EDITOUT			10
! #define FORMS			11
! #define FULLNAME		12
! #define KEYPAD			13
! #define LOCALSIGNATURE		14
! #define MAILBOX			15
! #define MAILDIR			16
! #define MENU			17
! #define MOVEPAGE		18
! #define NAMES			19
! #define NOHEADER		20
! #define PAGER			21
! #define POINTNEW		22
! #define PREFIX			23
! #define PRINT			24
! #define REMOTESIGNATURE		25
! #define RESOLVE			26
! #define SAVEMAIL		27
! #define SAVENAME		28
! #define SHELL			29
! #define SIGNATURE		30
! #define SOFTKEYS		31
! #define SORTBY			32
! #define TIMEOUT			33
! #define TITLES			34
! #define USERLEVEL		35
! #define WARNINGS		36
! #define WEED			37
! #define WEEDOUT			38
  
  #define NUMBER_OF_SAVEABLE_OPTIONS	WEEDOUT+1
  

--- 9,49 -----
  #define ALWAYSDELETE		1
  #define ALWAYSLEAVE		2
  #define ARROW			3
! #define AUTOCOPY		4
! #define BOUNCEBACK		5
! #define CALENDAR		6
! #define COPY			7
! #define EDITOR			8
! #define EDITOUT			9
! #define FORMS			10
! #define FULLNAME		11
! #define KEYPAD			12
! #define LOCALSIGNATURE		13
! #define MAILBOX			14
! #define MAILDIR			15
! #define MENU			16
! #define MOVEPAGE		17
! #define NAMES			18
! #define NOHEADER		19
! #define PAGER			20
! #define POINTNEW		21
! #define PREFIX			22
! #define PRINT			23
! #define REMOTESIGNATURE		24
! #define RESOLVE			25
! #define SAVEMAIL		26
! #define SAVENAME		27
! #define SHELL			28
! #define SIGNATURE		29
! #define SOFTKEYS		30
! #define SORTBY			31
! #define TIMEOUT			32
! #define TITLES			33
! #define USERLEVEL		34
! #define WARNINGS		35
! #define WEED			36
! #define WEEDOUT			37
! #define ASK			38
  
  #define NUMBER_OF_SAVEABLE_OPTIONS	ASK+1
  
***************
*** 45,51
  #define WEED			37
  #define WEEDOUT			38
  
! #define NUMBER_OF_SAVEABLE_OPTIONS	WEEDOUT+1
  
  struct save_info_recs { 
  	char 	name[NLEN]; 	/* name of instruction */

--- 45,51 -----
  #define WEEDOUT			37
  #define ASK			38
  
! #define NUMBER_OF_SAVEABLE_OPTIONS	ASK+1
  
  struct save_info_recs { 
  	char 	name[NLEN]; 	/* name of instruction */
***************
*** 53,59
  	} save_info[NUMBER_OF_SAVEABLE_OPTIONS] = 
  {
   { "alternatives", -1L }, { "alwaysdelete", -1L }, 	{ "alwaysleave", -1L },
!  { "arrow", -1L},		{ "ask", -1L },         { "autocopy", -1L },      	{ "bounceback", -1L },
   { "calendar", -1L }, 	  { "copy", -1L },          	{ "editor", -1L },
   { "editout", -1L }, 	  { "forms", -1L },         	{ "fullname", -1L },
   { "keypad", -1L }, 	  { "localsignature", -1L },	{ "mailbox", -1L }, 

--- 53,59 -----
  	} save_info[NUMBER_OF_SAVEABLE_OPTIONS] = 
  {
   { "alternatives", -1L }, { "alwaysdelete", -1L }, 	{ "alwaysleave", -1L },
!  { "arrow", -1L},         { "autocopy", -1L },      	{ "bounceback", -1L },
   { "calendar", -1L }, 	  { "copy", -1L },          	{ "editor", -1L },
   { "editout", -1L }, 	  { "forms", -1L },         	{ "fullname", -1L },
   { "keypad", -1L }, 	  { "localsignature", -1L },	{ "mailbox", -1L }, 
***************
*** 64,68
   { "savename", -1L },     { "shell", -1L },         	{ "signature", -1L },
   { "softkeys", -1L },	  { "sortby", -1L }, 		{ "timeout", -1L },
   { "titles", -1L },       { "userlevel", -1L }, 	{ "warnings", -1L },
!  { "weed", -1L },         { "weedout", -1L }
  };

--- 64,68 -----
   { "savename", -1L },     { "shell", -1L },         	{ "signature", -1L },
   { "softkeys", -1L },	  { "sortby", -1L }, 		{ "timeout", -1L },
   { "titles", -1L },       { "userlevel", -1L }, 	{ "warnings", -1L },
!  { "weed", -1L },         { "weedout", -1L },		{ "ask", -1L }
  };
--------------------------------------------------------------------------

*** src/initialize.c	Mon May 18 15:50:09 1987
--- src/initialize.c.patch	Mon May 18 15:46:19 1987
***************
*** 67,73
  	  sprintf(filename, "%s/%s", home, DEBUGFILE);
  	  if (access(filename, ACCESS_EXISTS) == 0) {	/* already one! */
  	    sprintf(newfname,"%s/%s", home, OLDEBUG);
- 	    (void) unlink(newfname);	/* make sure old one is gone */
  	    (void) link(filename, newfname);
  	    (void) unlink(filename);
  	  }

--- 67,72 -----
  	  sprintf(filename, "%s/%s", home, DEBUGFILE);
  	  if (access(filename, ACCESS_EXISTS) == 0) {	/* already one! */
  	    sprintf(newfname,"%s/%s", home, OLDEBUG);
  	    (void) link(filename, newfname);
  	    (void) unlink(filename);
  	  }

----------------------------------------------------------------------------
*** src/read_rc.c	Mon May 18 18:44:17 1987
--- src/read_rc.c.patch	Mon May 18 12:30:18 1987
***************
*** 401,407
  
  	while ((header = strtok(strptr, "\t ,\"'")) != NULL) {
  	  if (strlen(header) > 0) {
- 	    if (!strcmp(header,"*end-of-user-headers*")) break;
  	    if (weedcount > MAX_IN_WEEDLIST) {
  	      fprintf(stderr, "Too many weed headers!  Leaving...\n");
  	      exit(1);

--- 401,406 -----
  
  	while ((header = strtok(strptr, "\t ,\"'")) != NULL) {
  	  if (strlen(header) > 0) {
  	    if (weedcount > MAX_IN_WEEDLIST) {
  	      fprintf(stderr, "Too many weed headers!  Leaving...\n");
  	      exit(1);

-----------------------------------------------------------------------------
*** src/save_opts.c	Mon May 18 19:14:49 1987
--- src/save_opts.c.patch	Mon May 18 13:02:37 1987
***************
*** 45,51
  
  	FILE *newelmrc; 
  	char  oldfname[SLEN], newfname[SLEN];
- 	int rc;
  
  	sprintf(newfname, "%s/%s", home, elmrcfile);
  	sprintf(oldfname, "%s/.old%s", home, elmrcfile[0]=='/'?elmrcfile+1:elmrcfile);

--- 45,50 -----
  
  	FILE *newelmrc; 
  	char  oldfname[SLEN], newfname[SLEN];
  
  	sprintf(newfname, "%s/%s", home, elmrcfile);
  	sprintf(oldfname, "%s/.old%s", home, elmrcfile);
***************
*** 48,54
  	int rc;
  
  	sprintf(newfname, "%s/%s", home, elmrcfile);
! 	sprintf(oldfname, "%s/.old%s", home, elmrcfile[0]=='/'?elmrcfile+1:elmrcfile);
  
  	/** first off, let's see if they already HAVE a .elmrc file **/
  

--- 47,53 -----
  	char  oldfname[SLEN], newfname[SLEN];
  
  	sprintf(newfname, "%s/%s", home, elmrcfile);
! 	sprintf(oldfname, "%s/.old%s", home, elmrcfile);
  
  	/** first off, let's see if they already HAVE a .elmrc file **/
  
***************
*** 54,71
  
  	if (access(newfname, ACCESS_EXISTS) != -1) {
  	  /** YES!  Copy it to the file ".old.elmrc".. **/
! 	  rc =  unlink(oldfname);
! 	  if (rc < 0) {
! 		dprint(1,(debugfile,"unable to unlink '%s'\n", oldfname));
! 	  }
! 	  rc = link(newfname, oldfname);
!           if (rc < 0) {
! 		dprint(1,(debugfile,"unable to link '%s' to '%s'\n",newfname,oldfname));
! 	  }
!           rc = unlink(newfname);
!           if (rc < 0) {
! 		dprint(1,(debugfile,"unable to  unlink '%s'\n",newfname));
! 	  }
  	  (void) chown(oldfname, userid, groupid);
  	}
  

--- 53,61 -----
  
  	if (access(newfname, ACCESS_EXISTS) != -1) {
  	  /** YES!  Copy it to the file ".old.elmrc".. **/
! 	  (void) unlink(oldfname);
! 	  (void) link(newfname, oldfname);
!           (void) unlink(newfname);
  	  (void) chown(oldfname, userid, groupid);
  	}
  
***************
*** 251,258
  	  length_so_far += (strlen(weedlist[i]) + 4);
  	  i++;
  	}
! 
! 	fprintf(fd, "\t\"*end-of-user-headers*\"\n\n");
  }
  
  save_option_alternatives(index, list, fd)

--- 241,247 -----
  	  length_so_far += (strlen(weedlist[i]) + 4);
  	  i++;
  	}
! 	fprintf(fd, "\n\n");
  }
  
  save_option_alternatives(index, list, fd)
-- 
	-Steve Baur (Altair)
{ihnp4,decvax,ucbvax,hplabs}!trwrb!trwspp!spp3!baur
People without college degrees are people too.