Re: Deglobalize prompt_pos



Hi,

I wrote:
> The use of prompt_pos as a global static variable in subshell.c seems a
> bit odd. I've ripped the parameter and it's references out, except of
> course in read_subshell_prompt(). This patch also has the "already
> running a command" fix integrated.

It was probably a bad idea to send two integrated patches. The "already
running a command" patch has some odd behaviour when using pipes in the
subshell (fe "| less").

Attached is the plain "deglobalize prompt_pos" patch. Please test.

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research

--- src/main.c.000	2004-10-23 13:44:01.000000000 +0200
+++ src/main.c	2004-11-18 15:08:45.000000000 +0100
@@ -521,7 +521,7 @@ subshell_chdir (const char *directory)
 #ifdef HAVE_SUBSHELL_SUPPORT
     if (use_subshell) {
 	if (vfs_current_is_local ())
-	    do_subshell_chdir (directory, 0, 1);
+	    do_subshell_chdir (directory, 0);
     }
 #endif				/* HAVE_SUBSHELL_SUPPORT */
 }
--- src/subshell.c.000	2004-11-07 13:42:53.000000000 +0100
+++ src/subshell.c	2004-11-18 15:13:58.000000000 +0100
@@ -144,11 +144,6 @@ static struct termios shell_mode;
 /* are delivered to the shell pty */
 static struct termios raw_mode;
 
-/* This counter indicates how many characters of prompt we have read */
-/* FIXME: try to figure out why this had to become global */
-static int prompt_pos;
-
-
 /*
  *  Prepare child process to running the shell and run it.
  *
@@ -524,7 +519,7 @@ int invoke_subshell (const char *command
     
     /* Make the subshell change to MC's working directory */
     if (new_dir)
-	do_subshell_chdir (current_panel->cwd, TRUE, 1);
+	do_subshell_chdir (current_panel->cwd, TRUE);
     
     if (command == NULL)  /* The user has done "C-o" from MC */
     {
@@ -556,8 +545,6 @@ int invoke_subshell (const char *command
     while (!subshell_alive && !quit && use_subshell)
 	init_subshell ();
 
-    prompt_pos = 0;
-
     return quit;
 }
 
@@ -568,6 +555,7 @@ read_subshell_prompt (void)
     static int prompt_size = INITIAL_PROMPT_SIZE;
     int bytes = 0, i, rc = 0;
     struct timeval timeleft = { 0, 0 };
+    int prompt_pos = 0;
 
     fd_set tmp;
     FD_ZERO (&tmp);
@@ -576,7 +564,6 @@ read_subshell_prompt (void)
     if (subshell_prompt == NULL) {	/* First time through */
 	subshell_prompt = g_malloc (prompt_size);
 	*subshell_prompt = '\0';
-	prompt_pos = 0;
     }
 
     while (subshell_alive
@@ -751,7 +738,7 @@ subshell_name_quote (const char *s)
 
 /* If it actually changed the directory it returns true */
 void
-do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
+do_subshell_chdir (const char *directory, int do_update)
 {
     if (!
 	(subshell_state == INACTIVE
@@ -795,8 +782,6 @@ do_subshell_chdir (const char *directory
 	g_free (cwd);
     }
 
-    if (reset_prompt)
-	prompt_pos = 0;
     update_prompt = FALSE;
     /* Make sure that MC never stores the CWD in a silly format */
     /* like /usr////lib/../bin, or the strcmp() above will fail */
--- src/subshell.h.000	2002-12-24 01:13:44.000000000 +0100
+++ src/subshell.h	2004-11-18 15:12:19.000000000 +0100
@@ -29,7 +29,7 @@ int invoke_subshell (const char *command
 int read_subshell_prompt (void);
 void resize_subshell (void);
 int exit_subshell (void);
-void do_subshell_chdir (const char *directory, int update_prompt, int reset_prompt);
+void do_subshell_chdir (const char *directory, int update_prompt);
 void subshell_get_console_attributes (void);
 void sigchld_handler (int sig);
 


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