subst_token(): if s is empty and tok, new_val are gien just set return string to tok=new_val (no newlines whatsoever)

This commit is contained in:
stefan schippers 2024-10-05 11:43:57 +02:00
parent 7ace392d23
commit 835b05ce9f
1 changed files with 5 additions and 0 deletions

View File

@ -1204,6 +1204,11 @@ const char *subst_token(const char *s, const char *tok, const char *new_val)
my_strdup2(_ALLOC_ID_, &result, s);
return result;
}
if( (!s || s[0] == '\0') && tok && new_val) {
my_strdup2(_ALLOC_ID_, &result, tok);
my_mstrcat(_ALLOC_ID_, &result, "=", new_val, NULL);
return result;
}
/* quote new_val if it contains newlines and not "name" token */
if(new_val) {
new_val_len = strlen(new_val);