commit 2f7313d8d3f436e9ca77eeb614ec3b91167f3278
Author: Ivan Tham <pickfire_AT_riseup.net>
Date: Thu Dec 17 18:29:12 2015 +0800
[surf] Fix my stupid patch
diff --git a/surf.suckless.org/patches/surf-0.6-searchengines.diff b/surf.suckless.org/patches/surf-0.6-searchengines.diff
index d7325f2..c74a835 100644
--- a/surf.suckless.org/patches/surf-0.6-searchengines.diff
+++ b/surf.suckless.org/patches/surf-0.6-searchengines.diff
_AT_@ -1,50 +1,3 @@
-diff --cc surf.c
-index fdfaab1,deb23b7..0000000
---- a/surf.c
-+++ b/surf.c
-_AT_@@ -178,10 -185,10 +184,11 @@@ static void loaduri(Client *c, const Ar
- static void navigate(Client *c, const Arg *arg);
- static Client *newclient(void);
- static void newwindow(Client *c, const Arg *arg, gboolean noembed);
-+ static gchar *parseuri(const gchar *uri);
- static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
- static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
- - WebKitHitTestResult *target, gboolean keyboard, Client *c);
- + WebKitHitTestResult *target, gboolean keyboard,
- + Client *c);
- static void menuactivate(GtkMenuItem *item, Client *c);
- static void print(Client *c, const Arg *arg);
- static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event,
-_AT_@@ -1172,11 -1128,25 +1178,26 @@@ menuactivate(GtkMenuItem *item, Client
- }
- }
-
-- void
-+ static gchar *
-+ parseuri(const gchar *uri) {
-+ guint i;
-+
-+ for (i = 0; i < LENGTH(searchengines); i++) {
-+ if (searchengines[i].token == NULL || searchengines[i].uri == NULL || \
-+ *(uri + strlen(searchengines[i].token)) != ' ')
-+ continue;
-+ if (g_str_has_prefix(uri, searchengines[i].token))
-+ return g_strdup_printf(searchengines[i].uri, uri + strlen(searchengines[i].token) + 1);
-+ }
-+
-+ return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("
http://%s", uri);
-+ }
-+
-+ static void
- -pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
- +pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
- +{
- Arg arg = {.v = text };
- - if(text != NULL)
- + if (text != NULL)
- loaduri((Client *) d, &arg);
- }
-
diff --git a/config.def.h b/config.def.h
index 93a3d49..4ac7f15 100644
--- a/config.def.h
_AT_@ -63,3 +16,62 @@ index 93a3d49..4ac7f15 100644
#define MODKEY GDK_CONTROL_MASK
/* hotkeys */
+diff --git a/surf.c b/surf.c
+index fdfaab1..b6ac237 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -91,6 +91,12 @@ typedef struct {
+ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+
+ typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
++
++typedef struct {
+ char *regex;
+ char *style;
+ regex_t re;
+_AT_@ -178,6 +184,7 @@ static void loaduri(Client *c, const Arg *arg);
+ static void navigate(Client *c, const Arg *arg);
+ static Client *newclient(void);
+ static void newwindow(Client *c, const Arg *arg, gboolean noembed);
++static gchar *parseuri(const gchar *uri);
+ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+ static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
+ WebKitHitTestResult *target, gboolean keyboard,
+_AT_@ -838,8 +845,7 @@ loaduri(Client *c, const Arg *arg)
+ u = g_strdup_printf("file://%s", rp);
+ free(rp);
+ } else {
+- u = g_strrstr(uri, "://") ? g_strdup(uri)
+- : g_strdup_printf("
http://%s", uri);
++ u = parseuri(uri);
+ }
+
+ setatom(c, AtomUri, uri);
+_AT_@ -1172,7 +1178,22 @@ menuactivate(GtkMenuItem *item, Client *c)
+ }
+ }
+
+-void
++static gchar *
++parseuri(const gchar *uri) {
++ guint i;
++
++ for (i = 0; i < LENGTH(searchengines); i++) {
++ if (searchengines[i].token == NULL || searchengines[i].uri == NULL || \
++ *(uri + strlen(searchengines[i].token)) != ' ')
++ continue;
++ if (g_str_has_prefix(uri, searchengines[i].token))
++ return g_strdup_printf(searchengines[i].uri, uri + strlen(searchengines[i].token) + 1);
++ }
++
++ return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("
http://%s", uri);
++}
++
++static void
+ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
+ {
+ Arg arg = {.v = text };
Received on Thu Dec 17 2015 - 11:29:17 CET