From: Ondrej Zajicek Date: Fri, 9 May 2025 13:38:31 +0000 (+0200) Subject: Conf: Switch options should use boolean values X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=474ce47b25d3753839bea701de8a2cd52a5421f6;p=thirdparty%2Fbird.git Conf: Switch options should use boolean values Fix switch options to use boolean constants and expressions intead of integer ones. Still allow integer values with deprecation warning. Also, allow true/false in addition to on/off and yes/no. --- diff --git a/conf/confbase.Y b/conf/confbase.Y index b1d0625f1..0912a5f7e 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -244,12 +244,23 @@ expr_us: /* Switches */ bool: - expr { $$ = !!$1; } - | ON { $$ = 1; } + ON { $$ = 1; } | YES { $$ = 1; } + | TRUE { $$ = 1; } | OFF { $$ = 0; } | NO { $$ = 0; } + | FALSE { $$ = 0; } | /* Silence means agreement */ { $$ = 1; } + | NUM { $$ = !!$1; cf_warn("Number argument for switch option deprecated"); } + | conf_expr { + if (($1.type != T_BOOL) && ($1.type != T_INT)) + cf_error("Switch value expected"); + + if ($1.type == T_INT) + cf_warn("Number argument for switch option deprecated"); + + $$ = !!$1.val.i; + } ;