Ticket #1992: incorrect sturtup of MC with some special paths.
Problem description: 1. Run mc as mc /#ftp:user@server 2. If FTP server asks password, MC shows the password dialog window. 3. If type the first symbol in input line, MC crashes. Bug cause: MC asks ftp password before initialize of input line keybindings. Solution: Reimplemented MC startup sequence. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
08cabe95f5
Коммит
45073c35e7
100
src/main.c
100
src/main.c
@ -937,9 +937,7 @@ create_panels (void)
|
|||||||
int current_index;
|
int current_index;
|
||||||
int other_index;
|
int other_index;
|
||||||
panel_view_mode_t current_mode, other_mode;
|
panel_view_mode_t current_mode, other_mode;
|
||||||
char original_dir[1024];
|
char original_dir[BUF_1K] = "\0";
|
||||||
|
|
||||||
original_dir[0] = 0;
|
|
||||||
|
|
||||||
if (boot_current_is_left) {
|
if (boot_current_is_left) {
|
||||||
current_index = 0;
|
current_index = 0;
|
||||||
@ -967,7 +965,7 @@ create_panels (void)
|
|||||||
|
|
||||||
/* The other panel */
|
/* The other panel */
|
||||||
if (other_dir) {
|
if (other_dir) {
|
||||||
if (original_dir[0])
|
if (original_dir[0] != '\0')
|
||||||
translated_mc_chdir (original_dir);
|
translated_mc_chdir (original_dir);
|
||||||
translated_mc_chdir (other_dir);
|
translated_mc_chdir (other_dir);
|
||||||
}
|
}
|
||||||
@ -1388,18 +1386,6 @@ midnight_execute_cmd (Widget *sender, unsigned long command)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
setup_pre (void)
|
|
||||||
{
|
|
||||||
/* Call all the inits */
|
|
||||||
|
|
||||||
#ifdef HAVE_SLANG
|
|
||||||
tty_display_8bit (full_eight_bits != 0);
|
|
||||||
#else
|
|
||||||
tty_display_8bit (eight_bit_clean != 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_xterm_support (void)
|
init_xterm_support (void)
|
||||||
{
|
{
|
||||||
@ -1448,9 +1434,11 @@ init_xterm_support (void)
|
|||||||
static void
|
static void
|
||||||
setup_mc (void)
|
setup_mc (void)
|
||||||
{
|
{
|
||||||
setup_pre ();
|
#ifdef HAVE_SLANG
|
||||||
create_panels ();
|
tty_display_8bit (full_eight_bits != 0);
|
||||||
setup_panels ();
|
#else
|
||||||
|
tty_display_8bit (eight_bit_clean != 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
if (use_subshell)
|
if (use_subshell)
|
||||||
@ -1552,6 +1540,9 @@ midnight_callback (Dlg_head *h, Widget *sender,
|
|||||||
unsigned long command;
|
unsigned long command;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
|
case DLG_INIT:
|
||||||
|
setup_panels ();
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
case DLG_DRAW:
|
case DLG_DRAW:
|
||||||
load_hint (1);
|
load_hint (1);
|
||||||
@ -1570,6 +1561,12 @@ midnight_callback (Dlg_head *h, Widget *sender,
|
|||||||
case DLG_IDLE:
|
case DLG_IDLE:
|
||||||
/* We only need the first idle event to show user menu after start */
|
/* We only need the first idle event to show user menu after start */
|
||||||
set_idle_proc (h, 0);
|
set_idle_proc (h, 0);
|
||||||
|
|
||||||
|
if (boot_current_is_left)
|
||||||
|
dlg_select_widget (get_panel_widget (0));
|
||||||
|
else
|
||||||
|
dlg_select_widget (get_panel_widget (1));
|
||||||
|
|
||||||
if (auto_menu)
|
if (auto_menu)
|
||||||
midnight_execute_cmd (NULL, CK_UserMenuCmd);
|
midnight_execute_cmd (NULL, CK_UserMenuCmd);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
@ -1777,15 +1774,18 @@ load_hint (int force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_panels_and_run_mc (void)
|
create_panels_and_run_mc (void)
|
||||||
{
|
{
|
||||||
midnight_dlg->get_shortcut = midnight_get_shortcut;
|
midnight_dlg->get_shortcut = midnight_get_shortcut;
|
||||||
|
|
||||||
|
create_panels ();
|
||||||
|
|
||||||
add_widget (midnight_dlg, the_menubar);
|
add_widget (midnight_dlg, the_menubar);
|
||||||
init_menu ();
|
init_menu ();
|
||||||
|
|
||||||
add_widget (midnight_dlg, get_panel_widget (0));
|
add_widget (midnight_dlg, get_panel_widget (0));
|
||||||
add_widget (midnight_dlg, get_panel_widget (1));
|
add_widget (midnight_dlg, get_panel_widget (1));
|
||||||
|
|
||||||
add_widget (midnight_dlg, the_hint);
|
add_widget (midnight_dlg, the_hint);
|
||||||
add_widget (midnight_dlg, cmdline);
|
add_widget (midnight_dlg, cmdline);
|
||||||
add_widget (midnight_dlg, the_prompt);
|
add_widget (midnight_dlg, the_prompt);
|
||||||
@ -1793,11 +1793,6 @@ setup_panels_and_run_mc (void)
|
|||||||
add_widget (midnight_dlg, the_bar);
|
add_widget (midnight_dlg, the_bar);
|
||||||
midnight_set_buttonbar (the_bar);
|
midnight_set_buttonbar (the_bar);
|
||||||
|
|
||||||
if (boot_current_is_left)
|
|
||||||
dlg_select_widget (get_panel_widget (0));
|
|
||||||
else
|
|
||||||
dlg_select_widget (get_panel_widget (1));
|
|
||||||
|
|
||||||
/* Run the Midnight Commander if no file was specified in the command line */
|
/* Run the Midnight Commander if no file was specified in the command line */
|
||||||
run_dlg (midnight_dlg);
|
run_dlg (midnight_dlg);
|
||||||
}
|
}
|
||||||
@ -1807,45 +1802,39 @@ static char *
|
|||||||
prepend_cwd_on_local (const char *filename)
|
prepend_cwd_on_local (const char *filename)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
int l;
|
size_t l;
|
||||||
|
|
||||||
if (vfs_file_is_local (filename)) {
|
if (!vfs_file_is_local (filename)
|
||||||
if (*filename == PATH_SEP) /* an absolute pathname */
|
|| g_path_is_absolute (filename))
|
||||||
return g_strdup (filename);
|
|
||||||
d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2);
|
|
||||||
mc_get_current_wd (d, MC_MAXPATHLEN);
|
|
||||||
l = strlen (d);
|
|
||||||
d[l++] = PATH_SEP;
|
|
||||||
strcpy (d + l, filename);
|
|
||||||
canonicalize_pathname (d);
|
|
||||||
return d;
|
|
||||||
} else
|
|
||||||
return g_strdup (filename);
|
return g_strdup (filename);
|
||||||
|
|
||||||
|
d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2);
|
||||||
|
mc_get_current_wd (d, MC_MAXPATHLEN);
|
||||||
|
l = strlen (d);
|
||||||
|
d[l++] = PATH_SEP;
|
||||||
|
strcpy (d + l, filename);
|
||||||
|
canonicalize_pathname (d);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/* Invoke the internal view/edit routine with:
|
||||||
|
* the default processing and forcing the internal viewer/editor
|
||||||
|
*/
|
||||||
|
static void
|
||||||
mc_maybe_editor_or_viewer (void)
|
mc_maybe_editor_or_viewer (void)
|
||||||
{
|
{
|
||||||
if (!(view_one_file || edit_one_file))
|
if (view_one_file != NULL) {
|
||||||
return 0;
|
char *path;
|
||||||
|
|
||||||
/* Invoke the internal view/edit routine with:
|
|
||||||
* the default processing and forcing the internal viewer/editor
|
|
||||||
*/
|
|
||||||
if (view_one_file) {
|
|
||||||
char *path = NULL;
|
|
||||||
path = prepend_cwd_on_local (view_one_file);
|
path = prepend_cwd_on_local (view_one_file);
|
||||||
view_file (path, 0, 1);
|
view_file (path, 0, 1);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
else {
|
else
|
||||||
edit_file (edit_one_file, edit_one_file_start_line);
|
edit_file (edit_one_file, edit_one_file_start_line);
|
||||||
}
|
|
||||||
#endif /* USE_INTERNAL_EDIT */
|
#endif /* USE_INTERNAL_EDIT */
|
||||||
midnight_shutdown = 1;
|
midnight_shutdown = 1;
|
||||||
done_mc ();
|
done_mc ();
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run the main dialog that occupies the whole screen */
|
/* Run the main dialog that occupies the whole screen */
|
||||||
@ -1863,7 +1852,7 @@ do_nc (void)
|
|||||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
||||||
"[main]", NULL, DLG_WANT_IDLE);
|
"[main]", NULL, DLG_WANT_IDLE);
|
||||||
|
|
||||||
if (view_one_file || edit_one_file)
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
setup_dummy_mc ();
|
setup_dummy_mc ();
|
||||||
else
|
else
|
||||||
setup_mc ();
|
setup_mc ();
|
||||||
@ -1896,8 +1885,10 @@ do_nc (void)
|
|||||||
help_map = (global_keymap_t *) help_keymap->data;
|
help_map = (global_keymap_t *) help_keymap->data;
|
||||||
|
|
||||||
/* Check if we were invoked as an editor or file viewer */
|
/* Check if we were invoked as an editor or file viewer */
|
||||||
if (!mc_maybe_editor_or_viewer ()) {
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
setup_panels_and_run_mc ();
|
mc_maybe_editor_or_viewer ();
|
||||||
|
else {
|
||||||
|
create_panels_and_run_mc ();
|
||||||
|
|
||||||
/* Program end */
|
/* Program end */
|
||||||
midnight_shutdown = 1;
|
midnight_shutdown = 1;
|
||||||
@ -2149,7 +2140,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
/* Don't use subshell when invoked as viewer or editor */
|
/* Don't use subshell when invoked as viewer or editor */
|
||||||
if (edit_one_file || view_one_file)
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
use_subshell = 0;
|
use_subshell = 0;
|
||||||
|
|
||||||
if (use_subshell)
|
if (use_subshell)
|
||||||
@ -2216,12 +2207,11 @@ main (int argc, char *argv[])
|
|||||||
if (use_subshell) {
|
if (use_subshell) {
|
||||||
mc_prompt = strip_ctrl_codes (subshell_prompt);
|
mc_prompt = strip_ctrl_codes (subshell_prompt);
|
||||||
if (mc_prompt == NULL)
|
if (mc_prompt == NULL)
|
||||||
mc_prompt = "";
|
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||||
} else
|
} else
|
||||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||||
|
|
||||||
|
|
||||||
/* Program main loop */
|
/* Program main loop */
|
||||||
if (!midnight_shutdown)
|
if (!midnight_shutdown)
|
||||||
do_nc ();
|
do_nc ();
|
||||||
|
@ -29,6 +29,8 @@ struct WButtonBar;
|
|||||||
void midnight_set_buttonbar (struct WButtonBar *b);
|
void midnight_set_buttonbar (struct WButtonBar *b);
|
||||||
|
|
||||||
/* See main.c for details on these variables */
|
/* See main.c for details on these variables */
|
||||||
|
extern const char *edit_one_file;
|
||||||
|
extern const char *view_one_file;
|
||||||
extern int mark_moves_down;
|
extern int mark_moves_down;
|
||||||
extern int auto_menu;
|
extern int auto_menu;
|
||||||
extern int pause_after_run;
|
extern int pause_after_run;
|
||||||
|
@ -344,6 +344,9 @@ save_panel_types (void)
|
|||||||
{
|
{
|
||||||
panel_view_mode_t type;
|
panel_view_mode_t type;
|
||||||
|
|
||||||
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
|
if (!mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
|
||||||
"auto_save_setup_panels", auto_save_setup))
|
"auto_save_setup_panels", auto_save_setup))
|
||||||
return;
|
return;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user