diff options
| author | Matthias-Christian Ott <ott@enolink.de> | 2008-06-08 20:47:08 +0200 |
|---|---|---|
| committer | Matthias-Christian Ott <ott@enolink.de> | 2008-06-08 20:47:08 +0200 |
| commit | a6efc851b6b0fa9befe1f81627c5c5955d48e6f6 (patch) | |
| tree | 6bc23194617d6f47175bfcd55a870809401eb90b | |
| parent | 50b4785f2650a741f827f4be17ecc18844a1b175 (diff) | |
| download | st-a6efc851b6b0fa9befe1f81627c5c5955d48e6f6.tar.gz st-a6efc851b6b0fa9befe1f81627c5c5955d48e6f6.zip | |
replace state with separate variables
| -rw-r--r-- | std.c | 19 |
1 files changed, 8 insertions, 11 deletions
| @@ -31,8 +31,6 @@ void shell(void); | |||
| 31 | void sigchld(int n); | 31 | void sigchld(int n); |
| 32 | char unbuffer(void); | 32 | char unbuffer(void); |
| 33 | 33 | ||
| 34 | enum { QuestionMark = 1, Digit = 2 }; | ||
| 35 | |||
| 36 | typedef struct { | 34 | typedef 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 | ||
| 42 | int cols = 80, lines = 25; | 40 | int cols = 80, lines = 25; |
| 43 | int cx = 0, cy = 0; | 41 | int cx = 0, cy = 0; |
| 44 | int c, s; | 42 | int c; |
| 45 | FILE *fptm = NULL; | 43 | FILE *fptm = NULL; |
| 46 | int ptm, pts; | 44 | int ptm, pts; |
| 47 | _Bool bold; | 45 | _Bool bold, digit, qmark; |
| 48 | pid_t pid; | 46 | pid_t pid; |
| 49 | RingBuffer buf; | 47 | RingBuffer 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; |
