[comp.bugs.4bsd] transient bug in vi nailed down

chris@mimsy.UUCP (Chris Torek) (01/05/89)

Chances are this bug is at least related to one I just fixed (?)
in the 4BSD vi.  There is a better way; but this was easy.

RCS file:        RCS/ex_vget.c,v;   Working file:    ex_vget.c
head:            1.3
locks:           ;  strict
access list:
symbolic names:
comment leader:  " * "
total revisions: 3;    selected revisions: 3
description:
ex/vi ex_vget.c: input for open/visual
----------------------------
revision 1.3
date: 89/01/05 01:59:18;  author: chris;  state: Exp;  lines added/del: 14/14
beware the longjmp botch, my son
the traps that bite, the race in CATCH
beware the signal call, and shun
the high-load schedule (natch)
[well, at least it rhymes]
----------------------------
revision 1.2
date: 89/01/04 08:30:28;  author: chris;  state: Exp;  lines added/del: 32/29
4.3tahoe prerelease edition: changes for ANSI C and VMS
----------------------------
revision 1.1
date: 89/01/03 17:42:23;  author: chris;  state: Exp;
Initial revision
=============================================================================
RCS file: RCS/ex_vget.c,v
retrieving revision 1.2
diff -c2 -r1.2 ex_vget.c
*** /tmp/,RCSt1018927	Thu Jan  5 02:09:13 1989
--- ex_vget.c	Thu Jan  5 02:07:44 1989
***************
*** 656,684 ****
  #ifdef MDEBUG
  	if (trace)
! 		fprintf(trace,"\nfastpeekkey: ",c);
  #endif
  	Oint = signal(SIGINT, trapalarm);
! 	if (value(TIMEOUT) && inopen >= 0) {
! 		signal(SIGALRM, trapalarm);
  #ifdef MDEBUG
! 		alarm(10);
! 		if (trace)
! 			fprintf(trace, "set alarm ");
  #else
! 		alarm(1);
  #endif
! 	}
! 	CATCH
  		c = peekkey();
  #ifdef MDEBUG
! 	if (trace)
! 		fprintf(trace,"[OK]",c);
  #endif
- 		alarm(0);
  	ONERR
  		c = 0;
  #ifdef MDEBUG
! 	if (trace)
! 		fprintf(trace,"[TIMEOUT]",c);
  #endif
  	ENDCATCH
--- 656,684 ----
  #ifdef MDEBUG
  	if (trace)
! 		fprintf(trace,"\nfastpeekkey: ");
  #endif
  	Oint = signal(SIGINT, trapalarm);
! 	CATCH
! 		if (value(TIMEOUT) && inopen >= 0) {
! 			signal(SIGALRM, trapalarm);
  #ifdef MDEBUG
! 			alarm(10);
! 			if (trace)
! 				fprintf(trace, "set alarm ");
  #else
! 			alarm(1);
  #endif
! 		}
  		c = peekkey();
+ 		alarm(0);
  #ifdef MDEBUG
! 		if (trace)
! 			fprintf(trace,"[OK]");
  #endif
  	ONERR
  		c = 0;
  #ifdef MDEBUG
! 		if (trace)
! 			fprintf(trace,"[TIMEOUT]");
  #endif
  	ENDCATCH
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris