diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-11-17 19:19:51 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-11-17 19:19:51 -0800 |
commit | 6c21b63190de70898ee4eacd66687d9759242331 (patch) | |
tree | 530df0166eb0ce54f1d048330653a635a1cd6882 /src/cnode/cnode-algorithm.cpp | |
parent | 1a2eac7485f52d93e1334a3818e5a4d420709db2 (diff) | |
download | vyatta-cfg-6c21b63190de70898ee4eacd66687d9759242331.tar.gz vyatta-cfg-6c21b63190de70898ee4eacd66687d9759242331.zip |
continue work on parser/output framework
* handle empty and leaf typeless nodes from parsed nodes.
* fix bug 6436 show level issue.
Diffstat (limited to 'src/cnode/cnode-algorithm.cpp')
-rw-r--r-- | src/cnode/cnode-algorithm.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cnode/cnode-algorithm.cpp b/src/cnode/cnode-algorithm.cpp index 6926c74..c5a2d54 100644 --- a/src/cnode/cnode-algorithm.cpp +++ b/src/cnode/cnode-algorithm.cpp @@ -315,8 +315,10 @@ _diff_show_other(CfgNode *cfg1, CfgNode *cfg2, int level, bool show_def, CfgNode *c1 = (in1 ? nmap1[cnodes[i]] : NULL); CfgNode *c2 = (in2 ? nmap2[cnodes[i]] : NULL); - int next_level = ((cfg->isTag() && !cfg->isValue()) - ? ((level >= 0) ? level : 0) : (level + 1)); + int next_level = level + 1; + if (!print_this) { + next_level = (level >= 0 ? level : 0); + } _show_diff(c1, c2, next_level, show_def, hide_secret); } @@ -331,6 +333,14 @@ static void _show_diff(CfgNode *cfg1, CfgNode *cfg2, int level, bool show_def, bool hide_secret) { + // if doesn't exist, treat as NULL + if (cfg1 && !cfg1->exists()) { + cfg1 = NULL; + } + if (cfg2 && !cfg2->exists()) { + cfg2 = NULL; + } + /* cfg1 and cfg2 point to the same config node in two configs. a "diff" * output is shown comparing the two configs recursively with this node * as the root of the config tree. @@ -349,7 +359,8 @@ _show_diff(CfgNode *cfg1, CfgNode *cfg2, int level, bool show_def, exit(1); } - if (_diff_check_and_show_leaf(cfg1, cfg2, level, show_def, hide_secret)) { + if (_diff_check_and_show_leaf(cfg1, cfg2, (level >= 0 ? level : 0), + show_def, hide_secret)) { // leaf node has been shown. done. return; } else { |