From: Michael Tremer Date: Wed, 8 Oct 2025 09:34:45 +0000 (+0000) Subject: string: Add function to strip non-whitespace X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3a9a023f6f74e95cee877c403fad6137b5bac6e;p=telemetry.git string: Add function to strip non-whitespace Signed-off-by: Michael Tremer --- 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);