diff options
author | David Bremner <david@tethera.net> | 2017-07-11 21:53:15 -0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2017-07-11 21:53:15 -0300 |
commit | 2f9741043a28227ef22b82a6670ff7fc5a180dc7 (patch) | |
tree | 2cbf0c9f26f6e90dceef5b8d8f27ae1f28ccf098 /lib/mystring/find_last_of.cc |
Import Upstream version 1.00RC5
Diffstat (limited to 'lib/mystring/find_last_of.cc')
-rw-r--r-- | lib/mystring/find_last_of.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/mystring/find_last_of.cc b/lib/mystring/find_last_of.cc new file mode 100644 index 0000000..b8f8831 --- /dev/null +++ b/lib/mystring/find_last_of.cc @@ -0,0 +1,24 @@ +#include "mystring.h" +#include <string.h> + +int mystring::find_last_of(const char* setstr, size_t setlen, + size_t offset) const +{ + if(offset == (size_t)-1) + offset = rep->length-1; + for(int i = offset; i >= 0; --i) { + if(memchr(setstr, rep->buf[i], setlen)) + return i; + } + return -1; +} + +int mystring::find_last_of(const char* setstr, size_t offset) const +{ + return find_last_of(setstr, strlen(setstr), offset); +} + +int mystring::find_last_of(const mystring& setstr, size_t offset) const +{ + return find_last_of(setstr.rep->buf, setstr.rep->length, offset); +} |