annotate 3rdparty/packages/ed/set.c @ 3158:927ba5ebc06e

mc09 l2: move MMU bit-field defines to defs file.
author Neal Crook <foofoobedoo@gmail.com>
date Thu, 06 Apr 2017 21:43:58 +0100
parents bef1844de0dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
994
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
1 /* set.c */
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
2 #include <stdio.h>
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
3 #include "tools.h"
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
4 #include "ed.h"
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
5
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
6 struct tbl {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
7 char *t_str;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
8 int *t_ptr;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
9 int t_val;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
10 } *t, tbl[] = {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
11
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
12 "number", &nflg, TRUE,
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
13 "nonumber", &nflg, FALSE,
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
14 "list", &lflg, TRUE,
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
15 "nolist", &lflg, FALSE,
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
16 "eightbit", &eightbit, TRUE,
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
17 "noeightbit", &eightbit, FALSE,
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
18 0
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
19 };
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
20
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
21 int set()
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
22 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
23 char word[16];
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
24 int i;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
25
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
26 inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
27 if (*inptr != 't') {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
28 if (*inptr != SP && *inptr != HT && *inptr != NL) return(ERR);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
29 } else
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
30 inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
31
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
32 if (*inptr == NL) return(show());
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
33 /* Skip white space */
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
34 while (*inptr == SP || *inptr == HT) inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
35
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
36 for (i = 0; *inptr != SP && *inptr != HT && *inptr != NL;)
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
37 word[i++] = *inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
38 word[i] = EOS;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
39 for (t = tbl; t->t_str; t++) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
40 if (strcmp(word, t->t_str) == 0) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
41 *t->t_ptr = t->t_val;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
42 return(0);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
43 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
44 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
45 return(0);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
46 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
47
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
48 int show()
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
49 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
50 extern int version;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
51
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
52 printf("ed version %d.%d\n", version / 100, version % 100);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
53 printf("number %s, list %s\n", nflg ? "ON" : "OFF", lflg ? "ON" : "OFF");
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
54 return(0);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
55 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
56