I've updated the searchengines patch for surf, the patch on the site
only works for 0.3.
diff -up surf-0.4/config.def.h surf-0.4-mychanges/config.def.h
--- surf-0.4/config.def.h	2010-05-30 16:05:25.000000000 -0400
+++ surf-0.4-mychanges/config.def.h	2010-06-05 14:23:36.000000000 -0400
@@ -38,3 +38,7 @@ static Key keys[] = {
     { MODKEY,               GDK_n,      find,       { .b = TRUE } },
     { MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
 };
+
+static SearchEngine searchengines[] = {
+    { NULL, NULL },
+};
diff -up surf-0.4/surf.c surf-0.4-mychanges/surf.c
--- surf-0.4/surf.c	2010-05-30 16:05:25.000000000 -0400
+++ surf-0.4-mychanges/surf.c	2010-06-05 14:23:36.000000000 -0400
@@ -55,6 +55,11 @@ typedef struct {
 	const Arg arg;
 } Key;
 
+typedef struct {
+	char *token;
+	char *uri;
+} SearchEngine;
+
 static Display *dpy;
 static Atom atoms[AtomLast];
 static Client *clients = NULL;
@@ -85,6 +90,7 @@ static gboolean initdownload(WebKitWebVi
 static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
 static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c);
 static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
+static gchar *parseuri(const gchar *uri);
 static void loaduri(Client *c, const Arg *arg);
 static void navigate(Client *c, const Arg *arg);
 static Client *newclient(void);
@@ -380,6 +386,18 @@ loadstatuschange(WebKitWebView *view, GP
 	}
 }
 
+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);
+}
+
 void
 loaduri(Client *c, const Arg *arg) {
 	char *u;
@@ -388,8 +406,9 @@ loaduri(Client *c, const Arg *arg) {
 
 	if(strcmp(uri, "") == 0)
 		return;
-	u = g_strrstr(uri, "://") ? g_strdup(uri)
-		: g_strdup_printf("http://%s";, uri);
+	//u = g_strrstr(uri, "://") ? g_strdup(uri)
+	//	: g_strdup_printf("http://%s";, uri);
+	u = parseuri(uri);
 	/* prevents endless loop */
 	if(c->uri && strcmp(u, c->uri) == 0) {
 		reload(c, &a);

Reply via email to