Util: Add rtrim

This commit is contained in:
Jeffrey Pfau 2016-08-19 05:06:45 -07:00
parent 947ef7edea
commit 0367d94aad
3 changed files with 14 additions and 0 deletions

View File

@ -62,6 +62,7 @@ Misc:
- Qt: Remove default autofire mappings
- PSP2: Allow UTF-8 filenames
- Util: Add Vector GetConstPointer
- Util: Add rtrim
0.4.1: (2016-07-11)
Bugfixes:

View File

@ -340,3 +340,14 @@ const char* hex4(const char* line, uint8_t* out) {
*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;
}
}

View File

@ -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