summaryrefslogtreecommitdiffstats
path: root/include/import/ist.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:11:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:11:10 +0000
commitcff6d757e3ba609c08ef2aaa00f07e53551e5bf6 (patch)
tree08c4fc3255483ad397d712edb4214ded49149fd9 /include/import/ist.h
parentAdding upstream version 2.9.7. (diff)
downloadhaproxy-upstream/3.0.0.tar.xz
haproxy-upstream/3.0.0.zip
Adding upstream version 3.0.0.upstream/3.0.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/import/ist.h')
-rw-r--r--include/import/ist.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/import/ist.h b/include/import/ist.h
index e4e1425..962d63b 100644
--- a/include/import/ist.h
+++ b/include/import/ist.h
@@ -331,6 +331,25 @@ static inline struct ist istzero(const struct ist ist, size_t size)
return ret;
}
+/* Remove trailing newline characters if present in <ist> by reducing its
+ * length. Both '\n', '\r' and '\n\r' match. Return the modified ist.
+ */
+static inline struct ist iststrip(const struct ist ist)
+{
+ struct ist ret = ist;
+
+ if (ret.len) {
+ if (ret.ptr[ret.len - 1] == '\n')
+ --ret.len;
+ }
+ if (ret.len) {
+ if (ret.ptr[ret.len - 1] == '\r')
+ --ret.len;
+ }
+
+ return ret;
+}
+
/* returns the ordinal difference between two strings :
* < 0 if ist1 < ist2
* = 0 if ist1 == ist2