surf-adblock

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

commit b86adf21767a22614e170a19b19eaf116a422532
parent 82cd3bf28176da0e23599f586ef6f18f06a059ba
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sat, 16 Jul 2016 19:15:45 +0200

style correction, shorten long lines

Diffstat:
surf-adblock.c | 35+++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/surf-adblock.c b/surf-adblock.c @@ -84,7 +84,8 @@ static struct filtertype filtertypes[] = { * requests for now */ { 0, STRP("collapse"), 1, 1, 0, NULL }, { FilterTypeDocument, STRP("document"), 1, 0, 1, NULL }, - { 0, STRP("domain"), 0, 1, 0, &parsedomainsoption }, /* domain=... */ + { 0, STRP("domain"), 0, 1, 0, + /* domain=... */ &parsedomainsoption }, { 0, STRP("donottrack"), 1, 1, 0, NULL }, { FilterTypeElemHide, STRP("elemhide"), 0, 0, 1, NULL }, { 0, STRP("font"), 1, 1, 0, NULL }, @@ -264,7 +265,8 @@ match(const char *pat, const char *str, int fcase) k = str_next(str, n, &sinc); if (k <= 0) return (c==END) ? 0 : 1; - if (c == CARET && (iswdigit(k) || iswalpha(k) || strchr("_-.%", k))) + if (c == CARET && (iswdigit(k) || iswalpha(k) || + strchr("_-.%", k))) return 1; str += sinc; n -= sinc; @@ -441,7 +443,8 @@ parsedomainsoption(struct filterrule *f, char *s) int filtertype_cmp(const void *a, const void *b) { - return strcmp(((struct filtertype *)a)->name, ((struct filtertype *)b)->name); + return strcmp(((struct filtertype *)a)->name, + ((struct filtertype *)b)->name); } /* check if domain is the same domain or a subdomain of `s` */ @@ -464,7 +467,8 @@ matchdomain(const char *s, const char *domain) } int -matchrule(struct filterrule *f, const char *uri, const char *type, const char *domain) +matchrule(struct filterrule *f, const char *uri, const char *type, + const char *domain) { /* NOTE: order matters, see FilterType enum values */ struct filterdomain *d; @@ -608,8 +612,8 @@ parserule(struct filterrule *f, char *s) key.name = s; ft = bsearch(&key, &filtertypes, - sizeof(filtertypes) / sizeof(*filtertypes), sizeof(*filtertypes), - filtertype_cmp); + sizeof(filtertypes) / sizeof(*filtertypes), + sizeof(*filtertypes), filtertype_cmp); /* restore NUL-terminator for domain= option */ if (values) @@ -624,8 +628,8 @@ parserule(struct filterrule *f, char *s) ft->fn(f, values); } else { /* DEBUG */ - fprintf(stderr, "ignored: unknown option: '%s' in rule: %s\n", - key.name, f->uri); + fprintf(stderr, "ignored: unknown option: '%s' " + "in rule: %s\n", key.name, f->uri); } /* restore ',' */ @@ -642,8 +646,9 @@ end: void debugrule(struct filterrule *r) { - printf("\turi: %s\n\tcss: %s\n\tisexception: %d\n\tblockmask: %lu\n===\n", - r->uri ? r->uri : "", r->css ? r->css : "", r->isexception, r->block); + printf("\turi: %s\n\tcss: %s\n\tisexception: %d\n\tblockmask: " + "%lu\n===\n", r->uri ? r->uri : "", r->css ? r->css : "", + r->isexception, r->block); } struct filterrule * @@ -730,12 +735,14 @@ documentloaded(WebKitWebPage *wp, Page *p) el = webkit_dom_document_create_element(doc, "style", NULL); webkit_dom_element_set_attribute(el, "type", "text/css", NULL); webkit_dom_element_set_inner_html(el, globalcss.data, NULL); - webkit_dom_node_append_child(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(el), NULL); + webkit_dom_node_append_child(WEBKIT_DOM_NODE(body), + WEBKIT_DOM_NODE(el), NULL); el = webkit_dom_document_create_element(doc, "style", NULL); webkit_dom_element_set_attribute(el, "type", "text/css", NULL); webkit_dom_element_set_inner_html(el, sitecss.data, NULL); - webkit_dom_node_append_child(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(el), NULL); + webkit_dom_node_append_child(WEBKIT_DOM_NODE(body), + WEBKIT_DOM_NODE(el), NULL); #endif free(uri); @@ -803,8 +810,8 @@ webkit_web_extension_initialize(WebKitWebExtension *ext) } else { if (!(e = getenv("HOME"))) e = ""; - n = snprintf(filepath, sizeof(filepath), "%s%s.surf/adblockrules", - e, e[0] ? "/" : ""); + n = snprintf(filepath, sizeof(filepath), + "%s%s.surf/adblockrules", e, e[0] ? "/" : ""); } if (n < 0 || (size_t)n >= sizeof(filepath)) eprintf("fatal: rules file path too long");