Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1895 → Rev 1896

/trunk/boot/generic/string.c
57,6 → 57,34
*
* Do a char-by-char comparison of two NULL terminated strings.
* The strings are considered equal iff they consist of the same
* characters on the minimum of their lengths.
*
* @param src First string to compare.
* @param dst Second string to compare.
*
* @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
*
*/
int strcmp(const char *src, const char *dst)
{
for (; *src && *dst; src++, dst++) {
if (*src < *dst)
return -1;
if (*src > *dst)
return 1;
}
if (*src == *dst)
return 0;
if (!*src)
return -1;
return 1;
}
 
 
/** Compare two NULL terminated strings
*
* Do a char-by-char comparison of two NULL terminated strings.
* The strings are considered equal iff they consist of the same
* characters on the minimum of their lengths and specified maximal
* length.
*
71,8 → 99,7
{
int i;
i = 0;
for (;*src && *dst && i < len;src++,dst++,i++) {
for (i = 0; *src && *dst && i < len; src++, dst++, i++) {
if (*src < *dst)
return -1;
if (*src > *dst)
/trunk/boot/generic/string.h
38,6 → 38,7
#include <types.h>
 
extern size_t strlen(const char *str);
extern int strcmp(const char *src, const char *dst);
extern int strncmp(const char *src, const char *dst, size_t len);
extern void strncpy(char *dest, const char *src, size_t len);
extern unative_t atoi(const char *text);