(no message)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 26 Apr 1983 14:59:21 +0000 (06:59 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 26 Apr 1983 14:59:21 +0000 (06:59 -0800)
SCCS-vsn: usr.bin/learn/learn/learn.c 4.2
SCCS-vsn: usr.bin/learn/learn/list.c 4.2
SCCS-vsn: usr.bin/learn/learn/lrnref.h 4.2
SCCS-vsn: usr.bin/learn/learn/makpipe.c 4.2
SCCS-vsn: usr.bin/learn/learn/maktee.c 4.2
SCCS-vsn: usr.bin/learn/learn/mem.c 4.2
SCCS-vsn: usr.bin/learn/learn/mysys.c 4.2
SCCS-vsn: usr.bin/learn/learn/selsub.c 4.2
SCCS-vsn: usr.bin/learn/learn/selunit.c 4.2
SCCS-vsn: usr.bin/learn/learn/start.c 4.2

usr/src/usr.bin/learn/learn/learn.c
usr/src/usr.bin/learn/learn/list.c
usr/src/usr.bin/learn/learn/lrnref.h
usr/src/usr.bin/learn/learn/makpipe.c
usr/src/usr.bin/learn/learn/maktee.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

index ffa9f92..0af7c3c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)learn.c    4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)learn.c    4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
index 27e091a..35abce8 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)list.c     4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)list.c     4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
index 052800b..d17318a 100644 (file)
@@ -1,5 +1,3 @@
-/*     @(#)lrnref.h    4.1     (Berkeley)      83/02/24        */
-
 #define        READY   0
 #define        PRINT   1
 #define        COPYIN  2
 #define        READY   0
 #define        PRINT   1
 #define        COPYIN  2
@@ -26,8 +24,9 @@
 #define        BAD     23
 #define        CREATE  24
 #define        CMP     25
 #define        BAD     23
 #define        CREATE  24
 #define        CMP     25
-#define        GOTO    26
-#define        ONCE    27
+#define        ONCE    26
+#define        AGAIN   27
+#define XYZZY  28
 
 extern int     more;
 extern char    *level;
 
 extern int     more;
 extern char    *level;
@@ -46,3 +45,7 @@ extern        FILE    *incopy;
 extern FILE    *scrin;
 extern int     logging;
 extern int     ask;
 extern FILE    *scrin;
 extern int     logging;
 extern int     ask;
+extern         int     again;
+extern int     skip;
+extern int     teed;
+extern int     total;
index b4c5ba2..932fa27 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)makpipe.c  4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)makpipe.c  4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -14,9 +14,14 @@ makpipe()
                close(0);
                dup(f[0]);
                close(f[0]);
                close(0);
                dup(f[0]);
                close(f[0]);
+#if vax
                execl ("/bin/sh", "sh", "-i", 0);
                execl ("/bin/sh", "sh", "-i", 0);
-               execl ("/usr/bin/sh", "sh", "-i", 0);
-               write(2,"Exec error\n",11);
+               execl ("/usr/ucb/bin/sh", "sh", "-i", 0);
+#else
+               execlp("/bin/csh", "csh", "-if", 0);
+               /*execl ("/usr/ucb/bin/csh", "csh", "-if", 0);*/
+#endif
+               write(2, "Exec error\n", 11);
        }
        close(f[0]);
        sleep(2);       /* so shell won't eat up too much input */
        }
        close(f[0]);
        sleep(2);       /* so shell won't eat up too much input */
index 3a27914..853441d 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)maktee.c   4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)maktee.c   4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -14,7 +14,7 @@ maktee()
        int fpip[2], in, out;
 
        if (tee[0] == 0)
        int fpip[2], in, out;
 
        if (tee[0] == 0)
-               sprintf(tee, "%s/tee", direct);
+               sprintf(tee, "%s/bin/lrntee", direct);
        pipe(fpip);
        in = fpip[0];
        out= fpip[1];
        pipe(fpip);
        in = fpip[0];
        out= fpip[1];
@@ -25,15 +25,18 @@ maktee()
                dup(in);
                close(in);
                execl (tee, "lrntee", 0);
                dup(in);
                close(in);
                execl (tee, "lrntee", 0);
-               fprintf(stderr, "Tee exec failed\n");
+               perror(tee);
+               fprintf(stderr, "Maktee:  lrntee exec failed\n");
                exit(1);
        }
        close(in);
        fflush(stdout);
        oldout = dup(1);
        close(1);
                exit(1);
        }
        close(in);
        fflush(stdout);
        oldout = dup(1);
        close(1);
-       if (dup(out) != 1)
-               fprintf(stderr, "Error making tee for copyout\n");
+       if (dup(out) != 1) {
+               perror("dup");
+               fprintf(stderr, "Maktee:  error making tee for copyout\n");
+       }
        close(out);
        return(1);
 }
        close(out);
        return(1);
 }
index a495586..71dfca6 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mem.c      4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)mem.c      4.2     (Berkeley)      %G%";
 #endif not lint
 
 # include "stdio.h"
 #endif not lint
 
 # include "stdio.h"
@@ -28,16 +28,17 @@ struct keys {
        {"#log",        LOG},
        {"yes",         YES},
        {"no",          NO},
        {"#log",        LOG},
        {"yes",         YES},
        {"no",          NO},
+       {"again",       AGAIN},
        {"#mv",         MV},
        {"#user",       USER},
        {"#next",       NEXT},
        {"skip",        SKIP},
        {"#mv",         MV},
        {"#user",       USER},
        {"#next",       NEXT},
        {"skip",        SKIP},
-       {"#where",      WHERE},
+       {"where",       WHERE},
        {"#match",      MATCH},
        {"#bad",        BAD},
        {"#create",     CREATE},
        {"#cmp",        CMP},
        {"#match",      MATCH},
        {"#bad",        BAD},
        {"#create",     CREATE},
        {"#cmp",        CMP},
-       {"#goto",       GOTO},
+       {"xyzzy",       XYZZY},
        {"#once",       ONCE},
        {"#",           NOP},
        {NULL,          0}
        {"#once",       ONCE},
        {"#",           NOP},
        {NULL,          0}
@@ -62,37 +63,53 @@ struct whichdid {
 int nwh = 0;
 char whbuff[NWCH];
 char *whcp = whbuff;
 int nwh = 0;
 char whbuff[NWCH];
 char *whcp = whbuff;
+static struct whichdid *pw;
 
 setdid(lesson, sequence)
 char *lesson;
 
 setdid(lesson, sequence)
 char *lesson;
+int sequence;
 {
 {
-       struct whichdid *pw;
-       for(pw=which; pw < which+nwh; pw++)
-               if (strcmp(pw->w_less, lesson) == SAME)
-                       {
-                       pw->w_seq = sequence;
-                       return;
-                       }
-       pw=which+nwh++;
+       if (already(lesson)) {
+               pw->w_seq = sequence;
+               return;
+       }
+       pw = which+nwh++;
        if (nwh >= NW) {
        if (nwh >= NW) {
-               fprintf(stderr, "nwh>=NW\n");
+               fprintf(stderr, "Setdid:  too many lessons\n");
+               tellwhich();
                wrapup(1);
        }
        pw->w_seq = sequence;
        pw->w_less = whcp;
        while (*whcp++ = *lesson++);
        if (whcp >= whbuff + NWCH) {
                wrapup(1);
        }
        pw->w_seq = sequence;
        pw->w_less = whcp;
        while (*whcp++ = *lesson++);
        if (whcp >= whbuff + NWCH) {
-               fprintf(stderr, "lesson name too long\n");
+               fprintf(stderr, "Setdid:  lesson names too long\n");
+               tellwhich();
                wrapup(1);
        }
 }
 
                wrapup(1);
        }
 }
 
-already(lesson, sequence)
+unsetdid(lesson)
+char *lesson;
+{
+       if (!already(lesson))
+               return;
+       nwh = pw - which;       /* pretend the rest have not been done */
+       whcp = pw->w_less;
+}
+
+already(lesson)
 char *lesson;
 {
 char *lesson;
 {
-       struct whichdid *pw;
        for (pw=which; pw < which+nwh; pw++)
                if (strcmp(pw->w_less, lesson) == SAME)
                        return(1);
        return(0);
 }
        for (pw=which; pw < which+nwh; pw++)
                if (strcmp(pw->w_less, lesson) == SAME)
                        return(1);
        return(0);
 }
+
+tellwhich()
+{
+       for (pw=which; pw < which+nwh; pw++)
+               printf("%3d lesson %7s sequence %3d\n",
+                       pw-which, pw->w_less, pw->w_seq);
+}
index 33c73c6..30f890f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mysys.c    4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)mysys.c    4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
@@ -8,6 +8,57 @@ static char sccsid[] = "@(#)mysys.c    4.1     (Berkeley)      %G%";
 #define        EASY    1
 #define        MEDIUM  2
 #define        HARD    3
 #define        EASY    1
 #define        MEDIUM  2
 #define        HARD    3
+#define        EMAX    256
+
+char *envp[EMAX+1];
+
+/*
+ * This routine edits the PATH environment variable so that
+ * special commands that learners may need will be found.
+ * EXINIT is modified so that the editor will always prompt,
+ * will not print \r's, and will be usable with open mode.
+ */
+
+chgenv()
+{
+       register char **p;
+       register int i;
+       extern char **environ;
+       extern char *direct;
+       char path[BUFSIZ], exinit[BUFSIZ];
+       char *malloc();
+
+       sprintf(path, "PATH=%s/bin:/usr/cc/bin:/usr/ucb/bin:", direct);
+       sprintf(exinit, "EXINIT=set prompt noopt open");
+#if vax
+       system("stty old");
+       for (p=environ,i=3; *p != 0 && i < EMAX; p++,i++)   {
+#else
+       for (p=environ,i=2; *p != 0 && i < EMAX; p++,i++)   {
+#endif
+               envp[i] = *p;
+               if (**p != 'P' && **p != 'E')
+                       continue;
+               if (strncmp(*p, "PATH=", 5) == 0)
+                       sprintf(path, "PATH=%s/bin:%s", direct, &envp[i--][5]);
+               else if (strncmp(*p, "EXINIT=", 7) == 0)
+                       sprintf(exinit, "%s|set prompt noopt open", envp[i--]);
+#if vax
+               else if (strncmp(*p, "PS1=", 4) == 0);
+                       i--;
+       }
+       envp[2] = malloc(7);
+       strcpy(envp[2], "PS1=% ");
+#else
+       }
+#endif
+       envp[0] = malloc(strlen(path) + 1);
+       strcpy(envp[0], path);
+       envp[1] = malloc(strlen(exinit) + 1);
+       strcpy(envp[1], exinit);
+       envp[i] = 0;
+       environ = envp;
+}
 
 mysys(s)
 char *s;
 
 mysys(s)
 char *s;
@@ -31,6 +82,9 @@ char *s;
                case '$':
                case '\'':
                case '"':
                case '$':
                case '\'':
                case '"':
+               case '`':
+               case '{':
+               case '~':
                        type = MEDIUM;
                        break;
                case '|': 
                        type = MEDIUM;
                        break;
                case '|': 
@@ -58,11 +112,19 @@ char *s;
                        if (fork() == 0) {
                                char b[100];
                                signal(SIGINT, SIG_DFL);
                        if (fork() == 0) {
                                char b[100];
                                signal(SIGINT, SIG_DFL);
-                               strcpy(b, "/bin/");
-                               strcat(b, t);
                                np[nv] = 0;
                                np[nv] = 0;
+                               execvp(t, np);
+                               perror(t);
+                       /*      sprintf(b, "/usr/ucb/bin/%s", t);
+                               execv(b, np);
+                               sprintf(b, "/usr/ucb/%s", t);
+                               execv(b, np);
+                               sprintf(b, "/bin/%s", t);
+                               execv(b, np);
+                               sprintf(b, "/usr/bin/%s", t);
                                execv(b, np);
                                execv(b, np);
-                               fprintf(stderr, "Execv failed\n");
+                               perror(b); */
+                               fprintf(stderr, "Mysys:  execv failed on %s\n", np);
                                exit(1);
                        }
                        wait(&stat);
                                exit(1);
                        }
                        wait(&stat);
@@ -90,7 +152,7 @@ char *s;
        if ((pid = fork()) == 0) {
                signal(SIGINT, SIG_DFL);
                signal(SIGQUIT, SIG_DFL);
        if ((pid = fork()) == 0) {
                signal(SIGINT, SIG_DFL);
                signal(SIGQUIT, SIG_DFL);
-               execl("/bin/sh", "sh", "-c", s, 0);
+               execl("/bin/csh", "csh", "-cf", s, 0);
                _exit(127);
        }
        while ((w = wait(&status)) != pid && w != -1)
                _exit(127);
        }
        while ((w = wait(&status)) != pid && w != -1)
index fb2bed9..a8c32f5 100644 (file)
@@ -1,31 +1,39 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)selsub.c   4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)selsub.c   4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
+#include "sys/types.h"
+#include "sys/stat.h"
 #include "lrnref.h"
 
 selsub(argc,argv)
 char *argv[];
 {
 #include "lrnref.h"
 
 selsub(argc,argv)
 char *argv[];
 {
-       char ans1[100], *cp;
+       char ans1[100];
        static char ans2[30];
        static char dirname[20];
        static char subname[20];
        static char ans2[30];
        static char dirname[20];
        static char subname[20];
+       struct stat statbuf;
 
        if (argc > 1 && argv[1][0] == '-') {
                direct = argv[1]+1;
                argc--;
                argv++;
        }
 
        if (argc > 1 && argv[1][0] == '-') {
                direct = argv[1]+1;
                argc--;
                argv++;
        }
-       chknam(direct);
        if (chdir(direct) != 0) {
        if (chdir(direct) != 0) {
-               fprintf(stderr, "can't cd to %s\,", direct);
+               perror(direct);
+               fprintf(stderr, "Selsub:  couldn't cd to non-standard directory\n");
                exit(1);
        }
        sname = argc > 1 ? argv[1] : 0;
                exit(1);
        }
        sname = argc > 1 ? argv[1] : 0;
-       if (argc > 2)
+       if (argc > 2) {
                strcpy (level=ans2, argv[2]);
                strcpy (level=ans2, argv[2]);
+               if (strcmp(level, "-") == 0)    /* no lesson name is - */
+                       ask = 1;
+               else
+                       again = 1;      /* treat as if "again lesson" */
+       }
        else
                level = 0;
        if (argc > 3 )
        else
                level = 0;
        if (argc > 3 )
@@ -35,8 +43,8 @@ char *argv[];
                list("Linfo");
                printf("If you want more information about the courses,\n");
                printf("or if you have never used 'learn' before,\n");
                list("Linfo");
                printf("If you want more information about the courses,\n");
                printf("or if you have never used 'learn' before,\n");
-               printf("type 'return'; otherwise type the name of\n");
-               printf("the course you want, followed by 'return'.\n");
+               printf("press RETURN; otherwise type the name of\n");
+               printf("the course you want, followed by RETURN.\n");
                fflush(stdout);
                gets(sname=subname);
                if (sname[0] == '\0') {
                fflush(stdout);
                gets(sname=subname);
                if (sname[0] == '\0') {
@@ -49,43 +57,44 @@ char *argv[];
                }
        }
        chknam(sname);
                }
        }
        chknam(sname);
+       stat(sname, &statbuf);
+       total = statbuf.st_size / 16 - 2;       /* size/dirsize-(.+..) */
        if (!level) {
                printf("If you were in the middle of this subject\n");
                printf("and want to start where you left off, type\n");
                printf("the last lesson number the computer printed.\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");
                printf("the last lesson number the computer printed.\n");
-               printf("To start at the beginning, just hit return.\n");
+               printf("If you don't know the number, type in a word\n");
+               printf("you think might appear in the lesson you want,\n");
+               printf("and I will look for the first lesson containing it.\n");
+               printf("To start at the beginning, just hit RETURN.\n");
                fflush(stdout);
                gets(ans2);
                if (ans2[0]==0)
                        strcpy(ans2,"0");
                fflush(stdout);
                gets(ans2);
                if (ans2[0]==0)
                        strcpy(ans2,"0");
-               for (cp=ans2; *cp; cp++)
-                       if (*cp == '(' || *cp == ' ')
-                               *cp= 0;
                level=ans2;
        }
 
        /* make new directory for user to play in */
                level=ans2;
        }
 
        /* make new directory for user to play in */
-       if (chdir("play") != 0) {
-               fprintf(stderr, "can't cd to playpen\n");
+       if (chdir("/tmp") != 0) {
+               perror("/tmp");
+               fprintf(stderr, "Selsub:  couldn't cd to public directory\n");
                exit(1);
        }
        sprintf(dir=dirname, "pl%da", getpid());
        sprintf(ans1, "mkdir %s", dir);
        system(ans1);
        if (chdir(dir) < 0) {
                exit(1);
        }
        sprintf(dir=dirname, "pl%da", getpid());
        sprintf(ans1, "mkdir %s", dir);
        system(ans1);
        if (chdir(dir) < 0) {
-               fprintf(stderr, "Couldn't create working directory.\nBye.\n");
+               perror(dir);
+               fprintf(stderr, "Selsub:  couldn't make play directory with %s.\nBye.\n", ans1);
                exit(1);
        }
        /* after this point, we have a working directory. */
        /* have to call wrapup to clean up */
        if (access(sprintf(ans1, "%s/%s/Init", direct, sname), 04)==0)
                exit(1);
        }
        /* after this point, we have a working directory. */
        /* have to call wrapup to clean up */
        if (access(sprintf(ans1, "%s/%s/Init", direct, sname), 04)==0)
-               if (system(sprintf(ans1, "%s/%s/Init %s", direct,sname, level)) != 0) {
+               if (system(sprintf(ans1, "%s/%s/Init %s", direct, sname, level)) != 0) {
                        printf("Leaving learn.\n");
                        wrapup(1);
                }
                        printf("Leaving learn.\n");
                        wrapup(1);
                }
-       if (level[0] == '-')    /* no lesson names start with - */
-               ask = 1;
-       start(level);
 }
 
 chknam(name)
 }
 
 chknam(name)
index 089a4fe..adcf962 100644 (file)
@@ -1,42 +1,51 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)selunit.c  4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)selunit.c  4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #include "lrnref.h"
 
 int    nsave   = 0;
 #endif not lint
 
 #include "stdio.h"
 #include "lrnref.h"
 
 int    nsave   = 0;
+int    review  = 0;
 
 selunit()
 {
 
 selunit()
 {
-       char fnam[20], s[50];
        static char dobuff[50];
        static char dobuff[50];
+       static char saved[20];
+       char fnam[80], s[80], zb[200];
        char posslev[20][20];
        int diff[20], i, k, m, n, best, alts;
        char posslev[20][20];
        int diff[20], i, k, m, n, best, alts;
+       char *getlesson();
        FILE *f;
        FILE *f;
-       char zb[200];
-       static char saved[20];
 
 
+       if (again) {
+               again = 0;
+               if (todo=getlesson()) {
+                       if (!review)
+                               unsetdid(todo);
+                       return;
+               }
+               wrapup(1);
+       }
        while (ask) {
                printf("What lesson? ");
                fflush(stdout);
                gets(dobuff);
                if (strcmp(dobuff, "bye") == 0)
        while (ask) {
                printf("What lesson? ");
                fflush(stdout);
                gets(dobuff);
                if (strcmp(dobuff, "bye") == 0)
-                       wrapup(0);
-               level = todo = dobuff;
-               sprintf(s, "../../%s/L%s", sname, dobuff);
-               if (access(s, 04) == 0)
+                       wrapup(1);
+               level = dobuff;
+               if (todo=getlesson())
                        return;
                        return;
-               printf("no such lesson\n");
        }
        alts = 0;
 retry:
        }
        alts = 0;
 retry:
-       f=scrin;
+       f = scrin;                      /* use old lesson to find next */
        if (f==NULL) {
        if (f==NULL) {
-               sprintf(fnam, "../../%s/L%s", sname, level);
+               sprintf(fnam, "%s/%s/L%s", direct, sname, level);
                f = fopen(fnam, "r");
                if (f==NULL) {
                f = fopen(fnam, "r");
                if (f==NULL) {
-                       fprintf(stderr, "No script for lesson %s.\n", level);
+                       perror(fnam);
+                       fprintf(stderr, "Selunit:  no script for lesson %s.\n", level);
                        wrapup(1);
                }
                while (fgets(zb, 200, f)) {
                        wrapup(1);
                }
                while (fgets(zb, 200, f)) {
@@ -51,7 +60,7 @@ retry:
                todo = 0;
                return;
        }
                todo = 0;
                return;
        }
-       for(i=0; fgets(s, 50, f); i++) {
+       for(i=0; fgets(s, 80, f); i++) {
                sscanf(s, "%s %d", posslev[i], &diff[i]);
        }
        best = -1;
                sscanf(s, "%s %d", posslev[i], &diff[i]);
        }
        best = -1;
@@ -61,19 +70,20 @@ retry:
        n = grand()%i;
        for(k=0; k<i; k++) {
                m = (n+k)%i;
        n = grand()%i;
        for(k=0; k<i; k++) {
                m = (n+k)%i;
-               if (already(posslev[m],0)) continue;
-               if (best<0) best=m;
-               /* real alternatives */
-               alts++;
+               if (already(posslev[m]))
+                       continue;
+               if (best<0)
+                       best = m;
+               alts++;                         /* real alternatives */
                if (abs(diff[m]-speed) < abs(diff[best]-speed))
                if (abs(diff[m]-speed) < abs(diff[best]-speed))
-                       best=m;
+                       best = m;
        }
        if (best < 0 && nsave) {
                nsave--;
                strcpy(level, saved);
                goto retry;
        }
        }
        if (best < 0 && nsave) {
                nsave--;
                strcpy(level, saved);
                goto retry;
        }
-       if (best <0) {
+       if (best < 0) {
                /* lessons exhausted or missing */
                printf("Sorry, there are no alternative lessons at this stage.\n");
                printf("See someone for help.\n");
                /* lessons exhausted or missing */
                printf("Sorry, there are no alternative lessons at this stage.\n");
                printf("See someone for help.\n");
@@ -83,8 +93,8 @@ retry:
        }
        strcpy (dobuff, posslev[best]);
        if (alts>1) {
        }
        strcpy (dobuff, posslev[best]);
        if (alts>1) {
-               nsave=1;
-               strcpy (saved, level);
+               nsave = 1;
+               strcpy(saved, level);
        }
        todo = dobuff;
        fclose(f);
        }
        todo = dobuff;
        fclose(f);
@@ -92,7 +102,7 @@ retry:
 
 abs(x)
 {
 
 abs(x)
 {
-       return(x>=0? x: -x);
+       return(x>=0 ? x : -x);
 }
 
 grand()
 }
 
 grand()
index c45a558..7409653 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)start.c    4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)start.c    4.2     (Berkeley)      %G%";
 #endif not lint
 
 #include "stdio.h"
 #endif not lint
 
 #include "stdio.h"
+#include "lrnref.h"
 #include <sys/types.h>
 #include <sys/dir.h>
 #include <sys/types.h>
 #include <sys/dir.h>
-#include "lrnref.h"
 #define        ND      64
 
 start(lesson)
 #define        ND      64
 
 start(lesson)
@@ -15,11 +15,11 @@ char *lesson;
        int f, c, n;
        char where [100];
 
        int f, c, n;
        char where [100];
 
-       f = open(".", 0);
+       f = open(".", 0);               /* clean up play directory */
        n = read(f, dv, ND*sizeof(*dp));
        n /= sizeof(*dp);
        if (n==ND)
        n = read(f, dv, ND*sizeof(*dp));
        n /= sizeof(*dp);
        if (n==ND)
-               fprintf(stderr, "lesson too long\n");
+               fprintf(stderr, "Start:  play directory too long\n");
        dm = dv+n;
        for(dp=dv; dp<dm; dp++)
                if (dp->d_ino) {
        dm = dv+n;
        for(dp=dv; dp<dm; dp++)
                if (dp->d_ino) {
@@ -33,10 +33,11 @@ char *lesson;
        close(f);
        if (ask)
                return;
        close(f);
        if (ask)
                return;
-       sprintf(where, "../../%s/L%s", sname, lesson);
+       sprintf(where, "%s/%s/L%s", direct, sname, lesson);
        if (access(where, 04)==0)       /* there is a file */
                return;
        if (access(where, 04)==0)       /* there is a file */
                return;
-       fprintf(stderr, "No lesson %s\n",lesson);
+       perror(where);
+       fprintf(stderr, "Start:  no lesson %s\n",lesson);
        wrapup(1);
 }
 
        wrapup(1);
 }