[BACK]Return to string.c CVS log [TXT][DIR] Up to [local] / funnyos / libkern

Annotation of funnyos/libkern/string.c, Revision 1.1

1.1     ! init        1: /*
        !             2:  * $Id: string.c,v 1.1.1.1 2007/10/12 08:40:38 init Exp $
        !             3:  */
        !             4: #include <sys/types.h>
        !             5: #include <libkern/string.h>
        !             6:
        !             7: int
        !             8: strncmp(const char *s1, const char *s2, const uint32_t len)
        !             9: {
        !            10:        /*
        !            11:         * Compare len characters of string s1 with len characters of s2.
        !            12:         * Return first difference's position or 0 if no differencies.
        !            13:         */
        !            14:        uint32_t        i;
        !            15:
        !            16:        /* TODO ugly algorhitm; rewrite */
        !            17:
        !            18:        for(i = 0; i < len; i++) {
        !            19:                if(s1[i] != s2[i])
        !            20:                        return(i + 1);
        !            21:
        !            22:                if(s1[i] == '\0')
        !            23:                        /* \0 encountered, but strings are identical */
        !            24:                        return(0);
        !            25:        }
        !            26:
        !            27:        return(-1);
        !            28: }
        !            29:

CVSweb