Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-04-04 14:59:55 -07:00
parent c174832c8e
commit 81a995090f
1 changed files with 3 additions and 7 deletions

View File

@ -1,5 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include <string.h>
typedef struct { typedef struct {
char *a, *b; char *a, *b;
@ -46,8 +45,7 @@ writereg(char r)
while((c = *s++)) { while((c = *s++)) {
if(c == '(') depth++; if(c == '(') depth++;
if(c == ')') --depth; if(c == ')') --depth;
if(c == ' ' && !depth) if(c == ' ' && !depth) break;
break;
*outp_++ = c; *outp_++ = c;
} }
return 1; return 1;
@ -57,8 +55,7 @@ static void
save(void) save(void)
{ {
int i, end = outp_ - outp; int i, end = outp_ - outp;
for(i = 0; i < end; i++) for(i = 0; i < end; i++) prog[i] = outp[i];
prog[i] = outp[i];
prog[i] = 0; prog[i] = 0;
prog_ = prog; prog_ = prog;
outp_ = outp; outp_ = outp;
@ -76,12 +73,11 @@ rewrite(void)
char *res = match(p, r); char *res = match(p, r);
if(res != NULL) { if(res != NULL) {
char cc, *b = r->b; char cc, *b = r->b;
while((cc = *b++)) { while((cc = *b++))
if(cc == '?') if(cc == '?')
writereg(*b++); writereg(*b++);
else else
*outp_++ = cc; *outp_++ = cc;
}
found = 1; found = 1;
p = res; p = res;
} }