feature (kernel): Implemented function to find the last matching char in a string
This commit is contained in:
parent
b89825b589
commit
b607c9280b
|
@ -24,6 +24,7 @@ typedef const char* string_t;
|
|||
uint32_t string_length (string_t string);
|
||||
bool string_compare (string_t a, string_t b);
|
||||
uint32_t string_find_next (string_t string, char chr);
|
||||
uint32_t string_find_last (string_t string, char chr);
|
||||
|
||||
uint64_t variadic_format_size (string_t string, va_list args);
|
||||
uint64_t format_size (string_t string, ...);
|
||||
|
|
|
@ -43,6 +43,18 @@ uint32_t string_find_next(string_t string, char chr) {
|
|||
return n;
|
||||
}
|
||||
|
||||
uint32_t string_find_last(string_t string, char chr) {
|
||||
uint32_t n = string_length(string);
|
||||
|
||||
string += n;
|
||||
while(*string != chr && n != 0) {
|
||||
string--;
|
||||
n--;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
uint64_t variadic_format_size(string_t string, va_list args) {
|
||||
const char* buffer_in = (const char*)string;
|
||||
|
||||
|
|
Loading…
Reference in New Issue