Subversion Repositories HelenOS

Rev

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

Rev 2184 Rev 2745
Line 137... Line 137...
137
 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
137
 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
138
 *
138
 *
139
 */
139
 */
140
int strncmp(const char *src, const char *dst, size_t len)
140
int strncmp(const char *src, const char *dst, size_t len)
141
{
141
{
142
    int i;
142
    unsigned int i;
143
   
143
   
144
    for (i = 0; *src && *dst && i < len; src++, dst++, i++) {
144
    for (i = 0; (*src) && (*dst) && (i < len); src++, dst++, i++) {
145
        if (*src < *dst)
145
        if (*src < *dst)
146
            return -1;
146
            return -1;
147
        if (*src > *dst)
147
        if (*src > *dst)
148
            return 1;
148
            return 1;
149
    }
149
    }
Line 166... Line 166...
166
 * @param dest Destination buffer.
166
 * @param dest Destination buffer.
167
 * @param len Size of destination buffer.
167
 * @param len Size of destination buffer.
168
 */
168
 */
169
void strncpy(char *dest, const char *src, size_t len)
169
void strncpy(char *dest, const char *src, size_t len)
170
{
170
{
171
    int i;
171
    unsigned int i;
172
    for (i = 0; i < len; i++) {
172
    for (i = 0; i < len; i++) {
173
        if (!(dest[i] = src[i]))
173
        if (!(dest[i] = src[i]))
174
            return;
174
            return;
175
    }
175
    }
176
    dest[i-1] = '\0';
176
    dest[i-1] = '\0';