diff --git a/kernel/include/std/string.h b/kernel/include/std/string.h index 508ba10a..8228d872 100644 --- a/kernel/include/std/string.h +++ b/kernel/include/std/string.h @@ -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); diff --git a/kernel/src/std/string.cpp b/kernel/src/std/string.cpp index f0d130cd..f3d328a7 100644 --- a/kernel/src/std/string.cpp +++ b/kernel/src/std/string.cpp @@ -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; }