Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1895 → Rev 1896

/trunk/kernel/generic/include/func.h
44,6 → 44,7
extern void halt(void);
 
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);
/trunk/kernel/generic/src/lib/func.c
100,6 → 100,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.
*
114,8 → 142,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)
128,6 → 155,8
return 1;
}
 
 
 
/** Copy NULL terminated string.
*
* Copy at most 'len' characters from string 'src' to 'dest'.