From 2afc4b70a1591e18364c1d3dad1d928d4c7e08e3 Mon Sep 17 00:00:00 2001 From: schippes Date: Tue, 18 Aug 2020 02:33:58 +0200 Subject: [PATCH] subst_token(): do substitution only on first matching token, avoid clobbering at all successive matching tokens --- src/token.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/token.c b/src/token.c index 0666ac7f..2231b01b 100644 --- a/src/token.c +++ b/src/token.c @@ -854,12 +854,12 @@ char *subst_token(const char *s, const char *tok, const char *new_val) } else if( state == XTOKEN && space) { token[token_pos] = '\0'; token_pos = 0; - matched_tok = !strcmp(token, tok); + matched_tok = !strcmp(token, tok) && !done_subst; state=XENDTOK; } else if(state == XTOKEN && c=='=') { token[token_pos] = '\0'; token_pos = 0; - matched_tok = !strcmp(token, tok); + matched_tok = !strcmp(token, tok) && !done_subst; state=XSEPARATOR; } else if(state == XENDTOK && c=='=') { state=XSEPARATOR;