axl_strcmp
This commit is contained in:
parent
34e170d3b6
commit
b36822727e
2 changed files with 22 additions and 0 deletions
|
|
@ -77,3 +77,24 @@ i8* axl_strncat(i8* dst, const i8* src, u32 n) //n actually means "not more than
|
|||
|
||||
return dst;
|
||||
}
|
||||
|
||||
i32 axl_strcmp(const i8* s1, const i8* s2)
|
||||
{
|
||||
if (!s1 || !s2)
|
||||
{
|
||||
return (s1 == s2) ? 0 : (!s1 ? -1 : 1);
|
||||
}
|
||||
|
||||
for (;; s1++, s2++)
|
||||
{
|
||||
u8 c1 = *(const u8*)s1;
|
||||
u8 c2 = *(const u8*)s2;
|
||||
|
||||
if (c1 != c2 || c1 == '\0' || c2 == '\0')
|
||||
{
|
||||
return c1 - c2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@ i8* axl_strcpy(i8* dst, const i8* src);
|
|||
i8* axl_strncpy(i8* dst, const i8* src, u32 n);
|
||||
i8* axl_strcat(i8* dst, const i8* src);
|
||||
i8* axl_strncat(i8* dst, const i8* src, u32 n);
|
||||
i32 axl_strcmp(const i8* s1, const i8* s2);
|
||||
|
||||
#endif // AXL_STRING
|
||||
|
|
|
|||
Loading…
Reference in a new issue