From: Jerome Magnin Date: Fri, 21 Feb 2020 09:33:12 +0000 (+0100) Subject: MINOR: ist: add an iststop() function X-Git-Tag: v2.2-dev3~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9dde0b2d31dd0e588a6fcd34ca8b6dd6cee73e3d;p=thirdparty%2Fhaproxy.git MINOR: ist: add an iststop() function Add a function that finds a character in an ist and returns an updated ist with the length of the portion of the original string that doesn't contain the char. Might be backported to 2.1 --- diff --git a/include/common/ist.h b/include/common/ist.h index 10c0b6c083..0d8b457218 100644 --- a/include/common/ist.h +++ b/include/common/ist.h @@ -708,4 +708,16 @@ static inline struct ist istist(const struct ist ist, const struct ist pat) return ist2(NULL, 0); } +/* + * looks for the first occurence of in string and returns a shorter + * ist if char is found. + */ +static inline struct ist iststop(const struct ist ist, char chr) +{ + size_t len = 0; + + while (len++ < ist.len && ist.ptr[len - 1] != chr) + ; + return ist2(ist.ptr, len - 1); +} #endif