-
Notifications
You must be signed in to change notification settings - Fork 4
/
com_purge.c
55 lines (50 loc) · 1.06 KB
/
com_purge.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <string.h> /* for strchr() */
#include <ctype.h> /* for toupper() */
#include "rlgetc.h"
#include "db.h"
#include "token.h"
#include "xwin.h"
#include "rubber.h"
#define UNUSED(x) (void)(x)
int com_purge(lp, arg) /* remove device from memory and disk */
LEXER *lp;
char *arg;
{
UNUSED(arg);
TOKEN token;
int done=0;
char *word;
int editlevel;
while(!done && (token=token_get(lp, &word)) != EOF) {
switch(token) {
case IDENT: /* identifier */
if (currep != NULL && strncmp(word, currep->name, BUFSIZE) == 0) {
editlevel=currep->being_edited;
currep->being_edited = 0;
if ((currep = db_edit_pop(editlevel)) != NULL) {
;
} else {
lp->mode = MAIN;
}
db_purge(lp, word);
need_redraw++;
} else {
db_purge(lp, word);
}
done++;
break;
case CMD: /* command */
token_unget(lp, token, word);
done++;
break;
case EOC: /* end of command */
done++;
break;
default:
; /* eat em up! */
break;
}
}
return (0);
}