projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_2 release
[unix-history]
/
usr
/
src
/
usr.bin
/
learn
/
mem.c
diff --git
a/usr/src/usr.bin/learn/mem.c
b/usr/src/usr.bin/learn/mem.c
index
fd5fb0d
..
1985232
100644
(file)
--- a/
usr/src/usr.bin/learn/mem.c
+++ b/
usr/src/usr.bin/learn/mem.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)mem.c 4.
1 (Berkeley) 2/24
/83";
+static char sccsid[] = "@(#)mem.c 4.
2 (Berkeley) 4/25
/83";
#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);
+}