dan@rna.UUCP (02/19/84)
Subject: Few bugs with learn Index: /usr/src/usr.bin/learn/copy.c 4.2BSD Description: 1) Typing EOT to learn causes learn to loop on error from stdin. 2) learn scripts files, eqn, vi cannot startup at all. Repeat-By: (above) Fix: 1) In the file, copy.c, add clearerr(stdin)... *** copy.c.org Tue Apr 26 03:04:22 1983 --- copy.c Sat Feb 18 18:11:11 1984 *************** *** 34,35 if (fin == stdin) { fprintf(stderr, "Type \"bye\" if you want to leave learn.\n"); --- 34,36 ----- if (fin == stdin) { + clearerr(stdin); fprintf(stderr, "Type \"bye\" if you want to leave learn.\n"); 2) chmod 755 /usr/lib/learn/files/Init /usr/lib/learn/eqn/Init \ /usr/lib/learn/vi/Init Cheers, Dan Ts'o ...cmcl2!rna!dan
smk@axiom.UUCP (Steven M. Kramer) (02/19/84)
And there is another bug ... The tty is not reset after the session in learn is over. For the files lesson, the /usr/src/usr.lib/learn/files/Init file contains a stty which is not undone by learn itself upon wrapup. The fix is to simply save the terminal state before executing Init and then restore it upon wrapup. --steve kramer diff -c follows on learn.c and wrapup.c: ----------- *** learn.c.orig Thu Jan 19 11:39:28 1984 --- learn.c Thu Jan 19 11:40:59 1984 *************** *** 5,10 #include "stdio.h" #include "lrnref.h" #include "signal.h" char *direct = "/usr/lib/learn"; /* CHANGE THIS ON YOUR SYSTEM */ int more; --- 5,16 ----- #include "stdio.h" #include "lrnref.h" #include "signal.h" + #ifdef AXIOM + /* For saving the terminal state before entering learn and then + restoring if upon exiting. + */ + #include "sgtty.h" + #endif char *direct = "/usr/lib/learn"; /* CHANGE THIS ON YOUR SYSTEM */ int more; *************** *** 27,32 int skip; int teed; int total; main(argc,argv) int argc; --- 33,48 ----- int skip; int teed; int total; + #ifdef AXIOM + /* + * Fixes a bug whereby the learn program leaves you in a stty state + * fixed by whaever program you were running. We use this sgttyb + * to save the state upon entering learn. The corresponsing reset + * code is in wrapup() in wrapup.c + * Steve Kramer 1/20/84 + */ + struct sgttyb save_terminal_state; + #endif main(argc,argv) int argc; *************** *** 36,41 extern char * getlogin(); char *malloc(); speed = 0; more = 1; pwline = getlogin(); --- 52,60 ----- extern char * getlogin(); char *malloc(); + #ifdef AXIOM + gtty (fileno (stdin), &save_terminal_state); + #endif speed = 0; more = 1; pwline = getlogin(); *** wrapup.c.orig Tue Apr 26 03:04:34 1983 --- wrapup.c Thu Jan 19 11:59:10 1984 *************** *** 5,10 #include "signal.h" #include "stdio.h" #include "lrnref.h" wrapup(n) int n; --- 5,13 ----- #include "signal.h" #include "stdio.h" #include "lrnref.h" + #ifdef AXIOM + /* For restoring the terminal state when leaving. */ + #include "sgtty.h" extern struct sgttyb save_terminal_state; #endif *************** *** 6,11 #include "stdio.h" #include "lrnref.h" wrapup(n) int n; { --- 9,17 ----- /* For restoring the terminal state when leaving. */ #include "sgtty.h" + extern struct sgttyb save_terminal_state; + #endif + wrapup(n) int n; { *************** *** 30,35 } if (!n && todo) printf("To take up where you left off type \"learn %s %s\".\n", sname, todo); printf("Bye.\n"); /* not only does this reassure user but it stalls for time while deleting directory */ fflush(stdout); --- 36,48 ----- } if (!n && todo) printf("To take up where you left off type \"learn %s %s\".\n", sname, todo); + #ifdef AXIOM + /* + * Leave the terminal the way we found it! + * Steve Kramer 1/20/84 + */ + stty (fileno (stdin), &save_terminal_state); + #endif printf("Bye.\n"); /* not only does this reassure user but it stalls for time while deleting directory */ fflush(stdout); -- --steve kramer {allegra,genrad,ihnp4,utzoo,philabs,uw-beaver}!linus!axiom!smk (UUCP) linus!axiom!smk@mitre-bedford (MIL)