aboutsummaryrefslogtreecommitdiff
path: root/std.c
diff options
context:
space:
mode:
authorMatthias-Christian Ott <ott@enolink.de>2008-06-08 20:47:08 +0200
committerMatthias-Christian Ott <ott@enolink.de>2008-06-08 20:47:08 +0200
commita6efc851b6b0fa9befe1f81627c5c5955d48e6f6 (patch)
tree6bc23194617d6f47175bfcd55a870809401eb90b /std.c
parent50b4785f2650a741f827f4be17ecc18844a1b175 (diff)
downloadst-a6efc851b6b0fa9befe1f81627c5c5955d48e6f6.tar.gz
st-a6efc851b6b0fa9befe1f81627c5c5955d48e6f6.zip
replace state with separate variables
Diffstat (limited to 'std.c')
-rw-r--r--std.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/std.c b/std.c
index 4afdc3c..4808db4 100644
--- a/std.c
+++ b/std.c
@@ -31,8 +31,6 @@ void shell(void);
31void sigchld(int n); 31void sigchld(int n);
32char unbuffer(void); 32char unbuffer(void);
33 33
34enum { QuestionMark = 1, Digit = 2 };
35
36typedef struct { 34typedef struct {
37 unsigned char data[BUFSIZ]; 35 unsigned char data[BUFSIZ];
38 int s, e; 36 int s, e;
@@ -41,10 +39,10 @@ typedef struct {
41 39
42int cols = 80, lines = 25; 40int cols = 80, lines = 25;
43int cx = 0, cy = 0; 41int cx = 0, cy = 0;
44int c, s; 42int c;
45FILE *fptm = NULL; 43FILE *fptm = NULL;
46int ptm, pts; 44int ptm, pts;
47_Bool bold; 45_Bool bold, digit, qmark;
48pid_t pid; 46pid_t pid;
49RingBuffer buf; 47RingBuffer buf;
50 48
@@ -151,28 +149,27 @@ parseesc(void) {
151 int arg[16]; 149 int arg[16];
152 150
153 memset(arg, 0, LENGTH(arg)); 151 memset(arg, 0, LENGTH(arg));
154 s = 0;
155 c = getc(fptm); 152 c = getc(fptm);
156 switch(c) { 153 switch(c) {
157 case '[': 154 case '[':
158 c = getc(fptm); 155 c = getc(fptm);
159 for(j = 0; j < LENGTH(arg);) { 156 for(j = 0; j < LENGTH(arg);) {
160 if(isdigit(c)) { 157 if(isdigit(c)) {
161 s |= Digit; 158 digit = 1;
162 arg[j] *= 10; 159 arg[j] *= 10;
163 arg[j] += c - '0'; 160 arg[j] += c - '0';
164 } 161 }
165 else if(c == '?') 162 else if(c == '?')
166 s |= QuestionMark; 163 qmark = 1;
167 else if(c == ';') { 164 else if(c == ';') {
168 if(!(s & Digit)) 165 if(!digit)
169 eprint("syntax error\n"); 166 eprint("syntax error\n");
170 s &= ~Digit; 167 digit = 0;
171 j++; 168 j++;
172 } 169 }
173 else { 170 else {
174 if(s & Digit) { 171 if(digit) {
175 s &= ~Digit; 172 digit = 0;
176 j++; 173 j++;
177 } 174 }
178 break; 175 break;