surf-adblock

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

commit 1b2fa25986e2fbbecc4caa7a220364536fdab2af
parent c08593ce08d4b64713b3d8dd5433e9226d9df018
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 17 Jul 2016 14:07:23 +0200

don't exit on failed initialization (would crash the page)

we still have to think how to handle OOM situations.

Diffstat:
surf-adblock.c | 30++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/surf-adblock.c b/surf-adblock.c @@ -112,6 +112,18 @@ static String globalcss; static struct filterrule *rules; static void +weprintf(const char *fmt, ...) +{ + va_list ap; + + fprintf(stderr, "surf-adblock: "); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} + +static void eprintf(const char *fmt, ...) { va_list ap; @@ -827,15 +839,21 @@ webkit_web_extension_initialize(WebKitWebExtension *ext) 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"); + if (n < 0 || (size_t)n >= sizeof(filepath)) { + weprintf("fatal: rules file path too long"); + return; + } - if (!(fp = fopen(filepath, "r"))) - eprintf("fatal: cannot open rules file %s: %s\n", + if (!(fp = fopen(filepath, "r"))) { + weprintf("fatal: cannot open rules file %s: %s\n", filepath, strerror(errno)); - if (!(rules = loadrules(fp))) - eprintf("fatal: cannot read rules file %s: %s\n", + return; + } + if (!(rules = loadrules(fp))) { + weprintf("fatal: cannot read rules file %s: %s\n", filepath, strerror(errno)); + return; + } fclose(fp); /* general CSS rules: all sites */