Work on regulatory domains

FossilOrigin-Name: d4f75679142a708394989c19c5257a355f2a99e8e13c7e82d5f9677c8396485f
This commit is contained in:
7u83@mail.ru
2018-04-13 15:42:12 +00:00
parent 17e9f1636d
commit 2cc0ca6f17
6 changed files with 44 additions and 49 deletions

View File

@ -11,20 +11,24 @@ int cw_ktv_mavlcmp(const void *v1, const void *v2)
char *d1,*d2;
int l1,l2,rc,i1,i2;
/* Find dots in both keys */
d1 = strchr(((cw_KTV_t *) v1)->key,'.');
d2 = strchr(((cw_KTV_t *) v2)->key,'.');
/* if there are no dots, compare keys as normal */
if (d1==NULL || d2==NULL)
return strcmp(((cw_KTV_t *) v1)->key, ((cw_KTV_t *) v2)->key);
/* calculate the length of the key till dots */
l1=d1-((cw_KTV_t *) v1)->key;
l2=d2-((cw_KTV_t *) v2)->key;
/* if length differs do a normal compare */
if (l1!=l2){
return strcmp(((cw_KTV_t *) v1)->key, ((cw_KTV_t *) v2)->key);
}
rc = strncmp(((cw_KTV_t *) v1)->key,((cw_KTV_t *) v2)->key,l1);
if (rc!=0){
return rc;