- yang sorting did not use "stable" qsort: fixed by using vector index
This commit is contained in:
parent
5388aace12
commit
ee5c0a08d5
2 changed files with 11 additions and 5 deletions
|
|
@ -3761,12 +3761,12 @@ yang_sort_subelements_fn(const void* arg1,
|
|||
w1 = yang_find(ys1, Y_WHEN, NULL) != NULL;
|
||||
w2 = yang_find(ys2, Y_WHEN, NULL) != NULL;
|
||||
if (w1 == w2)
|
||||
return 0;
|
||||
if (w1)
|
||||
return ys1->_ys_vector_i - ys2->_ys_vector_i;
|
||||
else if (w1)
|
||||
return 1;
|
||||
if (w2)
|
||||
else if (w2)
|
||||
return -1;
|
||||
return 0;
|
||||
else return ys1->_ys_vector_i - ys2->_ys_vector_i;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3786,9 +3786,14 @@ yang_sort_subelements(yang_stmt *ys)
|
|||
#ifdef YANG_ORDERING_WHEN_LAST
|
||||
if ((yang_keyword_get(ys) == Y_CONTAINER ||
|
||||
yang_keyword_get(ys) == Y_LIST)){
|
||||
yang_stmt *yc = NULL;
|
||||
|
||||
/* This enumerates _ys_vector_i in ys->ys_stmt vector */
|
||||
while ((yc = yn_each(ys, yc)) != NULL) ;
|
||||
qsort(ys->ys_stmt, ys->ys_len, sizeof(ys), yang_sort_subelements_fn);
|
||||
}
|
||||
#endif
|
||||
|
||||
retval = 0;
|
||||
// done:
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -97,9 +97,10 @@ struct yang_stmt{
|
|||
yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */
|
||||
char *ys_when_xpath; /* Special conditional for a "when"-associated augment/uses xpath */
|
||||
cvec *ys_when_nsc; /* Special conditional for a "when"-associated augment/uses namespace ctx */
|
||||
int _ys_vector_i; /* internal use: yn_each */
|
||||
char *ys_filename; /* For debug/errors: filename (only (sub)modules) */
|
||||
int ys_linenum; /* For debug/errors: line number (in ys_filename) */
|
||||
/* Internal use */
|
||||
int _ys_vector_i; /* internal use: yn_each */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue