From: Tim Duesterhus Date: Mon, 5 Apr 2021 15:53:56 +0000 (+0200) Subject: MINOR: ist: Add `istsplit(struct ist*, char)` X-Git-Tag: v2.4-dev16~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8daf8dceb9527d6515dd24e132a935a63feb08be;p=thirdparty%2Fhaproxy.git MINOR: ist: Add `istsplit(struct ist*, char)` istsplit is a combination of iststop + istadv. --- diff --git a/include/import/ist.h b/include/import/ist.h index 6ece7cdf96..daf23d5521 100644 --- a/include/import/ist.h +++ b/include/import/ist.h @@ -801,6 +801,20 @@ static inline struct ist istadv(const struct ist ist, const size_t nb) return ist2(ist.ptr + nb, ist.len - nb); } +/* Splits the given at the given character. The returned ist is + * equivalent to iststop(ist, delim). The passed will contain the + * remainder of the string, not including the delimiter. In other words + * it will be advanced by the length of the returned string plus 1. + */ +static inline struct ist istsplit(struct ist *ist, char delim) +{ + const struct ist result = iststop(*ist, delim); + + *ist = istadv(*ist, result.len + 1); + + return result; +} + /* * compare 2 ists and return non-zero if they are the same */