summaryrefslogtreecommitdiff
path: root/we_adblock.c
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2015-08-29 16:23:03 +0200
committerPeter Hofmann <scm@uninformativ.de>2015-08-29 16:26:20 +0200
commit682cd872d8298d28562730b17c2a2977e4d35a22 (patch)
tree283769abd41600a6e8d3e46cc9da045ab5068ed6 /we_adblock.c
parentb3392c779178874daeb5d79fe6e98942007a5241 (diff)
downloadlariza-682cd872d8298d28562730b17c2a2977e4d35a22.tar.gz
Retab
For years, I've been using a tab size of 4. This, however, conflicts with the idea of limiting the line length: You can only limit the line length in a meaningful way if you're using the default tab size of 8. But 8 is a huge waste of space... So let's just do this. Retab to 4 spaces and limit the line length to about 80 characters.
Diffstat (limited to 'we_adblock.c')
-rw-r--r--we_adblock.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/we_adblock.c b/we_adblock.c
index be4e7b7..9a044a9 100644
--- a/we_adblock.c
+++ b/we_adblock.c
@@ -10,72 +10,72 @@ static GSList *adblock_patterns = NULL;
static void
adblock_load(void)
{
- GRegex *re = NULL;
- GError *err = NULL;
- GIOChannel *channel = NULL;
- gchar *path = NULL, *buf = NULL;
+ GRegex *re = NULL;
+ GError *err = NULL;
+ GIOChannel *channel = NULL;
+ gchar *path = NULL, *buf = NULL;
- path = g_build_filename(g_get_user_config_dir(), __NAME__, "adblock.black",
- NULL);
- channel = g_io_channel_new_file(path, "r", &err);
- if (channel != NULL)
- {
- while (g_io_channel_read_line(channel, &buf, NULL, NULL, NULL)
- == G_IO_STATUS_NORMAL)
- {
- g_strstrip(buf);
- if (buf[0] != '#')
- {
- re = g_regex_new(buf,
- G_REGEX_CASELESS | G_REGEX_OPTIMIZE,
- G_REGEX_MATCH_PARTIAL, &err);
- if (err != NULL)
- {
- fprintf(stderr, __NAME__": Could not compile regex: %s\n", buf);
- g_error_free(err);
- err = NULL;
- }
- else
- adblock_patterns = g_slist_append(adblock_patterns, re);
- }
- g_free(buf);
- }
- g_io_channel_shutdown(channel, FALSE, NULL);
- }
- g_free(path);
+ path = g_build_filename(g_get_user_config_dir(), __NAME__, "adblock.black",
+ NULL);
+ channel = g_io_channel_new_file(path, "r", &err);
+ if (channel != NULL)
+ {
+ while (g_io_channel_read_line(channel, &buf, NULL, NULL, NULL)
+ == G_IO_STATUS_NORMAL)
+ {
+ g_strstrip(buf);
+ if (buf[0] != '#')
+ {
+ re = g_regex_new(buf,
+ G_REGEX_CASELESS | G_REGEX_OPTIMIZE,
+ G_REGEX_MATCH_PARTIAL, &err);
+ if (err != NULL)
+ {
+ fprintf(stderr, __NAME__": Could not compile regex: %s\n", buf);
+ g_error_free(err);
+ err = NULL;
+ }
+ else
+ adblock_patterns = g_slist_append(adblock_patterns, re);
+ }
+ g_free(buf);
+ }
+ g_io_channel_shutdown(channel, FALSE, NULL);
+ }
+ g_free(path);
}
static gboolean
web_page_send_request(WebKitWebPage *web_page, WebKitURIRequest *request,
WebKitURIResponse *redirected_response, gpointer user_data)
{
- GSList *it = adblock_patterns;
- const gchar *uri;
+ GSList *it = adblock_patterns;
+ const gchar *uri;
- uri = webkit_uri_request_get_uri(request);
+ uri = webkit_uri_request_get_uri(request);
- while (it)
- {
- if (g_regex_match((GRegex *)(it->data), uri, 0, NULL))
- return TRUE;
- it = g_slist_next(it);
- }
+ while (it)
+ {
+ if (g_regex_match((GRegex *)(it->data), uri, 0, NULL))
+ return TRUE;
+ it = g_slist_next(it);
+ }
- return FALSE;
+ return FALSE;
}
static void
web_page_created_callback(WebKitWebExtension *extension, WebKitWebPage *web_page,
gpointer user_data)
{
- g_signal_connect_object(web_page, "send-request",
- G_CALLBACK(web_page_send_request), NULL, 0);
+ g_signal_connect_object(web_page, "send-request",
+ G_CALLBACK(web_page_send_request), NULL, 0);
}
G_MODULE_EXPORT void
webkit_web_extension_initialize(WebKitWebExtension *extension)
{
- adblock_load();
- g_signal_connect(extension, "page-created",
- G_CALLBACK(web_page_created_callback), NULL);
+ adblock_load();
+ g_signal_connect(extension, "page-created",
+ G_CALLBACK(web_page_created_callback), NULL);
}