added find back cstring to ARC_String

This commit is contained in:
herbglitch 2024-02-22 02:50:06 -07:00
parent 958fc9810e
commit 0496473cf5
2 changed files with 32 additions and 0 deletions

View file

@ -204,6 +204,27 @@ uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring){
return ~(uint64_t)0;
}
uint64_t ARC_String_FindBackCString(ARC_String *string, const char *cstring, uint64_t length){
if(!string || !cstring){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_ERR("ARC_String_FindBack(string, substring), string or substring was null");
return ~(uint64_t)0;
}
if(length > string->length){
return ~(uint64_t)0;
}
uint64_t max = string->length - (length - 1);
for(; max; max--){
if(!strncmp(string->data + (max - 1), cstring, length)){
return max;
}
}
return ~(uint64_t)0;
}
void ARC_String_StripEnds(ARC_String **stripped, ARC_String *original, char charToStrip){
if(!original){
arc_errno = ARC_ERRNO_NULL;