@@ -144,6 +144,8 @@ schema_diff_changed2str(enum lys_diff_changed_e ch)
144144 return "unique" ;
145145 case LYS_CHANGED_WHEN :
146146 return "when" ;
147+ case LYS_CHANGED_YANG_VERSION :
148+ return "yang-version" ;
147149 }
148150
149151 return NULL ;
@@ -1556,7 +1558,7 @@ schema_diff_imports(const struct lys_module *mod, const struct lysc_node *schema
15561558}
15571559
15581560/**
1559- * @brief Create cmp YANG data from direct text substatement of 'module'.
1561+ * @brief Create cmp YANG data from direct 'module' substatement .
15601562 *
15611563 * @param[in] change Change to use.
15621564 * @param[in] mod1 Old module.
@@ -1566,7 +1568,7 @@ schema_diff_imports(const struct lys_module *mod, const struct lysc_node *schema
15661568 * @return LY_ERR value.
15671569 */
15681570static LY_ERR
1569- schema_diff_module_text (const struct lys_diff_change_s * change , const struct lys_module * mod1 ,
1571+ schema_diff_module_substmt (const struct lys_diff_change_s * change , const struct lys_module * mod1 ,
15701572 const struct lys_module * mod2 , ly_bool with_parsed , struct lyd_node * diff_list )
15711573{
15721574 LY_ERR rc = LY_SUCCESS ;
@@ -1605,6 +1607,9 @@ schema_diff_module_text(const struct lys_diff_change_s *change, const struct lys
16051607 text_old = mod1 -> ref ;
16061608 text_new = mod2 -> ref ;
16071609 break ;
1610+ case LYS_CHANGED_YANG_VERSION :
1611+ node_name = "yang-version" ;
1612+ break ;
16081613 default :
16091614 LOGINT (mod1 -> ctx );
16101615 rc = LY_EINT ;
@@ -1617,16 +1622,32 @@ schema_diff_module_text(const struct lys_diff_change_s *change, const struct lys
16171622 /* change info */
16181623 LY_CHECK_GOTO (rc = schema_diff_change_info (change , mod_cmp_list ), cleanup );
16191624
1620- if (text_old ) {
1621- /* old */
1622- LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "old" , 0 , & cont ), cleanup );
1623- LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name , text_old , 0 , NULL ), cleanup );
1624- }
1625+ if (change -> changed != LYS_CHANGED_YANG_VERSION ) {
1626+ /* text substatement */
1627+ if (text_old ) {
1628+ /* old */
1629+ LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "old" , 0 , & cont ), cleanup );
1630+ LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name , text_old , 0 , NULL ), cleanup );
1631+ }
16251632
1626- if (text_new ) {
1627- /* new */
1628- LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "new" , 0 , & cont ), cleanup );
1629- LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name , text_new , 0 , NULL ), cleanup );
1633+ if (text_new ) {
1634+ /* new */
1635+ LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "new" , 0 , & cont ), cleanup );
1636+ LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name , text_new , 0 , NULL ), cleanup );
1637+ }
1638+ } else {
1639+ /* yang-version substatement */
1640+ if (mod1 -> version ) {
1641+ LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "old" , 0 , & cont ), cleanup );
1642+ LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name ,
1643+ mod1 -> version == LYS_VERSION_1_1 ? "1.1" : "1" , 0 , NULL ), cleanup );
1644+ }
1645+
1646+ if (mod2 -> version ) {
1647+ LY_CHECK_GOTO (rc = lyd_new_inner (mod_cmp_list , NULL , "new" , 0 , & cont ), cleanup );
1648+ LY_CHECK_GOTO (rc = lyd_new_term (cont , NULL , node_name ,
1649+ mod2 -> version == LYS_VERSION_1_1 ? "1.1" : "1" , 0 , NULL ), cleanup );
1650+ }
16301651 }
16311652
16321653cleanup :
@@ -3024,9 +3045,9 @@ schema_diff_module(const struct lys_diff_s *diff, const struct lys_module *mod1,
30243045 LY_ERR rc = LY_SUCCESS ;
30253046 uint32_t i ;
30263047
3027- /* text substmts */
3048+ /* yang-version and text substmts */
30283049 for (i = 0 ; i < diff -> module_changes .count ; ++ i ) {
3029- LY_CHECK_GOTO (rc = schema_diff_module_text (& diff -> module_changes .changes [i ], mod1 , mod2 , diff -> with_parsed ,
3050+ LY_CHECK_GOTO (rc = schema_diff_module_substmt (& diff -> module_changes .changes [i ], mod1 , mod2 , diff -> with_parsed ,
30303051 diff_list ), cleanup );
30313052 }
30323053
0 commit comments