luxos/SysCore/lib/string.c

24 lines
451 B
C
Raw Normal View History

2021-09-14 15:34:14 +00:00
#include <string.h>
2021-09-14 15:35:52 +00:00
unsigned strlen (const char *str)
2021-09-14 15:34:14 +00:00
{
2021-09-14 15:35:52 +00:00
unsigned i;
2021-09-14 15:34:14 +00:00
for (i = 0; *str!=0; str++) i++;
return i;
}
int strcmp(const char *pStr1, const char *pStr2)
{
char c1, c2;
int v;
do {
c1 = *pStr1++;
c2 = *pStr2++;
/* the casts are necessary when pStr1 is shorter & char is signed */
v = (unsigned int)c1 - (unsigned int)c2;
} while ((v == 0) && (c1 != '\0'));
return v;
}