]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Conf: Switch options should use boolean values
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 9 May 2025 13:38:31 +0000 (15:38 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Sat, 10 May 2025 13:32:02 +0000 (15:32 +0200)
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.

conf/confbase.Y

index b1d0625f1314e6e656a0c1a99c577164121f46c9..0912a5f7e45b415160fcefc903ab66c0d0037890 100644 (file)
@@ -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;
+   }
  ;