diff options
| author | Igor Burago <ib@iburago.org> | 2022-07-27 15:51:02 +0800 |
|---|---|---|
| committer | Dan Cross <crossd@gmail.com> | 2022-09-07 09:30:40 -0400 |
| commit | 4f801be05521d52e3e5a43b3ed4b4a1206ed871e (patch) | |
| tree | f1eba6a90afa742b905b392f3bfcdc878ef9cc34 /src | |
| parent | 28e91cd8798fd55993e98c83e577dd1d82955257 (diff) | |
plumber: set match variables past the first non-matching subexpression
Fixes #563.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/plumb/match.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/plumb/match.c b/src/cmd/plumb/match.c index 13ebe768..4cb32cc6 100644 --- a/src/cmd/plumb/match.c +++ b/src/cmd/plumb/match.c @@ -45,12 +45,12 @@ setvar(Resub rs[10], char *match[10]) for(i=0; i<10; i++){ free(match[i]); match[i] = nil; - } - for(i=0; i<10 && rs[i].s.sp!=nil; i++){ - n = rs[i].e.ep-rs[i].s.sp; - match[i] = emalloc(n+1); - memmove(match[i], rs[i].s.sp, n); - match[i][n] = '\0'; + if(rs[i].s.sp != nil){ + n = rs[i].e.ep-rs[i].s.sp; + match[i] = emalloc(n+1); + memmove(match[i], rs[i].s.sp, n); + match[i][n] = '\0'; + } } } |