Hi!

Hannes Schüller <[email protected]> wrote:
> The second one, I don't really consider a problem, to be honest. You
> could easily just write
> 
> vimprobable ./index.htm

This does not work for me. Because this leads to the URL 'file://./index.html'
which could not be found.

> Does anyone else have an opinion?

In my opinion the stat call isn't required. I think the '/' or './' should
be enough. But out of the none working vimprobable2 ./index.html we should use
the realpath on the file before creating the URL.

By the way we can reduce the code by replacing:

new = g_malloc(sizeof("file://") + len);
strcpy(new, "file://");
memcpy(&new[sizeof("file://") - 1], s, len + 1);

by:
uri = g_strdup_printf("file://%s", s);

I've made a little patch that applies to the master that demonstrates what I
want to have. But this didn't check if the realpath returned a value or not,
but as an example this should be enough.

Daniel
From 4474a63ec3a6053bd56d7118c9f89308ecb9cdab Mon Sep 17 00:00:00 2001
From: Daniel Carl <[email protected]>
Date: Sun, 24 Feb 2013 16:38:42 +0100
Subject: [PATCH] Get the realpath before opening local files.

---
 main.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c
index f6531f7..5523198 100644
--- a/main.c
+++ b/main.c
@@ -1262,9 +1262,8 @@ open_arg(const Arg *arg) {
                 }
                 *p = '\0';
             } else if (strcspn(s, "/") == 0 || strcspn(s, "./") == 0) {  /* prepend "file://" */
-                new = g_malloc(sizeof("file://") + len);
-                strcpy(new, "file://");
-                memcpy(&new[sizeof("file://") - 1], s, len + 1);
+                char* rp = realpath(s, NULL);
+                new = g_strdup_printf("file://%s", rp);
             } else if (p || !strchr(s, '.')) {                      /* whitespaces or no dot? */
                 search_uri = find_uri_for_searchengine(defaultsearch);
                 if (search_uri != NULL) {
@@ -1273,9 +1272,7 @@ open_arg(const Arg *arg) {
                     g_free(search_term);
                 }
             } else {                                                    /* prepend "http://"; */
-                new = g_malloc(sizeof("http://";) + len);
-                strcpy(new, "http://";);
-                memcpy(&new[sizeof("http://";) - 1], s, len + 1);
+                new = g_strdup_printf("http://%s";, s);
             }
         }
         webkit_web_view_load_uri(webview, new);
-- 
1.7.9.5

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Vimprobable-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vimprobable-users

Reply via email to