[hackers] [surf] Support relative paths for surf. || Christoph Lohmann

From: <git_AT_suckless.org>
Date: Thu, 14 Mar 2013 19:17:46 +0100

commit a69c41ccac3141784140852c9d3935049d188d0f
Author: Christoph Lohmann <20h_AT_r-36.net>
Date: Thu Mar 14 19:14:44 2013 +0100

    Support relative paths for surf.
    
    Thanks Kurt Van Dijck <kurt.van.dijck_AT_eia.be>!

diff --git a/surf.c b/surf.c
index 830665a..1ad5ace 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -577,12 +577,13 @@ loaduri(Client *c, const Arg *arg) {
         char *u, *rp;
         const char *uri = (char *)arg->v;
         Arg a = { .b = FALSE };
+ struct stat st;
 
         if(strcmp(uri, "") == 0)
                 return;
 
         /* In case it's a file path. */
- if(uri[0] == '/') {
+ if(stat(uri, &st) == 0) {
                 rp = realpath(uri, NULL);
                 u = g_strdup_printf("file://%s", rp);
                 free(rp);
_AT_@ -889,11 +890,12 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
                         if(ev->atom == atoms[AtomFind]) {
                                 arg.b = TRUE;
                                 find(c, &arg);
+
                                 return GDK_FILTER_REMOVE;
- }
- else if(ev->atom == atoms[AtomGo]) {
+ } else if(ev->atom == atoms[AtomGo]) {
                                 arg.v = getatom(c, AtomGo);
                                 loaduri(c, &arg);
+
                                 return GDK_FILTER_REMOVE;
                         }
                 }
Received on Thu Mar 14 2013 - 19:17:46 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 14 2013 - 19:24:09 CET