LibC: Add POSIX spec comments for string APIs

This commit is contained in:
Brian Gianforcaro 2021-12-21 15:56:28 -08:00 committed by Brian Gianforcaro
commit 11a12c2312
Notes: sideshowbarker 2024-07-17 22:25:41 +09:00
2 changed files with 30 additions and 0 deletions

View file

@ -28,6 +28,7 @@ static char foldcase(char ch)
return ch;
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html
int strcasecmp(const char* s1, const char* s2)
{
for (; foldcase(*s1) == foldcase(*s2); ++s1, ++s2) {
@ -37,6 +38,7 @@ int strcasecmp(const char* s1, const char* s2)
return foldcase(*(const unsigned char*)s1) < foldcase(*(const unsigned char*)s2) ? -1 : 1;
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncasecmp.html
int strncasecmp(const char* s1, const char* s2, size_t n)
{
if (!n)