MINOR: ist: Add `istsplit(struct ist*, char)`

istsplit is a combination of iststop + istadv.
This commit is contained in:
Tim Duesterhus 2021-04-05 17:53:56 +02:00 committed by Willy Tarreau
parent 90aa8c7f02
commit 8daf8dceb9
1 changed files with 14 additions and 0 deletions

View File

@ -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 <ist> at the given character. The returned ist is
* equivalent to iststop(ist, delim). The passed <ist> 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
*/