From 4f801be05521d52e3e5a43b3ed4b4a1206ed871e Mon Sep 17 00:00:00 2001 From: Igor Burago Date: Wed, 27 Jul 2022 15:51:02 +0800 Subject: [PATCH] plumber: set match variables past the first non-matching subexpression Fixes #563. --- src/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 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'; + } } }