From 51cb8e29920259dd69e92877bd30e948e310f456 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 19 Nov 2023 21:47:14 -0500 Subject: [PATCH] feat: cpp: handle `iflt` and `ifgt` --- src/core/cpp/cpp.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/cpp/cpp.ml b/src/core/cpp/cpp.ml index 8ce5e529..5535049e 100644 --- a/src/core/cpp/cpp.ml +++ b/src/core/cpp/cpp.ml @@ -1,6 +1,6 @@ module C = Configurator.V1 -type op = Le | Ge +type op = Le | Ge | Gt | Lt type line = | If of op * int * int @@ -29,7 +29,9 @@ let prefix ~pre s = let eval ~major ~minor op i j = match op with | Le -> (major, minor) <= (i, j) + | Lt -> (major, minor) < (i, j) | Ge -> (major, minor) >= (i, j) + | Gt -> (major, minor) > (i, j) let preproc_lines ~file ~major ~minor (ic : in_channel) : unit = let pos = ref 0 in @@ -47,8 +49,12 @@ let preproc_lines ~file ~major ~minor (ic : in_channel) : unit = if line' <> "" && line'.[0] = '[' then if prefix line' ~pre:"[@@@ifle" then Scanf.sscanf line' "[@@@ifle %d.%d]" (fun x y -> If (Le, x, y)) + else if prefix line' ~pre:"[@@@iflt" then + Scanf.sscanf line' "[@@@iflt %d.%d]" (fun x y -> If (Lt, x, y)) else if prefix line' ~pre:"[@@@ifge" then Scanf.sscanf line' "[@@@ifge %d.%d]" (fun x y -> If (Ge, x, y)) + else if prefix line' ~pre:"[@@@ifgt" then + Scanf.sscanf line' "[@@@ifgt %d.%d]" (fun x y -> If (Gt, x, y)) else if prefix line' ~pre:"[@@@elifle" then Scanf.sscanf line' "[@@@elifle %d.%d]" (fun x y -> Elseif (Le, x, y)) else if prefix line' ~pre:"[@@@elifge" then