-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcom_point.c
More file actions
81 lines (75 loc) · 1.59 KB
/
com_point.c
File metadata and controls
81 lines (75 loc) · 1.59 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "db.h"
#include "xwin.h"
#include "token.h"
#include "rlgetc.h"
#define UNUSED(x) (void)(x)
/*
*
* POI xypnt ...
* cross is placed and xy val written above
* no refresh is done.
*
*/
static double x1, y1;
int com_point(LEXER *lp, char *arg)
{
UNUSED(arg);
enum {START,NUM1,END} state = START;
int done=0;
TOKEN token;
char *word;
int debug=0;
while (!done) {
token = token_look(lp,&word);
if (debug) printf("got %s: %s\n", tok2str(token), word);
if (token==CMD) {
state=END;
}
switch(state) {
case START: /* get option or first xy pair */
if (token == OPT ) {
token_get(lp,&word); /* ignore for now */
state = START;
} else if (token == NUMBER) {
state = NUM1;
} else if (token == EOL) {
token_get(lp,&word); /* just eat it up */
state = START;
} else if (token == EOC || token == CMD) {
state = END;
} else {
token_err("POINT", lp, "expected NUMBER", token);
state = END; /* error */
}
break;
case NUM1:
if (token == NUMBER) {
if (getnum(lp, "POINT", &x1, &y1)) {
xwin_draw_point(x1, y1);
state = NUM1;
} else {
state = END;
}
} else if (token == EOL) {
token_get(lp,&word); /* just ignore it */
} else if (token == EOC || token == CMD) {
printf("POINT: cancelling POINT\n");
state = END;
} else {
token_err("POINT", lp, "expected NUMBER", token);
state = END;
}
break;
case END:
default:
if (token == EOC || token == CMD) {
;
} else {
token_flush_EOL(lp);
}
done++;
break;
}
}
return(1);
}