]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-var-expand: var-expand-parser - Add YYFPRINTF() wrapper
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 10 Nov 2025 08:38:00 +0000 (10:38 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 11 Nov 2025 10:17:51 +0000 (10:17 +0000)
Useful if one needs to debug parser.

src/lib-var-expand/var-expand-parser.y

index b9a03bbe21d777a9de5584735152f2667189f60c..f02b688ae24ba99f196b98d72f504d4960cd4889 100644 (file)
 /* 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 <stdio.h>