mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added strncmp(3).
This commit is contained in:
parent
a6a2c400bf
commit
728bde3bee
2 changed files with 19 additions and 1 deletions
|
@ -38,7 +38,7 @@ namespace Maxsi
|
|||
char* Cat(char* Dest, const char* Src);
|
||||
int Compare(const char* A, const char* B);
|
||||
int CompareN(const char* A, const char* B, size_t MaxLength);
|
||||
int StartsWith(const char* Haystack, const char* Needle);
|
||||
bool StartsWith(const char* Haystack, const char* Needle);
|
||||
int ToInt(const char* str);
|
||||
|
||||
int ConvertUInt8T(uint8_t num, char* dest);
|
||||
|
|
|
@ -85,6 +85,24 @@ namespace Maxsi
|
|||
}
|
||||
}
|
||||
|
||||
DUAL_FUNCTION(int, strncmp, CompareN, (const char* A, const char* B, size_t MaxLength))
|
||||
{
|
||||
while ( MaxLength-- )
|
||||
{
|
||||
if ( *A == '\0' && *B == '\0' ) { return 0; }
|
||||
if ( *A < *B ) { return -1; }
|
||||
if ( *A > *B ) { return 1; }
|
||||
A++; B++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool StartsWith(const char* haystack, const char* needle)
|
||||
{
|
||||
return CompareN(haystack, needle, Length(needle)) == 0;
|
||||
}
|
||||
|
||||
char* Clone(const char* Input)
|
||||
{
|
||||
size_t InputSize = Length(Input);
|
||||
|
|
Loading…
Add table
Reference in a new issue