surf-adblock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 570bc167d93bac50d3b773e420a8cd9b1150ca2c
parent 60429d74233b5c0f61db8bf5725b4fdda92faa77
Author: Quentin Rameau <quinq@fifth.space>
Date:   Mon, 18 Jul 2016 01:06:05 +0200

don't modify input string in parsedomains

Diffstat:
surf-adblock.c | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/surf-adblock.c b/surf-adblock.c @@ -416,7 +416,7 @@ domain=... if domain is prefixed with ~, ignore. multiple domains can be separated with | */ static int -parsedomains(char *s, int sep, struct filterdomain **head) +parsedomains(const char *s, int sep, struct filterdomain **head) { struct filterdomain *d, *last = *head = NULL; char *p; @@ -431,12 +431,15 @@ parsedomains(char *s, int sep, struct filterdomain **head) if (!*s || *s == sep) break; - if ((p = strchr(s, sep))) /* TODO: should not contain , */ - *p = '\0'; - if (!(d = wecalloc(1, sizeof(struct filterdomain)))) return -1; - if (!(d->domain = westrdup(s))) + if (p = strchr(s, sep)) { /* TODO: should not contain ',' */ + d->domain = westrndup(s, p - s); + s = p + 1; + } else { + d->domain = westrdup(s); + } + if (!d->domain) return -1; d->inverse = inverse; @@ -444,11 +447,6 @@ parsedomains(char *s, int sep, struct filterdomain **head) *head = last = d; else last = last->next = d; - - if (p) { - *p = sep; - s = p + 1; - } } while (p); return (*head != NULL);