all repos — mgba @ f491196bc4fcc6c5c51c1fecff1db78b2070bb81

mGBA Game Boy Advance Emulator

Util: Add endswith
Jeffrey Pfau jeffrey@endrift.com
Tue, 23 Aug 2016 09:08:46 -0700
commit

f491196bc4fcc6c5c51c1fecff1db78b2070bb81

parent

b442282650cb7cb9046f35f6c76ae0e2ec241a39

3 files changed, 11 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -74,6 +74,7 @@ - PSP2: Screenshots are now saved into the Photo Gallery

- Qt: Make reseting when pasued frame-accurate - GBA Video: Optimize compositing cases slightly - VFS: Improve zip file detection + - Util: Add endswith 0.4.1: (2016-07-11) Bugfixes:
M src/util/string.csrc/util/string.c

@@ -39,6 +39,15 @@ }

return last; } +bool endswith(const char* restrict s1, const char* restrict end) { + size_t len = strlen(s1); + size_t endLen = strlen(end); + if (len < endLen) { + return false; + } + return strcmp(&s1[len - endLen], end) == 0; +} + uint32_t utf16Char(const uint16_t** unicode, size_t* length) { if (*length < 2) { *length = 0;
M src/util/string.hsrc/util/string.h

@@ -18,6 +18,7 @@ char* strdup(const char* str);

#endif char* strnrstr(const char* restrict s1, const char* restrict s2, size_t len); +bool endswith(const char* restrict s1, const char* restrict end); size_t toUtf8(uint32_t unichar, char* buffer); int utfcmp(const uint16_t* utf16, const char* utf8, size_t utf16Length, size_t utf8Length);