Mc command completion and empty entries in PATH



Hi!

As far as I know bash and csh use current_dir (".") if PATH is empty
or there are an empty entries. But mc now treats this one(s) as end 
condition of PATH processing in command_completion_function.

This patch changes this mc's behavior.

BTW, I want to know if pattern completion is a common behavior in
case statement for shells or this is true for Korn and Bourne shells
only ? If it's common some entries in mc's menu could be rewritten
without egrep.

With best wishes,
Andrew.

--- ChangeLog.orig	Mon Jun 25 16:43:55 2001
+++ ChangeLog	Mon Jun 25 17:49:38 2001
@@ -9,6 +9,10 @@
 	bash_builtins const, use concat_dir_and_file.
 	(fetch_hosts): Fix typo, style fixes.
 
+	* (command_completion_function): Don't end PATH processing if
+	there is an empty entry and use this as current directory.
+	Bash and csh work so.
+
 2001-06-23  Pavel Roskin  <proski gnu org>
 
 	* mem.h: Undefine bcopy(), bcmp() and bzero() before redefining
--- complete.c.orig	Mon Jun 25 17:42:53 2001
+++ complete.c	Mon Jun 25 17:44:20 2001
@@ -442,6 +442,7 @@
 static char *
 command_completion_function (char *text, int state)
 {
+    static char *path_end;
     static int isabsolute;
     static int phase;
     static int text_len;
@@ -471,17 +472,12 @@
 	    words = bash_reserved;
 	    phase = 0;
 	    text_len = strlen (text);
-	    p = getenv ("PATH");
-	    if (!p)
-	    	path = NULL;
-	    else {
-	    	path = g_malloc (strlen (p) + 2);
-	    	strcpy (path, p);
-	    	path [strlen (p) + 1] = 0;
-	    	p = strchr (path, PATH_ENV_SEP);
-	    	while (p){
-	    	    *p = 0;
-	    	    p = strchr (p + 1, PATH_ENV_SEP);
+	    path = getenv ("PATH");
+	    if (path){
+		p = path = g_strdup (path);
+		path_end = strchr (p, 0);
+		while ((p = strchr (p, PATH_ENV_SEP))){
+		    *p++ = 0;
 	    	}
 	    }
 	}
@@ -520,9 +516,9 @@
 	        if (!cur_word){
 		    char *expanded;
 		    
-	            if (!*cur_path)
+		    if (cur_path >= path_end)
 	            	break;
-		    expanded = tilde_expand (cur_path);
+		    expanded = tilde_expand (*cur_path ? cur_path : ".");
 		    if (!expanded){
 			g_free (path);
 			path = NULL;




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