From f3a9a023f6f74e95cee877c403fad6137b5bac6e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 8 Oct 2025 09:34:45 +0000 Subject: [PATCH] string: Add function to strip non-whitespace Signed-off-by: Michael Tremer --- src/daemon/string.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/daemon/string.h b/src/daemon/string.h index 20180a8..4114770 100644 --- a/src/daemon/string.h +++ b/src/daemon/string.h @@ -143,6 +143,17 @@ static inline void collecty_string_rstrip(char* s) { s[l-- - 1] = '\0'; } +static inline void collecty_string_rstrip2(char* s, char c) { + if (!s) + return; + + size_t l = strlen(s); + + // Remove the character at the end + while (l > 0 && s[l - 1] == c) + s[l-- - 1] = '\0'; +} + static inline void collecty_string_strip(char* s) { // Strip everything on the left side collecty_string_lstrip(s); -- 2.47.3