@@ -2115,8 +2115,7 @@ resolve_absolute_schema_nodeid(const char *nodeid, const struct lys_module *modu
21152115}
21162116
21172117static int
2118- resolve_json_schema_list_predicate (const char * predicate , const struct lys_node_list * list ,
2119- const struct lys_module * cur_module , int * parsed )
2118+ resolve_json_schema_list_predicate (const char * predicate , const struct lys_node_list * list , int * parsed )
21202119{
21212120 const char * mod_name , * name ;
21222121 int mod_name_len , nam_len , has_predicate , i ;
@@ -2147,7 +2146,7 @@ resolve_json_schema_list_predicate(const char *predicate, const struct lys_node_
21472146
21482147 /* more predicates? */
21492148 if (has_predicate ) {
2150- return resolve_json_schema_list_predicate (predicate , list , cur_module , parsed );
2149+ return resolve_json_schema_list_predicate (predicate , list , parsed );
21512150 }
21522151
21532152 return 0 ;
@@ -2162,7 +2161,7 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
21622161 const struct lys_node * sibling , * start_parent , * parent ;
21632162 int r , nam_len , mod_name_len , is_relative = -1 , has_predicate ;
21642163 /* resolved import module from the start module, it must match the next node-name-match sibling */
2165- const struct lys_module * prefix_mod , * cur_module ;
2164+ const struct lys_module * prefix_mod , * module , * prev_mod ;
21662165
21672166 assert (nodeid && (ctx || start ));
21682167 if (!ctx ) {
@@ -2183,7 +2182,7 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
21832182 while (start_parent && (start_parent -> nodetype == LYS_USES )) {
21842183 start_parent = lys_parent (start_parent );
21852184 }
2186- cur_module = start -> module ;
2185+ module = start -> module ;
21872186 } else {
21882187 if (!mod_name ) {
21892188 str = strndup (nodeid , (name + nam_len ) - nodeid );
@@ -2202,7 +2201,7 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
22022201
22032202 memmove (module_name , mod_name , mod_name_len );
22042203 module_name [mod_name_len ] = '\0' ;
2205- cur_module = ly_ctx_get_module (ctx , module_name , NULL );
2204+ module = ly_ctx_get_module (ctx , module_name , NULL );
22062205
22072206 if (buf_backup ) {
22082207 /* return previous internal buffer content */
@@ -2212,7 +2211,7 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
22122211 }
22132212 ly_buf_used -- ;
22142213
2215- if (!cur_module ) {
2214+ if (!module ) {
22162215 str = strndup (nodeid , (mod_name + mod_name_len ) - nodeid );
22172216 LOGVAL (LYE_PATH_INMOD , LY_VLOG_STR , str );
22182217 free (str );
@@ -2225,9 +2224,11 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
22252224 mod_name_len = 0 ;
22262225 }
22272226
2227+ prev_mod = module ;
2228+
22282229 while (1 ) {
22292230 sibling = NULL ;
2230- while ((sibling = lys_getnext (sibling , start_parent , cur_module , 0 ))) {
2231+ while ((sibling = lys_getnext (sibling , start_parent , module , 0 ))) {
22312232 /* name match */
22322233 if (sibling -> name && !strncmp (name , sibling -> name , nam_len ) && !sibling -> name [nam_len ]) {
22332234 /* output check */
@@ -2272,7 +2273,7 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
22722273 return NULL ;
22732274 }
22742275 } else {
2275- prefix_mod = cur_module ;
2276+ prefix_mod = prev_mod ;
22762277 }
22772278 if (prefix_mod != lys_node_module (sibling )) {
22782279 continue ;
@@ -2287,7 +2288,7 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
22872288 return NULL ;
22882289 }
22892290 } else if (sibling -> nodetype == LYS_LIST ) {
2290- if (resolve_json_schema_list_predicate (id , (const struct lys_node_list * )sibling , cur_module , & r )) {
2291+ if (resolve_json_schema_list_predicate (id , (const struct lys_node_list * )sibling , & r )) {
22912292 return NULL ;
22922293 }
22932294 } else {
@@ -2308,6 +2309,9 @@ resolve_json_nodeid(const char *nodeid, struct ly_ctx *ctx, const struct lys_nod
23082309 return NULL ;
23092310 }
23102311 start_parent = sibling ;
2312+
2313+ /* update prev mod */
2314+ prev_mod = (start_parent -> child ? lys_node_module (start_parent -> child ) : module );
23112315 break ;
23122316 }
23132317 }
@@ -2463,7 +2467,7 @@ resolve_partial_json_data_nodeid(const char *nodeid, const char *llist_value, st
24632467 int has_predicate , last_parsed , llval_len , pred_name_len , last_has_pred ;
24642468 struct lyd_node * sibling , * last_match = NULL ;
24652469 struct lyd_node_leaf_list * llist ;
2466- const struct lys_module * prefix_mod , * cur_module ;
2470+ const struct lys_module * prefix_mod , * prev_mod ;
24672471 struct ly_ctx * ctx ;
24682472
24692473 assert (nodeid && start && parsed );
@@ -2481,11 +2485,11 @@ resolve_partial_json_data_nodeid(const char *nodeid, const char *llist_value, st
24812485 last_parsed = r ;
24822486
24832487 if (is_relative ) {
2484- cur_module = lyd_node_module (start );
2488+ prev_mod = lyd_node_module (start );
24852489 start = start -> child ;
24862490 } else {
24872491 for (; start -> parent ; start = start -> parent );
2488- cur_module = lyd_node_module (start );
2492+ prev_mod = lyd_node_module (start );
24892493 }
24902494
24912495 while (1 ) {
@@ -2546,7 +2550,7 @@ resolve_partial_json_data_nodeid(const char *nodeid, const char *llist_value, st
25462550 return NULL ;
25472551 }
25482552 } else {
2549- prefix_mod = cur_module ;
2553+ prefix_mod = prev_mod ;
25502554 }
25512555 if (prefix_mod != lyd_node_module (sibling )) {
25522556 continue ;
@@ -2629,6 +2633,7 @@ resolve_partial_json_data_nodeid(const char *nodeid, const char *llist_value, st
26292633 return NULL ;
26302634 }
26312635 last_match = sibling ;
2636+ prev_mod = lyd_node_module (sibling );
26322637 start = sibling -> child ;
26332638 break ;
26342639 }
0 commit comments