]> git.kaiwu.me - 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>
Tue, 24 Jun 2025 16:29:41 +0000 (18:29 +0200)
commitc452e69d4b0bc2e3fc60ccc36fdf00bd73d1b57c
tree2089733203201562205f0c6813d7a645936b6cfe
parent2187391558fecc42b6ef6f7f1f8e94f1b6dff4b7
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