Minor changes

This commit is contained in:
Devine Lu Linvega 2024-04-08 15:14:05 -07:00
parent bdb19d5ea5
commit ad2dbb2a1f
1 changed files with 6 additions and 8 deletions

View File

@ -56,7 +56,7 @@ plode(char *s)
}
static int
bind_reg(int r, char *b)
set_reg(int r, char *b)
{
if(regs[r]) {
char *a = regs[r], *aa = walk(a), *bb = walk(b);
@ -72,15 +72,14 @@ bind_reg(int r, char *b)
}
static int
write_reg(char r)
put_reg(char r)
{
char *s = regs[(int)r];
if(r == '*')
s = plode(s);
else if(s) {
char *ss = walk(s);
while((s < ss) && (*outp_++ = *s++))
;
while((s < ss)) *outp_++ = *s++;
} else
*outp_++ = r;
return 1;
@ -96,7 +95,7 @@ match_rule(char *p, Rule *r)
regs[i] = 0;
while((c = *a)) {
if(c == '?') {
if(!bind_reg(*(++a), b)) return NULL;
if(!set_reg(*(++a), b)) return NULL;
a++, b = walk(b);
continue;
}
@ -127,8 +126,7 @@ parse_rule(char *s)
{
char *ss = walk(s), *d = dict_;
if(*s == '(') s++, ss--;
while((s < ss) && (*dict_++ = *s++))
;
while((s < ss)) *dict_++ = *s++;
*dict_++ = 0;
return d;
}
@ -163,7 +161,7 @@ rewrite(void)
if(!*b && last == ' ') outp_--;
while((cc = *b++)) {
if(cc == '?')
write_reg(*b++);
put_reg(*b++);
else
*outp_++ = cc;
}