]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: arg: improve the error message on missing closing parenthesis
authorWilly Tarreau <w@1wt.eu>
Thu, 6 May 2021 12:50:30 +0000 (14:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 May 2021 15:02:36 +0000 (17:02 +0200)
When the closing brace is missing after an argument (acl, ...), the
error may report something like "expected ')' before ''". Let's just
drop "before ''" when the final word is empty to make the message a
bit clearer.

src/arg.c

index 8b3dccf31f11f2854af53e7ac6d411897eafed41..5d5766b7458e0b54ac7413c1cb8cfe10ad4d4700 100644 (file)
--- a/src/arg.c
+++ b/src/arg.c
@@ -359,7 +359,12 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp,
        } else {
                /* the caller is responsible for freeing this message */
                char *word = (len > 0) ? my_strndup(in, len) : (char *)in;
-               memprintf(err_msg, "expected ')' before '%s'", word);
+
+               if (*word)
+                       memprintf(err_msg, "expected ')' before '%s'", word);
+               else
+                       memprintf(err_msg, "expected ')'");
+
                if (len > 0)
                        free(word);
                /* when we're missing a right paren, the empty part preceding