plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 4f801be05521d52e3e5a43b3ed4b4a1206ed871e
parent 28e91cd8798fd55993e98c83e577dd1d82955257
Author: Igor Burago <ib@iburago.org>
Date:   Wed, 27 Jul 2022 15:51:02 +0800

plumber: set match variables past the first non-matching subexpression

Fixes #563.

Diffstat:
Msrc/cmd/plumb/match.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 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'; + } } }