Generalize string trunctation util function

Add an additional argument to let the client pass the possible end
chars.
This commit is contained in:
Romain Vimont
2021-11-17 21:38:59 +01:00
parent f2781a8b6d
commit 9619ade706
4 changed files with 26 additions and 8 deletions

View File

@@ -293,9 +293,9 @@ error:
}
size_t
sc_str_truncate_first_line(char *data, size_t len) {
sc_str_truncate(char *data, size_t len, const char *endchars) {
data[len - 1] = '\0';
char *eol = strpbrk(data, "\r\n");
char *eol = strpbrk(data, endchars);
if (eol) {
*eol = '\0';
len = eol - data;