[comp.sources.bugs] elm 2.2 Patch #6

syd@dsinc.DSI.COM (Syd Weinstein) (05/03/89)

Summary: This is an official patch for elm 2.2 system.  Please apply it.
Priority: MEDIUM

When you convert from printf to curses, you must remember that it treats
\n as a RAW \n, and that you must also send \r.  Either that or make
sure the _col variable gets reset to the proper column.
From: jbuck@epimass.EPI.COM (Joe Buck)

Need to go leave raw mode before doing shell escapes and system() calls.
These changes of mode were accidentally removed when the builtin editor
was fixed by making it operate in raw mode.
From: Rob Bernardo <clib!rob>

Remove extra definition of whitespace from src/string2.c

Allow setvbuf not to exist, silently.  It is for efficiency only.

Make termio routine code depend on TERMIO symbol not BSD symbol in src/init.c

The function remove_possible_trailing_spaces could 'spin backwards' over
a great deal more than its input.... consider the case that the input contained
nothing but whitespace characters.  Also, the original nulls out every trailing
whitespace character, not just the first.
From: Randy Wright <convex!rwright>

Added missing routine name to usage call in newmail.

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:
		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
	syd@dsinc.UUCP

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

	Subject: patch list
	send index elm

Index: hdrs/patchlevel.h
Prereq: 5
*** ../elm2.2/hdrs/patchlevel.h	Fri Apr 28 16:05:18 1989
--- hdrs/patchlevel.h	Wed May  3 09:25:56 1989
***************
*** 1 ****
! #define PATCHLEVEL 5
--- 1 ----
! #define PATCHLEVEL 6

Index: filter/utils.c
Prereq: 2.5
*** ../elm2.2/filter/utils.c	Thu Mar 30 10:34:21 1989
--- filter/utils.c	Wed May  3 09:05:20 1989
***************
*** 1,8 ****
  
! static char rcsid[] ="@(#)$Id: utils.c,v 2.5 89/03/25 21:45:20 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.5 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] ="@(#)$Id: utils.c,v 2.6 89/05/03 09:05:05 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.6 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
***************
*** 14,19 ****
--- 14,22 ----
   *
   *******************************************************************************
   * $Log:	utils.c,v $
+  * Revision 2.6  89/05/03  09:05:05  syd
+  * setvbuf is for efficiency, allow it not to exist silently
+  * 
   * Revision 2.5  89/03/25  21:45:20  syd
   * Initial 2.2 Release checkin
   * 
***************
*** 72,78 ****
--- 75,83 ----
  	  fd = stdout;
  	}
  	
+ #ifdef _IOFBF
  	setvbuf(fd, NULL, _IOFBF, BUFSIZ);
+ #endif
  
  	if (strlen(from) + strlen(subject) > 60)
  	  fprintf(fd, "\nMail from %s\n\tabout %s\n", from, subject);

Index: src/editmsg.c
Prereq: 2.15
*** ../elm2.2/src/editmsg.c	Wed Apr 26 12:12:05 1989
--- src/editmsg.c	Wed May  3 08:54:40 1989
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: editmsg.c,v 2.15 89/04/26 11:39:10 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.15 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: editmsg.c,v 2.17 89/05/03 08:54:38 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.17 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
***************
*** 14,19 ****
--- 14,28 ----
   *
   *******************************************************************************
   * $Log:	editmsg.c,v $
+  * Revision 2.17  89/05/03  08:54:38  syd
+  * Need to go leave raw mode before doing shell escapes and system() calls.
+  * These changes of mode were accidentally removed when the builtin editor
+  * was fixed by making it operate in raw mode.
+  * From: Rob Bernardo <clib!rob>
+  * 
+  * Revision 2.16  89/05/03  08:53:40  syd
+  * Make it use cr/lf on output
+  * 
   * Revision 2.15  89/04/26  11:39:10  syd
   * Fix the pattern-matching feature of ~f/~m in the builtin editor
   * and fix the documentation for the builtin editor in the Reference Guide.
***************
*** 71,77 ****
  	    instead... **/
  
  	char buffer[SLEN];
! 	register int stat, return_value = 0;
  
  	buffer[0] = '\0';
  
--- 80,86 ----
  	    instead... **/
  
  	char buffer[SLEN];
! 	register int stat, return_value = 0, old_raw;
  
  	buffer[0] = '\0';
  
***************
*** 88,93 ****
--- 97,105 ----
  
  	chown(filename, userid, groupid);	/* file was owned by root! */
  
+ 	if (( old_raw = RawState()) == ON)
+ 	  Raw(OFF);
+ 
  	if (cursor_control)
  	  transmit_functions(OFF);		/* function keys are local */
  
***************
*** 103,108 ****
--- 115,123 ----
  	  return_value = 1;
  	}
  
+ 	if (old_raw == ON)
+ 	   Raw(ON);
+ 
  	if (cursor_control)
  	  transmit_functions(ON);		/* function keys are local */
  	
***************
*** 134,140 ****
  
  	FILE *edit_fd;
  	char buffer[SLEN], editor_name[SLEN], buf[SLEN];
! 	int      edit_interrupt();
  #ifdef VOIDSIG
  	void	(*oldint)(), (*oldquit)();
  #else
--- 149,155 ----
  
  	FILE *edit_fd;
  	char buffer[SLEN], editor_name[SLEN], buf[SLEN];
! 	int      edit_interrupt(), old_raw;
  #ifdef VOIDSIG
  	void	(*oldint)(), (*oldquit)();
  #else
***************
*** 278,284 ****
--- 293,303 ----
  			   else {
  			     sprintf(buf, " > %s.%d 2>&1", temp_edit, getpid());
  			     strcat(buffer, buf);
+ 			     if (( old_raw = RawState()) == ON)
+ 			       Raw(OFF);
  			     (void) system_call((char *) buffer+2, SH, TRUE);
+ 			     if (old_raw == ON)
+ 			        Raw(ON);
  			     sprintf(buffer, "~r %s.%d", temp_edit, getpid());
  	      	             read_in_file(edit_fd, (char *) buffer + 3, 0);
  			     (void) unlink((char *) buffer+3);
***************
*** 286,296 ****
--- 305,319 ----
  	                   goto more_input; 
  
  		case '!' : NewLine();
+ 			   if (( old_raw = RawState()) == ON)
+ 			     Raw(OFF);
  			   if (strlen(buffer) < 3) 
  			     (void) system_call(shell, USER_SHELL, TRUE);
  			   else
  	                     (void) system_call((char *) buffer+2,
  			       USER_SHELL, TRUE);
+ 			   if (old_raw == ON)
+ 			      Raw(ON);
  	    		   Write_to_screen(SIMPLE_CONTINUE, 0);
  			   goto more_input;
  
***************
*** 489,496 ****
  	Write_to_screen("Bcc: %s\n\r", 1, format_long(bcc, 5));
  	Write_to_screen("Subject: %s\n\r\n\r", 1, subject);
  
! 	while (fgets(buffer, SLEN, edit_fd) != NULL)
  	  Write_to_screen(buffer, 0);
  
  	fclose(edit_fd);
  
--- 512,521 ----
  	Write_to_screen("Bcc: %s\n\r", 1, format_long(bcc, 5));
  	Write_to_screen("Subject: %s\n\r\n\r", 1, subject);
  
! 	while (fgets(buffer, SLEN, edit_fd) != NULL) {
  	  Write_to_screen(buffer, 0);
+ 	  CarriageReturn();
+         }
  
  	fclose(edit_fd);
  

Index: src/init.c
Prereq: 2.26
*** ../elm2.2/src/init.c	Mon Apr 24 20:57:34 1989
--- src/init.c	Wed May  3 09:13:14 1989
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: init.c,v 2.26 89/04/24 20:47:04 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.26 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: init.c,v 2.27 89/05/03 09:13:06 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.27 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
***************
*** 14,19 ****
--- 14,22 ----
   *
   *******************************************************************************
   * $Log:	init.c,v $
+  * Revision 2.27  89/05/03  09:13:06  syd
+  * Make termio defines depend on termio
+  * 
   * Revision 2.26  89/04/24  20:47:04  syd
   * Change includes for consistency
   * From: Jim Brown <jim@umigw.miami.edu>
***************
*** 372,384 ****
  	    ERASE and KILL for use in the input routine.  The meaning 
              of the characters are (dare I say it?) fairly obvious... **/
  
! #ifdef BSD
  	struct sgttyb term_buffer;
  
  # define TCGETA	TIOCGETP
  
- #else 
- 	struct termio term_buffer;
  #endif
  
  	if (ioctl(STANDARD_INPUT, TCGETA, &term_buffer) == -1) {
--- 375,387 ----
  	    ERASE and KILL for use in the input routine.  The meaning 
              of the characters are (dare I say it?) fairly obvious... **/
  
! #ifdef TERMIO
! 	struct termio term_buffer;
! #else 
  	struct sgttyb term_buffer;
  
  # define TCGETA	TIOCGETP
  
  #endif
  
  	if (ioctl(STANDARD_INPUT, TCGETA, &term_buffer) == -1) {
***************
*** 390,401 ****
  	  kill_line = ctrl('U');
  	}
  	else {
! #ifdef BSD
! 	  backspace = term_buffer.sg_erase;
! 	  kill_line = term_buffer.sg_kill;
! #else
  	  backspace = term_buffer.c_cc[VERASE];
  	  kill_line = term_buffer.c_cc[VKILL];
  #endif
  	}
  }
--- 393,404 ----
  	  kill_line = ctrl('U');
  	}
  	else {
! #ifdef TERMIO
  	  backspace = term_buffer.c_cc[VERASE];
  	  kill_line = term_buffer.c_cc[VKILL];
+ #else
+ 	  backspace = term_buffer.sg_erase;
+ 	  kill_line = term_buffer.sg_kill;
  #endif
  	}
  }

Index: src/string2.c
Prereq: 2.5
*** ../elm2.2/src/string2.c	Mon Apr 24 20:27:43 1989
--- src/string2.c	Wed May  3 09:18:38 1989
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: string2.c,v 2.5 89/04/24 20:25:30 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.5 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: string2.c,v 2.7 89/05/03 09:18:24 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.7 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
***************
*** 14,19 ****
--- 14,25 ----
   *
   *******************************************************************************
   * $Log:	string2.c,v $
+  * Revision 2.7  89/05/03  09:18:24  syd
+  * Fix ability to write before start of string
+  * 
+  * Revision 2.6  89/05/03  09:00:24  syd
+  * Remove extra definition of whitespace
+  * 
   * Revision 2.5  89/04/24  20:25:30  syd
   * Move shift_lower
   * 
***************
*** 43,51 ****
  #undef toupper
  #endif
  
- 
- #define whitespace(c)		(c == ' ' || c == '\t')
- 
  char *shift_lower(string)
  char *string;
  {
--- 49,54 ----
***************
*** 182,189 ****
  
  	register int i;
  
! 	for (i=strlen(string)-1; whitespace(string[i]); i--)
! 		/** spin backwards **/
  
  	string[i+1] = '\0';	/* note that even in the worst case when there
  				   are no trailing spaces at all, we'll simply
--- 185,192 ----
  
  	register int i;
  
! 	for ( i = strlen(string); --i >= 0 && whitespace(string[i]); )
! 		/** spin backwards, semicolon intented **/ ;
  
  	string[i+1] = '\0';	/* note that even in the worst case when there
  				   are no trailing spaces at all, we'll simply

Index: utils/newmail.c
Prereq: 2.18
*** ../elm2.2/utils/newmail.c	Wed Apr 26 12:12:08 1989
--- utils/newmail.c	Wed May  3 09:23:51 1989
***************
*** 1,8 ****
  
! static char rcsid[] = "@(#)$Id: newmail.c,v 2.18 89/04/26 12:05:52 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.18 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
--- 1,8 ----
  
! static char rcsid[] = "@(#)$Id: newmail.c,v 2.19 89/05/03 09:23:45 syd Exp $";
  
  /*******************************************************************************
!  *  The Elm Mail System  -  $Revision: 2.19 $   $State: Exp $
   *
   * 			Copyright (c) 1986, 1987 Dave Taylor
   * 			Copyright (c) 1988, 1989 USENET Community Trust
***************
*** 14,19 ****
--- 14,22 ----
   *
   *******************************************************************************
   * $Log:	newmail.c,v $
+  * Revision 2.19  89/05/03  09:23:45  syd
+  * fix missing name
+  * 
   * Revision 2.18  89/04/26  12:05:52  syd
   * add better from_whom controls
   * 
***************
*** 156,162 ****
  	    case 'd' : debug++;					break;
  	    case 'i' : interval_time = atoi(optarg);		break;
  	    case 'w' : in_window = 1;				break;
! 	    default  : usage();					exit(1);
  	 }
  	}
  
--- 159,165 ----
  	    case 'd' : debug++;					break;
  	    case 'i' : interval_time = atoi(optarg);		break;
  	    case 'w' : in_window = 1;				break;
! 	    default  : usage(argv[0]);				exit(1);
  	 }
  	}
  
***************
*** 686,697 ****
  	return( (char *) return_value);
  }
  
! usage()
  {
  	/* print a nice friendly usage message */
  
  	fprintf(stderr, 
! "\nUsage: %s [-d] [-i interval] [-w] {folders}\n");
  	fprintf(stderr, "\nWhere:\n");
  	fprintf(stderr, "  -d\tturns on debugging output\n");
  	fprintf(stderr,
--- 689,701 ----
  	return( (char *) return_value);
  }
  
! usage(name)
! char *name;
  {
  	/* print a nice friendly usage message */
  
  	fprintf(stderr, 
! "\nUsage: %s [-d] [-i interval] [-w] {folders}\n", name);
  	fprintf(stderr, "\nWhere:\n");
  	fprintf(stderr, "  -d\tturns on debugging output\n");
  	fprintf(stderr,

-- 
=====================================================================
Sydney S. Weinstein, CDP, CCP                   Elm Coordinator
Datacomp Systems, Inc.				Voice: (215) 947-9900
syd@DSI.COM or {bpa,vu-vlsi}!dsinc!syd	        FAX:   (215) 938-0235