updates from John Kunze
authorJim Bloom <bloom@ucbvax.Berkeley.EDU>
Fri, 16 May 1986 08:59:01 +0000 (00:59 -0800)
committerJim Bloom <bloom@ucbvax.Berkeley.EDU>
Fri, 16 May 1986 08:59:01 +0000 (00:59 -0800)
SCCS-vsn: usr.bin/learn/Makefile 4.4
SCCS-vsn: usr.bin/learn/README 4.3
SCCS-vsn: usr.bin/learn/learn/copy.c 4.3
SCCS-vsn: usr.bin/learn/learn/learn.c 4.4
SCCS-vsn: usr.bin/learn/learn/lrnref.h 4.4
SCCS-vsn: usr.bin/learn/lrntee/lrntee.c 4.3
SCCS-vsn: usr.bin/learn/learn/makpipe.c 4.3
SCCS-vsn: usr.bin/learn/learn/mem.c 4.3
SCCS-vsn: usr.bin/learn/learn/mysys.c 4.5
SCCS-vsn: usr.bin/learn/learn/selsub.c 4.3
SCCS-vsn: usr.bin/learn/learn/selunit.c 4.3
SCCS-vsn: usr.bin/learn/learn/start.c 4.5
SCCS-vsn: usr.bin/learn/learn/wrapup.c 4.3

13 files changed:
usr/src/usr.bin/learn/Makefile
usr/src/usr.bin/learn/README
usr/src/usr.bin/learn/learn/copy.c
usr/src/usr.bin/learn/learn/learn.c
usr/src/usr.bin/learn/learn/lrnref.h
usr/src/usr.bin/learn/learn/makpipe.c
usr/src/usr.bin/learn/learn/mem.c
usr/src/usr.bin/learn/learn/mysys.c
usr/src/usr.bin/learn/learn/selsub.c
usr/src/usr.bin/learn/learn/selunit.c
usr/src/usr.bin/learn/learn/start.c
usr/src/usr.bin/learn/learn/wrapup.c
usr/src/usr.bin/learn/lrntee/lrntee.c

index 22b30b1..390c716 100644 (file)
@@ -1,7 +1,8 @@
-#      @(#)Makefile    4.3     (Berkeley)      83/06/19
+#      @(#)Makefile    4.4     (Berkeley)      86/05/15
 #
 DESTDIR=
 
 #
 DESTDIR=
 
+# The vi lessons come with the user-contributed software.
 LESSONS = files editor morefiles macros eqn C
 
 FILES = lrnref.h \
 LESSONS = files editor morefiles macros eqn C
 
 FILES = lrnref.h \
@@ -15,7 +16,8 @@ OBJECTS = copy.o dounit.o getlesson.o learn.o list.o mem.o \
        makpipe.o maktee.o mysys.o selsub.o selunit.o \
        start.o whatnow.o wrapup.o
 
        makpipe.o maktee.o mysys.o selsub.o selunit.o \
        start.o whatnow.o wrapup.o
 
-CFLAGS = -O
+# Flag BSD4_2 means 4.2 or later.
+CFLAGS = -O -DBSD4_2
 LIBRARY =
 LLIB   = $(DESTDIR)/usr/lib/learn/bin
 
 LIBRARY =
 LLIB   = $(DESTDIR)/usr/lib/learn/bin
 
@@ -27,11 +29,6 @@ install:     all
        install -s lrntee $(LLIB)
        install -s lcount $(LLIB)
 
        install -s lrntee $(LLIB)
        install -s lcount $(LLIB)
 
-ccinstall:     all
-       cp learn lrntee lcount $(LLIB)
-       chmod 755 $(LLIB)/*
-       strip $(LLIB)/*
-
 clean:
        rm -f *.o learn lrntee lcount errs
 
 clean:
        rm -f *.o learn lrntee lcount errs
 
index c5118f3..9065c5d 100644 (file)
@@ -1,8 +1,15 @@
+Important changes since 4.2:
+       Now uses 4.2 filesystem correctly and removes files between lessons.
+       Tee'd output to the .ocopy file works.  No more infinite loop on EOF.
+       Now maintains a .learnrc file to start you where you left off last
+       session.  The undocumented and dubious "xyzzy" command has become
+       the documented and dubious "hint" command.  Miscellaneous typos.
+
 Note that play directories are created in /tmp, no longer
 in /usr/lib/learn/play.  The C script is not complete;
 use at your own risk.  The editor script still smacks of ed.
 
 Note that play directories are created in /tmp, no longer
 in /usr/lib/learn/play.  The C script is not complete;
 use at your own risk.  The editor script still smacks of ed.
 
-Lessons are in
+Lessons are in (vi lessons are on user-contributed-software tape)
        /usr/lib/learn/*
 and auxilliary programs are in
        /usr/lib/learn/bin
        /usr/lib/learn/*
 and auxilliary programs are in
        /usr/lib/learn/bin
@@ -16,15 +23,14 @@ you're probably in good shape.
 
 Lesson directories may be protected.
 
 
 Lesson directories may be protected.
 
-Learn collects a log file for each script in the .../learn/log
-directory, with a file for each script (files, editor, etc.)
-containing an entry for each lesson attempted.
-These files will grow without bound,
+Learn keeps a log file for each script in the .../learn/log
+directory (files, editor, etc.) containing an entry for each
+lesson attempted.  These files will grow without bound,
 unless they are periodically truncated. 
 The log files should have general write permission.
 If you don't want logging (a sensible position to take),
 set the variable "logging" to zero in source/learn.c
 unless they are periodically truncated. 
 The log files should have general write permission.
 If you don't want logging (a sensible position to take),
 set the variable "logging" to zero in source/learn.c
-before making learn, remove the log directory, or just
+before making learn, or remove the log directory, or just
 turn off write permission for a particular log file.
 
 Learn requires about 1500 blocks to make itself,
 turn off write permission for a particular log file.
 
 Learn requires about 1500 blocks to make itself,
@@ -36,22 +42,25 @@ the user's environment variables PATH and EXINIT.
 Due to inane assumptions in the VAX versions of csh -i and ex
 when stdin and stdout are not terminals, kludges have been
 added with #if's.  In particular, I use the old terminal driver
 Due to inane assumptions in the VAX versions of csh -i and ex
 when stdin and stdout are not terminals, kludges have been
 added with #if's.  In particular, I use the old terminal driver
-to keep #copyout working and make sh -i masquerades as
+to keep #copyout working and make sh -i masquerade as
 a csh -i (by setting PS1=% ) to keep #pipe working.
 
 a csh -i (by setting PS1=% ) to keep #pipe working.
 
-"#create" can now end in an incomplete last line with ....#\n
-On input the string %s is converted to the lesson directory.
+"#create" can now end in an incomplete last line by making '#'
+the last character on the line.  On input the string %s is
+converted to the lesson directory (useful for debugging).
 On output with "#copyout", prompt signs ("% ") are removed.
 On output with "#copyout", prompt signs ("% ") are removed.
-"#cmp" now takes a trailing number specifying that only that
+"#cmp" now takes a trailing NUMBER specifying that only NUMBER
 many lines are to be compared.
 
 many lines are to be compared.
 
-The new command "xyzzy" prints the answer (i.e. the last part
-of the lesson), and "xyzzy x" prints the whole lesson text.
+The new command "hint" prints the "answer" (i.e. the last part
+of the lesson).  With an argument it prints the whole lesson text.
 A new routine called getlesson tries to construct a valid
 lesson number from in invalid one before giving up.
 The commands "where", "skip", and "again" are also new.
 Greeting, closing, and reminder messages have been expanded.
 
 A new routine called getlesson tries to construct a valid
 lesson number from in invalid one before giving up.
 The commands "where", "skip", and "again" are also new.
 Greeting, closing, and reminder messages have been expanded.
 
-Please report problems, bad lessons, contributions, etc., to
-John Kunze, UC Berkeley, 415-642-1530, ucbvax!ucbernie.jak .
-Thanks.
+The "vi" lessons are packaged separately as part of the user-
+contributed software.  Ask the system administrator to install them.
+
+Please report problems, bad lessons, contributions, etc.,
+to John Kunze, jak@ernie.Berkeley.EDU.  Thanks.
index e56d061..e42c308 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)copy.c     4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)copy.c     4.3     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -34,6 +34,7 @@ FILE *fin;
                        if (fin == stdin) {
                                fprintf(stderr, "Type \"bye\" if you want to leave learn.\n");
                                fflush(stderr);
                        if (fin == stdin) {
                                fprintf(stderr, "Type \"bye\" if you want to leave learn.\n");
                                fflush(stderr);
+                               clearerr(stdin);
                                continue;
                        } else
                                break;
                                continue;
                        } else
                                break;
@@ -88,7 +89,7 @@ FILE *fin;
                        else
                                scopy(fin, stdout);
                        break;
                        else
                                scopy(fin, stdout);
                        break;
-               case XYZZY:
+               case HINT:
                        mark = ftell(scrin);
                        if (r)
                                rewind(scrin);
                        mark = ftell(scrin);
                        if (r)
                                rewind(scrin);
@@ -142,6 +143,7 @@ FILE *fin;
                                noclobber = 0;
                        more = 1;
                        return;
                                noclobber = 0;
                        more = 1;
                        return;
+               /* "again previous_lesson" has a hard-to-reproduce bug */
                case AGAIN:
                        review = 0;
                        if (!r) {
                case AGAIN:
                        review = 0;
                        if (!r) {
@@ -204,7 +206,7 @@ FILE *fin;
                        printf("You are already in learn.\n");
                        fflush(stdout);
                        break;
                        printf("You are already in learn.\n");
                        fflush(stdout);
                        break;
-               case LOG:
+               case LOG:       /* logfiles should be created mode 666 */
                        if (!logging)
                                break;
                        if (logf[0] == 0)
                        if (!logging)
                                break;
                        if (logf[0] == 0)
index 674d92a..f2dff30 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)learn.c    4.3     (Berkeley)      %G%";
+static char sccsid[] = "@(#)learn.c    4.4     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -33,11 +33,15 @@ int argc;
 char *argv[];
 {
        extern hangup(), intrpt();
 char *argv[];
 {
        extern hangup(), intrpt();
-       extern char * getlogin();
+       extern char * getlogin(), *malloc();
 
        speed = 0;
        more = 1;
        pwline = getlogin();
 
        speed = 0;
        more = 1;
        pwline = getlogin();
+#ifndef BSD4_2
+       setbuf(stdout, malloc(BUFSIZ));
+       setbuf(stderr, malloc(BUFSIZ));
+#endif
        selsub(argc, argv);
        chgenv();
        signal(SIGHUP, hangup);
        selsub(argc, argv);
        chgenv();
        signal(SIGHUP, hangup);
index 9387fff..231895a 100644 (file)
@@ -1,4 +1,4 @@
-/*     lrnref.h        4.3     83/08/11        */
+/*     lrnref.h        4.4     86/05/15        */
 
 #define        READY   0
 #define        PRINT   1
 
 #define        READY   0
 #define        PRINT   1
@@ -28,7 +28,7 @@
 #define        CMP     25
 #define        ONCE    26
 #define        AGAIN   27
 #define        CMP     25
 #define        ONCE    26
 #define        AGAIN   27
-#define XYZZY  28
+#define        HINT    28
 
 extern int     more;
 extern char    *level;
 
 extern int     more;
 extern char    *level;
index 932fa27..44bcdbd 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)makpipe.c  4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)makpipe.c  4.3     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -14,7 +14,7 @@ makpipe()
                close(0);
                dup(f[0]);
                close(f[0]);
                close(0);
                dup(f[0]);
                close(f[0]);
-#if vax
+#if BSD4_2
                execl ("/bin/sh", "sh", "-i", 0);
                execl ("/usr/ucb/bin/sh", "sh", "-i", 0);
 #else
                execl ("/bin/sh", "sh", "-i", 0);
                execl ("/usr/ucb/bin/sh", "sh", "-i", 0);
 #else
index 71dfca6..b855c09 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mem.c      4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)mem.c      4.3     (Berkeley)      %G%";
 #endif not lint
 
 # include "stdio.h"
 #endif not lint
 
 # include "stdio.h"
@@ -38,7 +38,7 @@ struct keys {
        {"#bad",        BAD},
        {"#create",     CREATE},
        {"#cmp",        CMP},
        {"#bad",        BAD},
        {"#create",     CREATE},
        {"#cmp",        CMP},
-       {"xyzzy",       XYZZY},
+       {"hint",        HINT},
        {"#once",       ONCE},
        {"#",           NOP},
        {NULL,          0}
        {"#once",       ONCE},
        {"#",           NOP},
        {NULL,          0}
index d84ef4c..0006471 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mysys.c    4.4     (Berkeley)      %G%";
+static char sccsid[] = "@(#)mysys.c    4.5     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -30,7 +30,7 @@ chgenv()
 
        sprintf(path, "PATH=%s/bin:/usr/cc/bin:/usr/ucb/bin:", direct);
        sprintf(exinit, "EXINIT=set prompt noopt open window=23");
 
        sprintf(path, "PATH=%s/bin:/usr/cc/bin:/usr/ucb/bin:", direct);
        sprintf(exinit, "EXINIT=set prompt noopt open window=23");
-#if vax
+#if BSD4_2
        system("stty old");
        for (p=environ,i=3; *p != 0 && i < EMAX; p++,i++)   {
 #else
        system("stty old");
        for (p=environ,i=3; *p != 0 && i < EMAX; p++,i++)   {
 #else
@@ -43,7 +43,7 @@ chgenv()
                        sprintf(path, "PATH=%s/bin:%s", direct, &envp[i--][5]);
                else if (strncmp(*p, "EXINIT=", 7) == 0)
                        sprintf(exinit, "%s|set prompt noopt open window=23", envp[i--]);
                        sprintf(path, "PATH=%s/bin:%s", direct, &envp[i--][5]);
                else if (strncmp(*p, "EXINIT=", 7) == 0)
                        sprintf(exinit, "%s|set prompt noopt open window=23", envp[i--]);
-#if vax
+#if BSD4_2
                else if (strncmp(*p, "PS1=", 4) == 0)
                        i--;
        }
                else if (strncmp(*p, "PS1=", 4) == 0)
                        i--;
        }
index a8c32f5..5d3ec78 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)selsub.c   4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)selsub.c   4.3     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -7,14 +7,18 @@ static char sccsid[] = "@(#)selsub.c  4.2     (Berkeley)      %G%";
 #include "sys/stat.h"
 #include "lrnref.h"
 
 #include "sys/stat.h"
 #include "lrnref.h"
 
+char learnrc[100];
+
 selsub(argc,argv)
 char *argv[];
 {
        char ans1[100];
 selsub(argc,argv)
 char *argv[];
 {
        char ans1[100];
-       static char ans2[30];
-       static char dirname[20];
-       static char subname[20];
-       struct stat statbuf;
+       static char ans2[40];
+       static char dirname[40];
+       static char subname[40];
+       FILE *fp;
+       char *getenv();
+       char *home;
 
        if (argc > 1 && argv[1][0] == '-') {
                direct = argv[1]+1;
 
        if (argc > 1 && argv[1][0] == '-') {
                direct = argv[1]+1;
@@ -31,13 +35,36 @@ char *argv[];
                strcpy (level=ans2, argv[2]);
                if (strcmp(level, "-") == 0)    /* no lesson name is - */
                        ask = 1;
                strcpy (level=ans2, argv[2]);
                if (strcmp(level, "-") == 0)    /* no lesson name is - */
                        ask = 1;
+               else if (strcmp(level, "0") == 0)
+                       level = 0;
                else
                else
-                       again = 1;      /* treat as if "again lesson" */
+                       again = 1;      /* treat as if "again" lesson */
        }
        else
                level = 0;
        if (argc > 3 )
                speed = atoi(argv[3]);
        }
        else
                level = 0;
        if (argc > 3 )
                speed = atoi(argv[3]);
+       if ((home = getenv("HOME")) != NULL) {
+               sprintf(learnrc, "%s/.learnrc", home);
+               if ((fp=fopen(learnrc, "r")) != NULL) {
+                       char xsub[40], xlev[40]; int xsp;
+                       fscanf(fp, "%s %s %d", xsub, xlev, &xsp);
+                       fclose(fp);
+                       if (*xsub && *xlev && xsp >= 0  /* all read OK */
+                           && (argc == 2 && strcmp(sname, xsub) == 0
+                             || argc <= 1)) {
+                               strcpy(sname = subname, xsub);
+                               strcpy(level = ans2, xlev);
+                               speed = xsp;
+                               again = 1;
+       printf("[ Taking up where you left off last time:  learn %s %s.\n",
+               sname, level);
+       printf("%s\n  \"rm $HOME/.learnrc\", and re-enter with \"learn %s\". ]\n",
+               "  To start this sequence over leave learn by typing \"bye\", then",
+               sname);
+                       }
+               }
+       }
        if (!sname) {
                printf("These are the available courses -\n");
                list("Linfo");
        if (!sname) {
                printf("These are the available courses -\n");
                list("Linfo");
@@ -57,8 +84,7 @@ char *argv[];
                }
        }
        chknam(sname);
                }
        }
        chknam(sname);
-       stat(sname, &statbuf);
-       total = statbuf.st_size / 16 - 2;       /* size/dirsize-(.+..) */
+       total = cntlessons(sname);
        if (!level) {
                printf("If you were in the middle of this subject\n");
                printf("and want to start where you left off, type\n");
        if (!level) {
                printf("If you were in the middle of this subject\n");
                printf("and want to start where you left off, type\n");
@@ -71,7 +97,10 @@ char *argv[];
                gets(ans2);
                if (ans2[0]==0)
                        strcpy(ans2,"0");
                gets(ans2);
                if (ans2[0]==0)
                        strcpy(ans2,"0");
+               else
+                       again = 1;
                level=ans2;
                level=ans2;
+               getlesson();
        }
 
        /* make new directory for user to play in */
        }
 
        /* make new directory for user to play in */
@@ -105,3 +134,34 @@ char *name;
                exit(1);
        }
 }
                exit(1);
        }
 }
+
+#ifndef DIR
+#include <sys/dir.h>
+#endif
+
+cntlessons(sname)      /* return number of entries in lesson directory; */
+char *sname;           /* approximate at best since I don't count L0, Init */
+{                      /* and lessons skipped by good students */
+#if BSD4_2
+       struct direct dbuf;
+       register struct direct *ep = &dbuf;     /* directory entry pointer */
+       int n = 0;
+       DIR *dp;
+
+       if ((dp = opendir(sname)) == NULL) {
+               perror(sname);
+               wrapup(1);
+       }
+       for (ep = readdir(dp); ep != NULL; ep = readdir(dp)) {
+               if (ep->d_ino != 0)
+                       n++;
+       }
+       closedir(dp);
+       return n - 2;                           /* minus . and .. */
+#else
+       struct stat statbuf;
+
+       stat(sname, &statbuf);
+       return statbuf.st_size / 16 - 2;
+#endif
+}
index adcf962..02b7439 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)selunit.c  4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)selunit.c  4.3     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -58,7 +58,7 @@ retry:
                printf("Congratulations; you have finished this sequence.\n");
                fflush(stdout);
                todo = 0;
                printf("Congratulations; you have finished this sequence.\n");
                fflush(stdout);
                todo = 0;
-               return;
+               wrapup(-1);
        }
        for(i=0; fgets(s, 80, f); i++) {
                sscanf(s, "%s %d", posslev[i], &diff[i]);
        }
        for(i=0; fgets(s, 80, f); i++) {
                sscanf(s, "%s %d", posslev[i], &diff[i]);
index 6e2a402..fb58b21 100644 (file)
@@ -1,13 +1,13 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)start.c    4.4     (Berkeley)      %G%";
+static char sccsid[] = "@(#)start.c    4.5     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #include "lrnref.h"
 #include <sys/types.h>
 #endif not lint
 
 #include "stdio.h"
 #include "lrnref.h"
 #include <sys/types.h>
+#ifndef DIR
 #include <sys/dir.h>
 #include <sys/dir.h>
-
-#define BSD4_2 1
+#endif
 
 start(lesson)
 char *lesson;
 
 start(lesson)
 char *lesson;
@@ -17,11 +17,10 @@ char *lesson;
        int c, n;
        char where [100];
 
        int c, n;
        char where [100];
 
-#if BSD4_2
+#ifdef BSD4_2
        DIR *dp;
 #define OPENDIR(s)     ((dp = opendir(s)) != NULL)
 #define DIRLOOP(s)     for (s = readdir(dp); s != NULL; s = readdir(dp))
        DIR *dp;
 #define OPENDIR(s)     ((dp = opendir(s)) != NULL)
 #define DIRLOOP(s)     for (s = readdir(dp); s != NULL; s = readdir(dp))
-#define PATHSIZE 256
 #define EPSTRLEN       ep->d_namlen
 #define CLOSEDIR       closedir(dp)
 #else
 #define EPSTRLEN       ep->d_namlen
 #define CLOSEDIR       closedir(dp)
 #else
@@ -32,7 +31,10 @@ char *lesson;
 #define CLOSEDIR       close(f)
 #endif
 
 #define CLOSEDIR       close(f)
 #endif
 
-       OPENDIR(".");                           /* clean up play directory */
+       if (!OPENDIR(".")) {            /* clean up play directory */
+               perror("Start:  play directory");
+               wrapup(1);
+       }
        DIRLOOP(ep) {
                if (ep->d_ino == 0)
                        continue;
        DIRLOOP(ep) {
                if (ep->d_ino == 0)
                        continue;
index 7f9bb48..9c0437a 100644 (file)
@@ -1,21 +1,24 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wrapup.c   4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)wrapup.c   4.3     (Berkeley)      %G%";
 #endif not lint
 
 #include "signal.h"
 #include "stdio.h"
 #include "lrnref.h"
 
 #endif not lint
 
 #include "signal.h"
 #include "stdio.h"
 #include "lrnref.h"
 
+extern char learnrc[];
+
 wrapup(n)
 int n;
 {
 wrapup(n)
 int n;
 {
+       FILE *fp;
 /* this routine does not use 'system' because it wants interrupts turned off */
 
        signal(SIGINT, SIG_IGN);
        chdir("..");
        if (fork() == 0) {
                signal(SIGHUP, SIG_IGN);
 /* this routine does not use 'system' because it wants interrupts turned off */
 
        signal(SIGINT, SIG_IGN);
        chdir("..");
        if (fork() == 0) {
                signal(SIGHUP, SIG_IGN);
-#if vax
+#if BSD4_2
                if (fork() == 0) {
                        close(1);
                        open("/dev/tty", 1);
                if (fork() == 0) {
                        close(1);
                        open("/dev/tty", 1);
@@ -28,8 +31,14 @@ int n;
                fprintf(stderr, "Wrapup:  can't find 'rm' command.\n");
                exit(0);
        }
                fprintf(stderr, "Wrapup:  can't find 'rm' command.\n");
                exit(0);
        }
-       if (!n && todo)
-               printf("To take up where you left off type \"learn %s %s\".\n", sname, todo);
+       if (n == -1)
+               unlink(learnrc);
+       else if (!n && todo) {
+               if ((fp=fopen(learnrc, "w")) == NULL)
+                       exit(0);
+               fprintf(fp, "%s %s %d\n", sname, todo, speed);
+               fclose(fp);
+       }
        printf("Bye.\n");       /* not only does this reassure user but it
                                stalls for time while deleting directory */
        fflush(stdout);
        printf("Bye.\n");       /* not only does this reassure user but it
                                stalls for time while deleting directory */
        fflush(stdout);
index ba3e522..ec74fc8 100644 (file)
@@ -1,10 +1,11 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)lrntee.c   4.2     (Berkeley)      %G%";
+static char sccsid[] = "@(#)lrntee.c   4.3     (Berkeley)      %G%";
 #endif not lint
 
 main()
 {
 #endif not lint
 
 main()
 {
-       int f, c;
+       int f;
+       char c;
 
        f = creat(".ocopy", 0666);
        while (read(0, &c, 1) == 1) {
 
        f = creat(".ocopy", 0666);
        while (read(0, &c, 1) == 1) {