Counter function

FossilOrigin-Name: 7f88de81e3340b664d21ef5b091aebec1115813b6751d824930ea2734ddb50ae
This commit is contained in:
7u83@mail.ru
2018-05-20 18:29:40 +00:00
parent 74631d08df
commit 59b08b31c0
7 changed files with 123 additions and 30 deletions

View File

@ -78,6 +78,7 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
char ikey[CW_KTV_MAX_KEY_LEN];
cw_KTV_t search, * result;
char *d;
int i;
sprintf(ikey,"%s.%d",key,n);
@ -90,13 +91,35 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
return -1;
}
d = strchr(result->key,'.');
/*d = strchr(result->key,'.');*/
d=NULL;
/* for (i = strlen(result->key); i>=0; i--){
if (result->key[i]=='/')
break;
}
*/ for (i = strlen(ikey); i>=0; i--){
if (ikey[i]=='.'){
d = result->key+i;
break;
}
}
if (d==NULL){
return -1;
}
if (strncmp(result->key,ikey,d-result->key)!=0)
if(result->key[i]!='.'){
return -1;
}
/* if (strncmp(result->key,ikey,d-result->key)!=0)
return -1;
*/
if (strncmp(result->key,ikey,i)!=0)
return -1;
return atoi(d+1);
return atoi(result->key+i+1);
}