all repos — mgba @ 0367d94aad98534aa4d997c7cb9fb85b44063c74

mGBA Game Boy Advance Emulator

Util: Add rtrim
Jeffrey Pfau jeffrey@endrift.com
Fri, 19 Aug 2016 05:06:45 -0700
commit

0367d94aad98534aa4d997c7cb9fb85b44063c74

parent

947ef7edea90b134c9dd06d70fa05adab3a4fb0f

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

jump to
M CHANGESCHANGES

@@ -62,6 +62,7 @@ - GBA Video: Optimize mode 0 rendering

- Qt: Remove default autofire mappings - PSP2: Allow UTF-8 filenames - Util: Add Vector GetConstPointer + - Util: Add rtrim 0.4.1: (2016-07-11) Bugfixes:
M src/util/string.csrc/util/string.c

@@ -340,3 +340,14 @@ value |= nybble;

*out = value; return line; } + +void rtrim(char* string) { + if (!*string) { + return; + } + char* end = string + strlen(string) - 1; + while (isspace((int) *end) && end >= string) { + *end = '\0'; + --end; + } +}
M src/util/string.hsrc/util/string.h

@@ -33,4 +33,6 @@ const char* hex12(const char* line, uint16_t* out);

const char* hex8(const char* line, uint8_t* out); const char* hex4(const char* line, uint8_t* out); +void rtrim(char* string); + #endif