summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-08-23 08:54:00 -0500
committerGitHub <noreply@github.com>2023-08-23 08:54:00 -0500
commitf11f014828c4310ce85af83ba451c39c73397daf (patch)
treecc19cc4a741fb3b2086773b938bf092d8d79aa32
parent2037d3f94930a0a57f70d45ed85175716556caf2 (diff)
parent3509491dd94cc371f5b0a4166274532acc5e6764 (diff)
downloadvyos1x-config-f11f014828c4310ce85af83ba451c39c73397daf.tar.gz
vyos1x-config-f11f014828c4310ce85af83ba451c39c73397daf.zip
Merge pull request #21 from jestabro/render-valueless1.4.0-epa21.4.0-epa1
T5500: adjust render function on valueless leaf and tag node values
-rw-r--r--src/config_tree.ml16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/config_tree.ml b/src/config_tree.ml
index a5698dc..531cae8 100644
--- a/src/config_tree.ml
+++ b/src/config_tree.ml
@@ -161,7 +161,7 @@ struct
let render_values ?(ord_val=false) indent_str name values =
match values with
- | [] -> Printf.sprintf "%s%s { }\n" indent_str name
+ | [] -> Printf.sprintf "%s%s\n" indent_str name
| [v] -> Printf.sprintf "%s%s \"%s\"\n" indent_str name (Util.escape_string v)
| _ ->
let values =
@@ -205,18 +205,10 @@ struct
let name = Vytree.name_of_node node in
let data = Vytree.data_of_node node in
let comment = render_comment indent_str data.comment in
- let values = render_values ~ord_val:ord_val indent_str name data.values in
let children = Vytree.children_of_node node in
- match children with
- (* This produces too much whitespace due to indent_str from values,
- but the issue is cosmetic *)
- | [] -> Printf.sprintf "%s%s%s %s" comment indent_str parent values
- | _ ->
- (* Exploiting the fact that immediate children of tag nodes are
- never themselves tag nodes *)
- let inner = List.map (render_node ~ord_val:ord_val indent (level + 1)) children in
- let inner = String.concat "" inner in
- Printf.sprintf "%s%s%s %s {\n%s%s}\n" comment indent_str parent name inner indent_str
+ let inner = List.map (render_node ~ord_val:ord_val indent (level + 1)) children in
+ let inner = String.concat "" inner in
+ Printf.sprintf "%s%s%s %s {\n%s%s}\n" comment indent_str parent name inner indent_str
let render_config ?(ord_val=false) node =
let children = Vytree.children_of_node node in