More fix problems with cl:ignore attribute for xml_diff2cbuf & co
This commit is contained in:
parent
833e748288
commit
9f592911f5
3 changed files with 101 additions and 54 deletions
|
|
@ -654,7 +654,10 @@ text_diff2cbuf_ordered_by_user(cbuf *cb,
|
|||
* + value [
|
||||
* + 97
|
||||
* - 99
|
||||
* @see xml_diff2cbuf
|
||||
* @see clixon_compare_xmls which uses files and is independent of YANG
|
||||
* @see xml_diff2cbuf for XML
|
||||
* @see xml_tree_equal Equal or not
|
||||
* @see xml_diff Diff sets
|
||||
*/
|
||||
static int
|
||||
text_diff2cbuf(cbuf *cb,
|
||||
|
|
@ -679,6 +682,7 @@ text_diff2cbuf(cbuf *cb,
|
|||
char *leaflname = NULL; // XXX
|
||||
cxobj *xi;
|
||||
cxobj *xj;
|
||||
int extflag;
|
||||
|
||||
level1 = level*PRETTYPRINT_INDENT;
|
||||
if ((y0 = xml_spec(x0)) != NULL){
|
||||
|
|
@ -694,7 +698,27 @@ text_diff2cbuf(cbuf *cb,
|
|||
/* Check if one or both subtrees are NULL */
|
||||
if (x0c == NULL && x1c == NULL)
|
||||
goto ok;
|
||||
else if (x0c == NULL){
|
||||
else {
|
||||
yc0 = NULL;
|
||||
yc1 = NULL;
|
||||
/* If cl:ignore-compare extension, skip */
|
||||
if (x0c && (yc0 = xml_spec(x0c)) != NULL){
|
||||
if (yang_extension_value(yc0, "ignore-compare", CLIXON_LIB_NS, &extflag, NULL) < 0)
|
||||
goto done;
|
||||
if (extflag){ /* skip */
|
||||
x0c = xml_child_each(x0, x0c, CX_ELMNT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (x1c && (yc1 = xml_spec(x1c)) != NULL){
|
||||
if (yang_extension_value(yc1, "ignore-compare", CLIXON_LIB_NS, &extflag, NULL) < 0)
|
||||
goto done;
|
||||
if (extflag){ /* skip */
|
||||
x1c = xml_child_each(x1, x1c, CX_ELMNT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (x0c == NULL){
|
||||
if (nr==0 && skiptop==0){
|
||||
cprintf(cb, "%*s", level1, "");
|
||||
if (prefix)
|
||||
|
|
@ -724,10 +748,9 @@ text_diff2cbuf(cbuf *cb,
|
|||
x0c = xml_child_each(x0, x0c, CX_ELMNT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* Both x0c and x1c exists, check if they are yang-equal. */
|
||||
eq = xml_cmp(x0c, x1c, 0, 0, NULL);
|
||||
yc0 = xml_spec(x0c);
|
||||
yc1 = xml_spec(x1c);
|
||||
if (eq && yc0 && yc1 && yc0 == yc1 && yang_find(yc0, Y_ORDERED_BY, "user")){
|
||||
if (text_diff2cbuf_ordered_by_user(cb, x0, x1, x0c, x1c, yc0,
|
||||
level, skiptop) < 0)
|
||||
|
|
|
|||
|
|
@ -1278,7 +1278,9 @@ xml_diff2cbuf_ordered_by_user(cbuf *cb,
|
|||
* @endcode
|
||||
* @see xml_diff which returns diff sets
|
||||
* @see clixon_compare_xmls which uses files and is independent of YANG
|
||||
* @see text_diff2cbuf
|
||||
* @see text_diff2cbuf for curly
|
||||
* @see xml_tree_equal Equal or not
|
||||
* @see xml_diff Diff sets
|
||||
*/
|
||||
static int
|
||||
xml_diff2cbuf(cbuf *cb,
|
||||
|
|
@ -1302,6 +1304,7 @@ xml_diff2cbuf(cbuf *cb,
|
|||
int level1;
|
||||
cxobj *xi;
|
||||
cxobj *xj;
|
||||
int extflag;
|
||||
|
||||
level1 = level*PRETTYPRINT_INDENT;
|
||||
y0 = xml_spec(x0);
|
||||
|
|
@ -1312,7 +1315,27 @@ xml_diff2cbuf(cbuf *cb,
|
|||
for (;;){
|
||||
if (x0c == NULL && x1c == NULL)
|
||||
goto ok;
|
||||
else if (x0c == NULL){
|
||||
else {
|
||||
yc0 = NULL;
|
||||
yc1 = NULL;
|
||||
/* If cl:ignore-compare extension, skip */
|
||||
if (x0c && (yc0 = xml_spec(x0c)) != NULL){
|
||||
if (yang_extension_value(yc0, "ignore-compare", CLIXON_LIB_NS, &extflag, NULL) < 0)
|
||||
goto done;
|
||||
if (extflag){ /* skip */
|
||||
x0c = xml_child_each(x0, x0c, CX_ELMNT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (x1c && (yc1 = xml_spec(x1c)) != NULL){
|
||||
if (yang_extension_value(yc1, "ignore-compare", CLIXON_LIB_NS, &extflag, NULL) < 0)
|
||||
goto done;
|
||||
if (extflag){ /* skip */
|
||||
x1c = xml_child_each(x1, x1c, CX_ELMNT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (x0c == NULL){
|
||||
/* Check if one or both subtrees are NULL */
|
||||
if (nr==0 && skiptop==0){
|
||||
xml_diff_context(cb, x1, level1);
|
||||
|
|
@ -1335,10 +1358,9 @@ xml_diff2cbuf(cbuf *cb,
|
|||
x0c = xml_child_each(x0, x0c, CX_ELMNT);
|
||||
continue;
|
||||
}
|
||||
/* Both x0c and x1c exists, check if they are yang-equal. */
|
||||
}
|
||||
/* Both x0c and x1c exists, check if yang equal */
|
||||
eq = xml_cmp(x0c, x1c, 0, 0, NULL);
|
||||
yc0 = xml_spec(x0c);
|
||||
yc1 = xml_spec(x1c);
|
||||
if (eq && yc0 && yc1 && yc0 == yc1 && yang_find(yc0, Y_ORDERED_BY, "user")){
|
||||
if (xml_diff2cbuf_ordered_by_user(cb, x0, x1, x0c, x1c, yc0,
|
||||
level, skiptop) < 0)
|
||||
|
|
|
|||
|
|
@ -570,6 +570,8 @@ xml_diff(cxobj *x0,
|
|||
* @retval 1 Not equal
|
||||
* @retval 0 Equal
|
||||
* @see xml_diff which returns diff sets
|
||||
* @see xml_diff2cbuf Diff buffer in XML
|
||||
* @see text_diff2cbuf Diff buffer in curly
|
||||
*/
|
||||
int
|
||||
xml_tree_equal(cxobj *x0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue