From: Aki Tuomi Date: Mon, 10 Nov 2025 08:38:00 +0000 (+0200) Subject: lib-var-expand: var-expand-parser - Add YYFPRINTF() wrapper X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5dc26bc63175649b442c44b5cfefd41266598747;p=thirdparty%2Fdovecot%2Fcore.git lib-var-expand: var-expand-parser - Add YYFPRINTF() wrapper Useful if one needs to debug parser. --- diff --git a/src/lib-var-expand/var-expand-parser.y b/src/lib-var-expand/var-expand-parser.y index b9a03bbe21..f02b688ae2 100644 --- a/src/lib-var-expand/var-expand-parser.y +++ b/src/lib-var-expand/var-expand-parser.y @@ -35,6 +35,33 @@ /* ignore unused parameters */ #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + +/* This will get used if you add YYDEBUG=1 to AM_CFLAGS and set + var_expand_parser_debug=1 global variable. + This can be done e.g. + + extern int var_expand_parser_debug; + ... + var_expand_parser_debug=1; + + it will print tracing information from the parser. +*/ +static int i_vyyprintf (const char *format, const char *file, int line, ...) ATTR_FORMAT(1, 4); +static int i_vyyprintf (const char *format, const char *file, int line, ...) +{ + va_list va; + va_start(va, line); + struct failure_context ctx = { + .type = LOG_TYPE_DEBUG, + .log_prefix = t_strdup_printf("Debug: %s:%d: ", file, line), + }; + i_log_typev(&ctx, format, va); + va_end(va); + return 0; +} + +#define YYFPRINTF(f, format, args...) i_vyyprintf(format, __FILE__, __LINE__, ##args) #include