From 7cad0a47a07c5b32e1b547e6b293a1f96daf39ba Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sun, 28 Oct 2018 16:08:18 +0100 Subject: T253: quote tag node names if they contain special characters. --- src/cnode/cnode-algorithm.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cnode/cnode-algorithm.cpp b/src/cnode/cnode-algorithm.cpp index 6638936..379fb6a 100644 --- a/src/cnode/cnode-algorithm.cpp +++ b/src/cnode/cnode-algorithm.cpp @@ -513,7 +513,12 @@ _diff_show_other(const CfgNode *cfg1, const CfgNode *cfg2, int level, _diff_print_indent(cfg1, cfg2, level, pfx_diff); if (is_value) { // at tag value - printf("%s %s", name.c_str(), value.c_str()); + const char *quote = ""; + size_t vlen = value.length(); + if (strcspn(value.c_str(), "*}{;\011\012\013\014\015 ") < vlen) { + quote = "\""; + } + printf("%s %s%s%s", name.c_str(), quote, value.c_str(), quote); } else { // at intermediate node printf("%s", name.c_str()); -- cgit v1.2.3