strncasecmp default implementation in stringutils
Philippe Torrelli
philippe.torrelli at alcatel.fr
Wed Oct 18 15:12:59 CEST 2006
Hello,
Trying for to have minisip communicate with TCP transport today ,
I had to fix the strncasecmp implementation . as the current one doesn't
correctly handle the character count .
Sorry for that I didn't notice it.
Here's a fixed version.
static int strncasecmp(const char *s1, const char *s2, int n){
int i;
for ( i=0; s1[i]!=0 && s2[i]!=0 && (n==-1 || (n!=-1 && i<n) ); i++){
if ( !nocaseequal(s1[i],s2[i]) ){
if (s1[i]<s2[i]){
return -1;
}else{
return 1;
}
}
}
if(i != n && (s1[i] != s2[i] )) {
if (s1[i] == '\0' ){
return -1;
}else{
return 1;
}
}
return 0;
}
Hope it helps.
Philippe Torrelli
More information about the Minisip-devel
mailing list