994
|
1 /* set.c */
|
|
2 #include <stdio.h>
|
|
3 #include "tools.h"
|
|
4 #include "ed.h"
|
|
5
|
|
6 struct tbl {
|
|
7 char *t_str;
|
|
8 int *t_ptr;
|
|
9 int t_val;
|
|
10 } *t, tbl[] = {
|
|
11
|
|
12 "number", &nflg, TRUE,
|
|
13 "nonumber", &nflg, FALSE,
|
|
14 "list", &lflg, TRUE,
|
|
15 "nolist", &lflg, FALSE,
|
|
16 "eightbit", &eightbit, TRUE,
|
|
17 "noeightbit", &eightbit, FALSE,
|
|
18 0
|
|
19 };
|
|
20
|
|
21 int set()
|
|
22 {
|
|
23 char word[16];
|
|
24 int i;
|
|
25
|
|
26 inptr++;
|
|
27 if (*inptr != 't') {
|
|
28 if (*inptr != SP && *inptr != HT && *inptr != NL) return(ERR);
|
|
29 } else
|
|
30 inptr++;
|
|
31
|
|
32 if (*inptr == NL) return(show());
|
|
33 /* Skip white space */
|
|
34 while (*inptr == SP || *inptr == HT) inptr++;
|
|
35
|
|
36 for (i = 0; *inptr != SP && *inptr != HT && *inptr != NL;)
|
|
37 word[i++] = *inptr++;
|
|
38 word[i] = EOS;
|
|
39 for (t = tbl; t->t_str; t++) {
|
|
40 if (strcmp(word, t->t_str) == 0) {
|
|
41 *t->t_ptr = t->t_val;
|
|
42 return(0);
|
|
43 }
|
|
44 }
|
|
45 return(0);
|
|
46 }
|
|
47
|
|
48 int show()
|
|
49 {
|
|
50 extern int version;
|
|
51
|
|
52 printf("ed version %d.%d\n", version / 100, version % 100);
|
|
53 printf("number %s, list %s\n", nflg ? "ON" : "OFF", lflg ? "ON" : "OFF");
|
|
54 return(0);
|
|
55 }
|
|
56
|