From 1d067868c05cc3b8b8b76f6d21ef4a3eebdc885c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 15 Aug 2018 14:47:48 +0200 Subject: UI: tweak drawing of header status text for transparent headers. --- source/blender/blenlib/BLI_string.h | 1 + source/blender/blenlib/intern/string.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index faa8dc03615..eef4e0647aa 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -85,6 +85,7 @@ size_t BLI_strnlen(const char *str, const size_t maxlen) ATTR_WARN_UNUSED_RESULT void BLI_str_tolower_ascii(char *str, const size_t len) ATTR_NONNULL(); void BLI_str_toupper_ascii(char *str, const size_t len) ATTR_NONNULL(); +void BLI_str_rstrip(char *str) ATTR_NONNULL(); int BLI_str_rstrip_float_zero(char *str, const char pad) ATTR_NONNULL(); int BLI_str_index_in_array_n(const char *__restrict str, const char **__restrict str_array, const int str_array_len) ATTR_NONNULL(); diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index c1696a912ba..f46676ac0cd 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -778,6 +778,21 @@ void BLI_str_toupper_ascii(char *str, const size_t len) str[i] -= 'a' - 'A'; } +/** + * Strip whitespace from end of the string. + */ +void BLI_str_rstrip(char *str) +{ + for (int i = strlen(str) - 1; i > 0; i--) { + if (isspace(str[i])) { + str[i] = '\0'; + } + else { + break; + } + } +} + /** * Strip trailing zeros from a float, eg: * 0.0000 -> 0.0 -- cgit v1.2.3