]> git.ipfire.org Git - telemetry.git/commitdiff
string: Add function to strip non-whitespace
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 09:34:45 +0000 (09:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 09:34:45 +0000 (09:34 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/string.h

index 20180a859f3e2fea5e425cf1ef6fb52aeb98c44f..4114770843bab506d8e0a43a8c837bb211ae381a 100644 (file)
@@ -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);