Consistent naming

This commit is contained in:
apio 2022-09-10 18:06:46 +02:00
parent fe672e6a18
commit e3e2952661
2 changed files with 17 additions and 17 deletions

View File

@ -4,11 +4,11 @@
size_t strlen(const char* __s);
__attribute__((deprecated)) char* strcpy(char* dest, const char* src);
__attribute__((deprecated)) int strcmp(const char* s1, const char* s2);
__attribute__((deprecated)) int strcmp(const char* a, const char* b);
__attribute__((deprecated)) char* strcat(char* dest, const char* src);
char* strncpy(char* dest, const char* src, size_t n);
int strncmp(const char* s1, const char* s2, size_t n);
int strncmp(const char* a, const char* b, size_t n);
char* strncat(char* dest, const char* src, size_t n);
char* strstr(char* haystack, char* needle);

View File

@ -21,25 +21,25 @@ char* strncpy(char* dest, const char* src, size_t n)
return dest;
}
int strcmp(const char* s1, const char* s2)
int strcmp(const char* a, const char* b)
{
while (*s1 && (*s1 == *s2))
while (*a && (*a == *b))
{
s1++;
s2++;
a++;
b++;
}
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
return *(const unsigned char*)a - *(const unsigned char*)b;
}
int strncmp(const char* s1, const char* s2, size_t n)
int strncmp(const char* a, const char* b, size_t n)
{
const char* base = s1;
while (*s1 && (*s1 == *s2) && (size_t)(s1 - base) < (n - 1))
const char* base = a;
while (*a && (*a == *b) && (size_t)(a - base) < (n - 1))
{
s1++;
s2++;
a++;
b++;
}
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
return *(const unsigned char*)a - *(const unsigned char*)b;
}
char* strncat(char* dest, const char* src, size_t n)
@ -100,12 +100,12 @@ void* memset(void* dest, int c, size_t n)
int memcmp(const void* a, const void* b, size_t n)
{
const char* a_uchar = (const char*)a;
const char* b_uchar = (const char*)b;
for (; n && a_uchar == b_uchar; n--, a_uchar++, b_uchar++)
const char* _a = (const char*)a;
const char* _b = (const char*)b;
for (; n && _a == _b; n--, _a++, _b++)
;
if (!n) return 0;
if (*a_uchar > *b_uchar) return 1;
if (*_a > *_b) return 1;
return -1;
}