better error message, cleanup old code, update TODO - surf-adblock - Surf adblock web extension
 (HTM) git clone git://git.codemadness.org/surf-adblock
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0cd2ac315bf63d72bb5e7241b08588c92627efc7
 (DIR) parent d23e1f8aeddd7fafb9570c3a0d042a8d00303c05
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Thu, 14 Jul 2016 22:38:38 +0200
       
       better error message, cleanup old code, update TODO
       
       Diffstat:
         M TODO                                |       4 +++-
         M surf-adblock.c                      |      17 ++++-------------
       
       2 files changed, 7 insertions(+), 14 deletions(-)
       ---
 (DIR) diff --git a/TODO b/TODO
       @@ -3,7 +3,9 @@ Docs:
        - https://adblockplus.org/filters
        
        - separate between site-specific and global block rules.
       -- optimize matching.
       +- optimize matching:
       +        ? hashtable per domain for specific rules?
       +        - separate general block rules into a separate list.
        - optimize memory allocation.
        - optimize: pregenerate one global stylesheet that applies to all sites?
        ? support exception rules #@#
 (DIR) diff --git a/surf-adblock.c b/surf-adblock.c
       @@ -28,7 +28,6 @@ struct filterdomain {
        };
        
        struct filterrule {
       -        char *line; /* DEBUG */
                /* type: match mask, must be atleast 32-bit, see FilterType enum */
                unsigned long block;
                int matchbegin;
       @@ -579,7 +578,7 @@ parserule(struct filterrule *f, char *s)
                                        ft->fn(f, values);
                        } else {
                                /* DEBUG */
       -                        fprintf(stderr, "unknown option: '%s' in rule: %s\n",
       +                        fprintf(stderr, "ignored: unknown option: '%s' in rule: %s\n",
                                        key.name, f->uri);
                        }
        
       @@ -624,7 +623,6 @@ loadrules(FILE *fp)
                                else
                                        rn = rn->next = r;
                                memcpy(rn, &f, sizeof(struct filterrule));
       -                        r->line = estrdup(line); /* DEBUG */
                        }
                }
                return rules;
       @@ -732,20 +730,12 @@ sendrequest(WebKitWebPage *wp, WebKitURIRequest *req,
        }
        
        static void
       -objectcleared(WebKitScriptWorld *w, WebKitWebPage *wp, WebKitFrame *f, Page *p)
       -{
       -}
       -
       -static void
        webpagecreated(WebKitWebExtension *e, WebKitWebPage *p, gpointer unused)
        {
                Page *np = newpage(p);
       -        WebKitScriptWorld *w = webkit_script_world_get_default();
        
                g_signal_connect(p, "send-request",
                                 G_CALLBACK(sendrequest), np);
       -        g_signal_connect(w, "window-object-cleared",
       -                         G_CALLBACK(objectcleared), np);
                g_signal_connect(p, "document-loaded",
                                 G_CALLBACK(documentloaded), np);
        }
       @@ -762,12 +752,13 @@ webkit_web_extension_initialize(WebKitWebExtension *e)
                        return;
                }
                if (!(rules = loadrules(fp))) {
       -                fprintf(stderr, "cannot load adblock rules\n");
       +                fprintf(stderr, "fatal: cannot read adblock rules from file: %s: %s\n",
       +                        filename, strerror(errno));
                        return;
                }
                fclose(fp);
        
       -        /* general rules: all sites */
       +        /* general CSS rules: all sites */
                for (r = rules; r; r = r->next) {
                        if (!r->css || r->domains)
                                continue;