Consistent naming
This commit is contained in:
parent
fe672e6a18
commit
e3e2952661
@ -4,11 +4,11 @@
|
|||||||
size_t strlen(const char* __s);
|
size_t strlen(const char* __s);
|
||||||
|
|
||||||
__attribute__((deprecated)) char* strcpy(char* dest, const char* src);
|
__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);
|
__attribute__((deprecated)) char* strcat(char* dest, const char* src);
|
||||||
|
|
||||||
char* strncpy(char* dest, const char* src, size_t n);
|
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* strncat(char* dest, const char* src, size_t n);
|
||||||
|
|
||||||
char* strstr(char* haystack, char* needle);
|
char* strstr(char* haystack, char* needle);
|
||||||
|
@ -21,25 +21,25 @@ char* strncpy(char* dest, const char* src, size_t n)
|
|||||||
return dest;
|
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++;
|
a++;
|
||||||
s2++;
|
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;
|
const char* base = a;
|
||||||
while (*s1 && (*s1 == *s2) && (size_t)(s1 - base) < (n - 1))
|
while (*a && (*a == *b) && (size_t)(a - base) < (n - 1))
|
||||||
{
|
{
|
||||||
s1++;
|
a++;
|
||||||
s2++;
|
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)
|
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)
|
int memcmp(const void* a, const void* b, size_t n)
|
||||||
{
|
{
|
||||||
const char* a_uchar = (const char*)a;
|
const char* _a = (const char*)a;
|
||||||
const char* b_uchar = (const char*)b;
|
const char* _b = (const char*)b;
|
||||||
for (; n && a_uchar == b_uchar; n--, a_uchar++, b_uchar++)
|
for (; n && _a == _b; n--, _a++, _b++)
|
||||||
;
|
;
|
||||||
if (!n) return 0;
|
if (!n) return 0;
|
||||||
if (*a_uchar > *b_uchar) return 1;
|
if (*_a > *_b) return 1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user