]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: tools: have parse_line's error pointer point to unknown variable names
authorWilly Tarreau <w@1wt.eu>
Tue, 24 Jun 2025 15:20:33 +0000 (17:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Nov 2025 18:57:44 +0000 (19:57 +0100)
commit49585049b996db803363352d108ebdcfc0a81a3b
tree2368cd866f249225d5979fb15dfdace86b1cfb11
parent14087e48b97dae5e84b0557394a15c6794100d4e
MINOR: tools: have parse_line's error pointer point to unknown variable names

When an argument is empty, parse_line() currently returns a pointer to
the empty string itself. This is convenient, but it's only actionable by
the user who will see for example "${HAPROXY_LOCALPEER}" and figure what
is wrong. Here we slightly change the reported pointer so that if an empty
argument results from the evaluation of an empty variable (meaning that
all variables in string are empty and no other char is present), then
instead of pointing to the opening quote, we'll return a pointer to the
first character of the variable's name. This will allow to make a
difference between an empty variable and an unknown variable, and for
the caller to take action based on this.

I.e. before we would get:

    log "${LOG_SERVER_IP}" local0
        ^

if LOG_SERVER_IP is not set, and now instead we'll get this:

    log "${LOG_SERVER_IP}" local0
           ^
src/tools.c