]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-var-expand: Handle default rule as error main
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 15 Dec 2025 09:44:10 +0000 (11:44 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 15 Dec 2025 10:26:55 +0000 (12:26 +0200)
src/lib-var-expand/Makefile.am
src/lib-var-expand/test-var-expand.c
src/lib-var-expand/var-expand-lexer.l

index fc21ede3eafe3398d6a14ebfda4936e2e98b05dd..10c05c06ea0617c98b3ef6144551484480d5f99c 100644 (file)
@@ -13,7 +13,7 @@ YACC=/bin/false
 # and cleaner to make this rule ourselves instead of working around ylwrap
 # and yywrap's antiquated notion of what is happening.
 .l.c:
-       $(AM_V_GEN)$(FLEX) -8 -o $@ $<
+       $(AM_V_GEN)$(FLEX) -8 -B -o $@ $<
 
 .y.c:
        $(AM_V_GEN)$(BISON) -o $@ $<
index 4af0a9395bbbc11dca82eea171dd35337fedf364..59633bcfbbbfcc4384b19ac77a03805784ff7383 100644 (file)
@@ -104,6 +104,7 @@ static void test_var_expand_builtin_filters(void) {
                        .out = "expecting CCBRACE or PIPE or NAME",
                        .ret = -1
                },
+               { .in = "%{\\", .out = "Premature program end", .ret = -1 },
                { .in = "hello%{}world", .out = "helloworld", .ret = 0 },
                /* basic lookup */
                { .in = "%{first}", .out = "hello", .ret = 0 },
index 4465589b7b26e3bc3e0c31613fe7f95d6e853b9d..e779f9e9c4903d320df26acfe457fb5c1abf789e 100644 (file)
@@ -22,6 +22,9 @@
 
 #pragma GCC diagnostic push
 
+/* If we hit here, the program has prematurely ended */
+#define ECHO STMT_START { scanner_error(yyscanner, "Premature program end"); } STMT_END;
+
 /* ignore strict bool warnings in generated code */
 #ifdef HAVE_STRICT_BOOL
 #  pragma GCC diagnostic ignored "-Wstrict-bool"