Deglobalize prompt_pos
- From: Leonard den Ottolander <leonard den ottolander nl>
- To: MC Devel <mc-devel gnome org>
- Subject: Deglobalize prompt_pos
- Date: Thu, 18 Nov 2004 15:41:46 +0100
Hi,
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.
Things seem to be fine on my box (Fedora Core 1). Please test this patch
on other platforms and tell me if this simplification is correct.
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,17 +519,11 @@ 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 */
{
- if (subshell_state == INACTIVE)
- {
- subshell_state = ACTIVE;
- /* FIXME: possibly take out this hack; the user can
- re-play it by hitting C-hyphen a few times! */
- write (subshell_pty, " \b", 2); /* Hack to make prompt reappear */
- }
+ ;
}
else /* MC has passed us a user command */
{
@@ -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
@@ -14,7 +14,7 @@ extern int use_subshell;
extern int subshell_pty;
/* State of the subshell; see subshell.c for an explanation */
-enum subshell_state_enum {INACTIVE, ACTIVE, RUNNING_COMMAND};
+enum subshell_state_enum {INACTIVE, RUNNING_COMMAND};
extern enum subshell_state_enum subshell_state;
/* Holds the latest prompt captured from the subshell */
@@ -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]