[comp.os.minix] fix for sh parser bug after SIGINT

bob@dhw68k.cts.com (Bob Best) (10/28/88)

A week or so ago, I reported a minor, yet annoying, bug involving the
shell's lack of recognition of keywords such as for, while, until, if,
case, etc. after the DEL key was pressed (i.e. after a SIGINT.)  The
following patch fixes the problem.  The bug was caused by failure to set
the variable 'startl' to 1 after a SIGINT.  When the parser restarted,
it assumed that it was not at the start of a line, hence the various
keywords failed to be properly parsed.  The variable 'startl' had to be
given global scope to be seen by onintr().

Bob
---------------------
Index: sh1.c
*** /bram0/sh.old/./sh1.c	Mon Oct 10 20:58:24 1988
--- ./sh1.c	Fri Oct 28 00:16:01 1988
***************
*** 3,8 ****
--- 3,9 ----
  #include <errno.h>
  #include <setjmp.h>
  #include "sh.h"
+ extern int startl;
  /* -------- sh.c -------- */
  /*
   * shell
***************
*** 396,401 ****
--- 397,403 ----
  onintr()
  {
  	signal(SIGINT, SIG_IGN);
+ 	startl = 1; /* fix for parser bug on for, while, until, etc. after SIGINT */
  	if (inparse) {
  		prs("\n");
  		fail();

Index: sh2.c
*** /bram0/sh.old/./sh2.c	Mon Oct 10 20:58:25 1988
--- ./sh2.c	Thu Oct 27 23:51:27 1988
***************
*** 39,45 ****
  
  /* #include "sh.h" */
  #define	SYNTAXERR	zzerr()
! static	int	startl = 1;
  static	int	peeksym = 0;
  static	void	zzerr();
  static	void	word();
--- 39,45 ----
  
  /* #include "sh.h" */
  #define	SYNTAXERR	zzerr()
! /*static*/	int	startl = 1;
  static	int	peeksym = 0;
  static	void	zzerr();
  static	void	word();

-- 
Bob Best
uucp: ...{trwrb,hplabs}!felix!dhw68k!bob	InterNet: bob@dhw68k.cts.com