From 300d834e9151637962d36df1ba650fbf1666c722 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 31 Jul 2022 17:37:55 -0300 Subject: misc: Make sure that `s` starts at the character before the delimiter in `find_delm()` Also `s` doesn't get incremented when checking if the current character is a backslash now. --- misc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index a2502e2..97333eb 100644 --- a/misc.c +++ b/misc.c @@ -72,9 +72,9 @@ char *get_line(char **str) { char *find_delm(char *str, const char *delm, int skip_delm) { if (!is_empty(str)) { char *s; - for (s = str; *s != '\0'; s += strcspn(s, delm)) { - if (*s++ == '\\') { - s += strspn(s, delm); + for (s = &str[strcspn(str, delm)]; *s != '\0'; s += strcspn(s, delm)) { + if (*s == '\\') { + s += strspn(++s, delm); continue; } else { break; -- cgit v1.2.3-13-gbd6f