Subversion Repositories HelenOS-historic

Rev

Rev 591 | Rev 603 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 591 Rev 601
Line 77... Line 77...
77
 *
77
 *
78
 * @param src First string to compare.
78
 * @param src First string to compare.
79
 * @param dst Second string to compare.
79
 * @param dst Second string to compare.
80
 * @param len Maximal length for comparison.
80
 * @param len Maximal length for comparison.
81
 *
81
 *
82
 * @return 0 if the strings are equal, 1 otherwise.
82
 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
83
 *
83
 *
84
 */
84
 */
85
int strncmp(const char *src, const char *dst, size_t len)
85
int strncmp(const char *src, const char *dst, size_t len)
86
{
86
{
87
    int i;
87
    int i;
88
   
88
   
89
    i = 0;
89
    i = 0;
90
    while ((i < len) && (src[i] == dst[i])) {
90
    for (;*src && *dst && i < len;src++,dst++,i++) {
91
        if ((i == len - 1) || (src[i] == '\0'))
91
        if (*src < *dst)
92
            return 0;
92
            return -1;
-
 
93
        if (*src > *dst)
93
        i++;
94
            return 1;
94
    }
95
    }
-
 
96
    if (i == len || *src == *dst)
-
 
97
        return 0;
-
 
98
    if (*src < *dst)
-
 
99
        return -1;
95
    return 1;
100
    return 1;
96
}
101
}
97
 
102
 
98
/** Copy NULL terminated string.
103
/** Copy NULL terminated string.
99
 *
104
 *