Redundant leading spaces should be deleted before vfs_translate_url() call



Hi mc-devel,

try the following from the mc command line (not from the subshell):

1) This case works fine:

cd  /#ftp:ftp.debian.org/
(note there are two spaces between cd and the ftp vfs request)

2) This case fails:

cd  ftp://ftp.debian.org/

Error message:
Cannot chdir to " ftp://ftp.debian.org/"; is displayed.

This failure is caused by vfs_translate_url(), because it tries to check
whether the url begins with "ftp://"; and substitutes it with "/#ftp:".
The vfs_translate_url() returns simple g_strdup() of its argument since
it begins with " ftp:/" what leads to string comparison mismatch and the
chdir error. Hence the leading spaces should be deleted before
vfs_translate_url() call.

The patch is attached.

cheers,
Jindrich

-- 
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
ChangeLog:

	* main.c (_do_panel_cd): Delete leading spaces from URL
	before vfs_translate_url() call.

--- mc-4.6.1a/src/main.c.jn	2004-11-29 21:11:07.000000000 +0100
+++ mc-4.6.1a/src/main.c	2005-01-13 21:45:57.198036832 +0100
@@ -568,14 +568,17 @@
     char *translated_url;
 
     olddir = g_strdup (panel->cwd);
+    
+    if (cd_type == cd_parse_command) {
+	while (*new_dir == ' ')
+	    new_dir++;
+    }
+    
     new_dir = translated_url = vfs_translate_url (new_dir);
 
     /* Convert *new_path to a suitable pathname, handle ~user */
 
     if (cd_type == cd_parse_command) {
-	while (*new_dir == ' ')
-	    new_dir++;
-
 	if (!strcmp (new_dir, "-")) {
 	    strcpy (temp, panel->lwd);
 	    new_dir = temp;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]