mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -22,13 +22,13 @@
|
|||
extern "C" {
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strspn.html
|
||||
size_t strspn(const char* s, const char* accept)
|
||||
size_t strspn(char const* s, char const* accept)
|
||||
{
|
||||
const char* p = s;
|
||||
char const* p = s;
|
||||
cont:
|
||||
char ch = *p++;
|
||||
char ac;
|
||||
for (const char* ap = accept; (ac = *ap++) != '\0';) {
|
||||
for (char const* ap = accept; (ac = *ap++) != '\0';) {
|
||||
if (ac == ch)
|
||||
goto cont;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ cont:
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcspn.html
|
||||
size_t strcspn(const char* s, const char* reject)
|
||||
size_t strcspn(char const* s, char const* reject)
|
||||
{
|
||||
for (auto* p = s;;) {
|
||||
char c = *p++;
|
||||
|
@ -50,7 +50,7 @@ size_t strcspn(const char* s, const char* reject)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strlen.html
|
||||
size_t strlen(const char* str)
|
||||
size_t strlen(char const* str)
|
||||
{
|
||||
size_t len = 0;
|
||||
while (*(str++))
|
||||
|
@ -59,7 +59,7 @@ size_t strlen(const char* str)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strnlen.html
|
||||
size_t strnlen(const char* str, size_t maxlen)
|
||||
size_t strnlen(char const* str, size_t maxlen)
|
||||
{
|
||||
size_t len = 0;
|
||||
for (; len < maxlen && *str; str++)
|
||||
|
@ -68,7 +68,7 @@ size_t strnlen(const char* str, size_t maxlen)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.html
|
||||
char* strdup(const char* str)
|
||||
char* strdup(char const* str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
char* new_str = (char*)malloc(len + 1);
|
||||
|
@ -78,7 +78,7 @@ char* strdup(const char* str)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html
|
||||
char* strndup(const char* str, size_t maxlen)
|
||||
char* strndup(char const* str, size_t maxlen)
|
||||
{
|
||||
size_t len = strnlen(str, maxlen);
|
||||
char* new_str = (char*)malloc(len + 1);
|
||||
|
@ -88,22 +88,22 @@ char* strndup(const char* str, size_t maxlen)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
|
||||
int strcmp(const char* s1, const char* s2)
|
||||
int strcmp(char const* s1, char const* s2)
|
||||
{
|
||||
while (*s1 == *s2++)
|
||||
if (*s1++ == 0)
|
||||
return 0;
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)--s2;
|
||||
return *(unsigned char const*)s1 - *(unsigned char const*)--s2;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html
|
||||
int strncmp(const char* s1, const char* s2, size_t n)
|
||||
int strncmp(char const* s1, char const* s2, size_t n)
|
||||
{
|
||||
if (!n)
|
||||
return 0;
|
||||
do {
|
||||
if (*s1 != *s2++)
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)--s2;
|
||||
return *(unsigned char const*)s1 - *(unsigned char const*)--s2;
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
} while (--n);
|
||||
|
@ -111,10 +111,10 @@ int strncmp(const char* s1, const char* s2, size_t n)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memcmp.html
|
||||
int memcmp(const void* v1, const void* v2, size_t n)
|
||||
int memcmp(void const* v1, void const* v2, size_t n)
|
||||
{
|
||||
auto* s1 = (const uint8_t*)v1;
|
||||
auto* s2 = (const uint8_t*)v2;
|
||||
auto* s1 = (uint8_t const*)v1;
|
||||
auto* s2 = (uint8_t const*)v2;
|
||||
while (n-- > 0) {
|
||||
if (*s1++ != *s2++)
|
||||
return s1[-1] < s2[-1] ? -1 : 1;
|
||||
|
@ -122,13 +122,13 @@ int memcmp(const void* v1, const void* v2, size_t n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int timingsafe_memcmp(const void* b1, const void* b2, size_t len)
|
||||
int timingsafe_memcmp(void const* b1, void const* b2, size_t len)
|
||||
{
|
||||
return AK::timing_safe_compare(b1, b2, len) ? 1 : 0;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memcpy.html
|
||||
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
|
||||
void* memcpy(void* dest_ptr, void const* src_ptr, size_t n)
|
||||
{
|
||||
void* original_dest = dest_ptr;
|
||||
asm volatile(
|
||||
|
@ -171,25 +171,25 @@ void* memset(void* dest_ptr, int c, size_t n)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memmove.html
|
||||
void* memmove(void* dest, const void* src, size_t n)
|
||||
void* memmove(void* dest, void const* src, size_t n)
|
||||
{
|
||||
if (((FlatPtr)dest - (FlatPtr)src) >= n)
|
||||
return memcpy(dest, src, n);
|
||||
|
||||
u8* pd = (u8*)dest;
|
||||
const u8* ps = (const u8*)src;
|
||||
u8 const* ps = (u8 const*)src;
|
||||
for (pd += n, ps += n; n--;)
|
||||
*--pd = *--ps;
|
||||
return dest;
|
||||
}
|
||||
|
||||
const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length)
|
||||
void const* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length)
|
||||
{
|
||||
return AK::memmem(haystack, haystack_length, needle, needle_length);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcpy.html
|
||||
char* strcpy(char* dest, const char* src)
|
||||
char* strcpy(char* dest, char const* src)
|
||||
{
|
||||
char* original_dest = dest;
|
||||
while ((*dest++ = *src++) != '\0')
|
||||
|
@ -198,7 +198,7 @@ char* strcpy(char* dest, const char* src)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncpy.html
|
||||
char* strncpy(char* dest, const char* src, size_t n)
|
||||
char* strncpy(char* dest, char const* src, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < n && src[i] != '\0'; ++i)
|
||||
|
@ -208,7 +208,7 @@ char* strncpy(char* dest, const char* src, size_t n)
|
|||
return dest;
|
||||
}
|
||||
|
||||
size_t strlcpy(char* dest, const char* src, size_t n)
|
||||
size_t strlcpy(char* dest, char const* src, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
// Would like to test i < n - 1 here, but n might be 0.
|
||||
|
@ -222,7 +222,7 @@ size_t strlcpy(char* dest, const char* src, size_t n)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strchr.html
|
||||
char* strchr(const char* str, int c)
|
||||
char* strchr(char const* str, int c)
|
||||
{
|
||||
char ch = c;
|
||||
for (;; ++str) {
|
||||
|
@ -234,12 +234,12 @@ char* strchr(const char* str, int c)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699959399/functions/index.html
|
||||
char* index(const char* str, int c)
|
||||
char* index(char const* str, int c)
|
||||
{
|
||||
return strchr(str, c);
|
||||
}
|
||||
|
||||
char* strchrnul(const char* str, int c)
|
||||
char* strchrnul(char const* str, int c)
|
||||
{
|
||||
char ch = c;
|
||||
for (;; ++str) {
|
||||
|
@ -249,10 +249,10 @@ char* strchrnul(const char* str, int c)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memchr.html
|
||||
void* memchr(const void* ptr, int c, size_t size)
|
||||
void* memchr(void const* ptr, int c, size_t size)
|
||||
{
|
||||
char ch = c;
|
||||
auto* cptr = (const char*)ptr;
|
||||
auto* cptr = (char const*)ptr;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (cptr[i] == ch)
|
||||
return const_cast<char*>(cptr + i);
|
||||
|
@ -261,7 +261,7 @@ void* memchr(const void* ptr, int c, size_t size)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strrchr.html
|
||||
char* strrchr(const char* str, int ch)
|
||||
char* strrchr(char const* str, int ch)
|
||||
{
|
||||
char* last = nullptr;
|
||||
char c;
|
||||
|
@ -273,13 +273,13 @@ char* strrchr(const char* str, int ch)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699959399/functions/rindex.html
|
||||
char* rindex(const char* str, int ch)
|
||||
char* rindex(char const* str, int ch)
|
||||
{
|
||||
return strrchr(str, ch);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcat.html
|
||||
char* strcat(char* dest, const char* src)
|
||||
char* strcat(char* dest, char const* src)
|
||||
{
|
||||
size_t dest_length = strlen(dest);
|
||||
size_t i;
|
||||
|
@ -290,7 +290,7 @@ char* strcat(char* dest, const char* src)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncat.html
|
||||
char* strncat(char* dest, const char* src, size_t n)
|
||||
char* strncat(char* dest, char const* src, size_t n)
|
||||
{
|
||||
size_t dest_length = strlen(dest);
|
||||
size_t i;
|
||||
|
@ -300,7 +300,7 @@ char* strncat(char* dest, const char* src, size_t n)
|
|||
return dest;
|
||||
}
|
||||
|
||||
const char* const sys_errlist[] = {
|
||||
char const* const sys_errlist[] = {
|
||||
#define __ENUMERATE_ERRNO_CODE(c, s) s,
|
||||
ENUMERATE_ERRNO_CODES(__ENUMERATE_ERRNO_CODE)
|
||||
#undef __ENUMERATE_ERRNO_CODE
|
||||
|
@ -350,7 +350,7 @@ char* strsignal(int signum)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strstr.html
|
||||
char* strstr(const char* haystack, const char* needle)
|
||||
char* strstr(char const* haystack, char const* needle)
|
||||
{
|
||||
char nch;
|
||||
char hch;
|
||||
|
@ -369,7 +369,7 @@ char* strstr(const char* haystack, const char* needle)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strpbrk.html
|
||||
char* strpbrk(const char* s, const char* accept)
|
||||
char* strpbrk(char const* s, char const* accept)
|
||||
{
|
||||
while (*s)
|
||||
if (strchr(accept, *s++))
|
||||
|
@ -378,7 +378,7 @@ char* strpbrk(const char* s, const char* accept)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok_r.html
|
||||
char* strtok_r(char* str, const char* delim, char** saved_str)
|
||||
char* strtok_r(char* str, char const* delim, char** saved_str)
|
||||
{
|
||||
if (!str) {
|
||||
if (!saved_str || *saved_str == nullptr)
|
||||
|
@ -433,20 +433,20 @@ char* strtok_r(char* str, const char* delim, char** saved_str)
|
|||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
|
||||
char* strtok(char* str, const char* delim)
|
||||
char* strtok(char* str, char const* delim)
|
||||
{
|
||||
static char* saved_str;
|
||||
return strtok_r(str, delim, &saved_str);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcoll.html
|
||||
int strcoll(const char* s1, const char* s2)
|
||||
int strcoll(char const* s1, char const* s2)
|
||||
{
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strxfrm.html
|
||||
size_t strxfrm(char* dest, const char* src, size_t n)
|
||||
size_t strxfrm(char* dest, char const* src, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < n && src[i] != '\0'; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue