[wiki] [sites] Minor fix to search engine patch. Added corresponding link in searchengines.md || erje

From: <hg_AT_suckless.org>
Date: Sun, 28 Oct 2012 14:25:24 +0100 (CET)

changeset: 991:cb48e8cee664
tag: tip
user: erje
date: Sun Oct 28 14:25:12 2012 +0100
files: surf.suckless.org/patches/searchengines.md surf.suckless.org/patches/surf-0.5-searchengines.diff
description:
Minor fix to search engine patch. Added corresponding link in searchengines.md


diff -r b89d486617fc -r cb48e8cee664 surf.suckless.org/patches/searchengines.md
--- a/surf.suckless.org/patches/searchengines.md Thu Oct 25 21:40:27 2012 +0200
+++ b/surf.suckless.org/patches/searchengines.md Sun Oct 28 14:25:12 2012 +0100
_AT_@ -27,6 +27,7 @@
 * [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)
+* [surf-0.5-searchengines.diff](surf-0.5-searchengines.diff) (1611) (20101028)
 
 Author
 ------
diff -r b89d486617fc -r cb48e8cee664 surf.suckless.org/patches/surf-0.5-searchengines.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/patches/surf-0.5-searchengines.diff Sun Oct 28 14:25:12 2012 +0100
_AT_@ -0,0 +1,52 @@
+--- surf.c 2012-10-26 17:58:18.912014914 +0200
++++ surf.c 2012-10-27 15:54:06.332317229 +0200
+_AT_@ -68,6 +68,11 @@
+
+ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+
++typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
+ static Display *dpy;
+ static Atom atoms[AtomLast];
+ static Client *clients = NULL;
+_AT_@ -105,6 +110,7 @@
+ 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 void populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c);
+ static void popupactivate(GtkMenuItem *menu, Client *);
+_AT_@ -475,8 +481,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_@ -679,6 +684,19 @@
+ }
+ }
+
++
++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 Sun Oct 28 2012 - 14:25:24 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 28 2012 - 14:36:06 CET