strncasecmp default implementation in stringutils
Erik Eliasson
eliasson at it.kth.se
Wed Oct 18 15:19:17 CEST 2006
Fixed - Thanks!
--Erik
On Wed, 2006-10-18 at 15:12 +0200, Philippe Torrelli wrote:
> 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
>
> _______________________________________________
> Minisip-devel mailing list
> Minisip-devel at minisip.org
> http://lists.minisip.org/mailman/listinfo/minisip-devel
--
Erik Eliasson <eliasson at it.kth.se>
More information about the Minisip-devel
mailing list