changeset: 613:7d03b02ddf7d
tag: tip
user: Alex Puterbaugh <puterbaugh0_AT_gmail.com>
date: Sat Aug 21 15:28:51 2010 -0400
files: surf.suckless.org/patches/searchengines.md surf.suckless.org/patches/surf-0.4-searchengines.diff
description:
Updated the searchengines patch to not fail with the current version of surf. If you want, you can remove the author credit; I don't care :)
diff -r 245e0cb8c97a -r 7d03b02ddf7d surf.suckless.org/patches/searchengines.md
--- a/surf.suckless.org/patches/searchengines.md Sat Aug 21 13:17:47 2010 +0200
+++ b/surf.suckless.org/patches/searchengines.md Sat Aug 21 15:28:51 2010 -0400
_AT_@ -26,9 +26,11 @@
* [surf-0.1-searchengines.diff](surf-0.1-searchengines.diff) (1964) (20090923)
* [surf-0.3-searchengines.diff](surf-0.3-searchengines.diff) (2107) (20091204)
+* [surf-0.4-searchengines.diff](surf-0.4-searchengines.diff) (2107) (20091204)
Author
------
* Nils Schweinsberg (McManiaC) <[mail_AT_n-sch.de](mailto:mail_AT_n-sch.de)>
* Samuel Baldwin (shardz) <[recursive.forest_AT_gmail.com](mailto:recursive.forest_AT_gmail.com)>
+* Alex Puterbaugh (zombine) <[puterbaugh0_AT_gmail.com](mailto:puterbaugh0_AT_gmail.com)>
diff -r 245e0cb8c97a -r 7d03b02ddf7d surf.suckless.org/patches/surf-0.4-searchengines.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/patches/surf-0.4-searchengines.diff Sat Aug 21 15:28:51 2010 -0400
_AT_@ -0,0 +1,53 @@
+diff -r dbb565b8d61c surf.c
+--- a/surf.c Fri Jun 25 09:42:58 2010 +0200
++++ b/surf.c Fri Aug 13 16:28:31 2010 -0400
+_AT_@ -55,6 +55,11 @@
+ const Arg arg;
+ } Key;
+
++typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
+ static Display *dpy;
+ static Atom atoms[AtomLast];
+ static Client *clients = NULL;
+_AT_@ -90,6 +95,7 @@
+ static Client *newclient(void);
+ static void newwindow(Client *c, const Arg *arg);
+ static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v);
++static gchar *parseuri(const gchar *uri);
+ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+ static void print(Client *c, const Arg *arg);
+ static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
+_AT_@ -388,8 +394,7 @@
+
+ if(strcmp(uri, "") == 0)
+ return;
+- 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);
+_AT_@ -562,6 +567,19 @@
+ spawn(NULL, &a);
+ }
+
++
++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
+ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
+ Arg arg = {.v = text };
Received on Sat Aug 21 2010 - 21:27:19 CEST