A few small bugs in 4.2bsd learn...
Steven M. Kramer
smk at axiom.UUCP
Mon Feb 20 05:55:27 AEST 1984
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 at mitre-bedford (MIL)
More information about the Comp.unix.wizards
mailing list