subst_token(): do substitution only on first matching token, avoid clobbering at all successive matching tokens

This commit is contained in:
schippes 2020-08-18 02:33:58 +02:00
parent f4f90b87d2
commit 2afc4b70a1
1 changed files with 2 additions and 2 deletions

View File

@ -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;