about summary refs log tree commit diff stats
path: root/xxxterm.c
diff options
context:
space:
mode:
authorElias Norberg <xyzzy@kudzu.se>2012-01-02 00:20:19 +0100
committerElias Norberg <xyzzy@kudzu.se>2012-01-03 01:02:37 +0100
commitc03de0ef36825c10662e5f391277af6477b6031d (patch)
treecda223b0512fade3538450f46396568281977172 /xxxterm.c
parent13ce5cc838bbc4a699280ab49acd99232fd56823 (diff)
downloadxombrero-c03de0ef36825c10662e5f391277af6477b6031d.tar.gz
Fix for FS#208 - open a file from the command line without full path
ok marco@
Diffstat (limited to 'xxxterm.c')
-rw-r--r--xxxterm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 3ea9c63..ba1773e 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -748,6 +748,8 @@ guess_url_type(char *url_in)
 	struct stat		sb;
 	char			*url_out = NULL, *enc_search = NULL;
 	int			i;
+	char			*cwd;
+
 
 	/* substitute aliases */
 	url_out = match_alias(url_in);
@@ -776,9 +778,17 @@ guess_url_type(char *url_in)
 	}
 
 	/* XXX not sure about this heuristic */
-	if (stat(url_in, &sb) == 0)
-		url_out = g_strdup_printf("file://%s", url_in);
-	else
+	if (stat(url_in, &sb) == 0) {
+		if (url_in[0] == '/')
+			url_out = g_strdup_printf("file://%s", url_in);
+		else {
+			cwd = malloc(PATH_MAX);
+			if (getcwd(cwd, PATH_MAX) != NULL) {
+				url_out = g_strdup_printf("file://%s/%s",cwd, url_in);
+			}
+			free(cwd);
+		}
+	}else
 		url_out = g_strdup_printf("http://%s", url_in); /* guess http */
 done:
 	DNPRINTF(XT_D_URL, "guess_url_type: guessed %s\n", url_out);