Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-04-28 20:37:53 -07:00
parent c9e932765a
commit e84ef37c5d
1 changed files with 7 additions and 13 deletions

View File

@ -34,10 +34,10 @@ walk(char *s)
static int
sint(char *s)
{
int acc = 0;
int r = 0;
char c;
while((c = *s++) && c > 0x20) acc *= 10, acc += c - '0';
return acc;
while((c = *s++) && c > 0x20) r = r * 10 + c - '0';
return r;
}
static void
@ -97,13 +97,9 @@ write_reg(char r, char *reg)
char c, *cap = walk(reg);
switch(r) {
case '>': /* op: output */
case ':':
device_write(reg);
return;
case ':': device_write(reg); return;
case '<': /* op: input */
case '~':
device_read();
return;
case '~': device_read(); return;
case '^': /* op: join */
if(*reg == '(') reg++, --cap;
while(reg < cap && (c = *reg++))
@ -244,8 +240,7 @@ rewrite(void)
while(*s == ' ') s++;
cap = walk(s), r = find_rule(s, cap);
if(r != NULL) {
if(!quiet)
fprintf(stderr, ">< (%s) (%s)\n", r->a, r->b);
if(!quiet) fprintf(stderr, ">< (%s) (%s)\n", r->a, r->b);
r->a = 0;
}
while(*cap == ' ') cap++;
@ -256,8 +251,7 @@ rewrite(void)
r = rules_, r->id = rules_ - rules - 1;
s = parse_frag(&r->b, parse_frag(&r->a, s + 2));
if(*r->a) {
if(!quiet)
fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b);
if(!quiet) fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b);
rules_++;
}
while(*s == ' ') s++;