plumber: allow underscores in variable names in plumbing rules

Fixes #561.
This commit is contained in:
Igor Burago 2022-07-29 21:43:53 +08:00 committed by Dan Cross
parent 4f801be055
commit 29fae81fb7

View file

@ -215,6 +215,16 @@ setvariable(char *s, int n, char *val, char *qval)
var->qvalue = estrdup(qval);
}
static char*
scanvarname(char *s)
{
if(isalpha((uchar)*s) || *s=='_')
do
s++;
while(isalnum((uchar)*s) || *s=='_');
return s;
}
static char*
nonnil(char *s)
{
@ -249,16 +259,15 @@ dollar(Exec *e, char *s, int *namelen)
{
int n;
static char *abuf;
char *t;
*namelen = 1;
if(e!=nil && '0'<=s[0] && s[0]<='9')
return nonnil(e->match[s[0]-'0']);
for(t=s; isalnum((uchar)*t); t++)
;
n = t-s;
n = scanvarname(s)-s;
*namelen = n;
if(n == 0)
return nil;
if(e != nil){
if(n == 3){
@ -391,11 +400,11 @@ assignment(char *p)
char *var, *qval;
int n;
if(!isalpha((uchar)p[0]))
return 0;
for(var=p; isalnum((uchar)*p); p++)
;
var = p;
p = scanvarname(p);
n = p-var;
if(n == 0)
return 0;
while(*p==' ' || *p=='\t')
p++;
if(*p++ != '=')