added find back cstring to ARC_String
This commit is contained in:
parent
958fc9810e
commit
0496473cf5
2 changed files with 32 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue