Use vfs_translate_path() to avoid extra string duplication.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-09-17 12:59:51 +04:00
parent 034e973fbf
commit 20ab79ba00

View File

@ -924,8 +924,6 @@ init_subshell (void)
int
invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
{
char *pcwd;
/* Make the MC terminal transparent */
tcsetattr (STDOUT_FILENO, TCSANOW, &raw_mode);
@ -957,11 +955,14 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
feed_subshell (how, FALSE);
pcwd = vfs_translate_path_n (vfs_path_as_str (current_panel->cwd_vpath));
if (new_dir_vpath != NULL && subshell_alive)
{
const char *pcwd;
if (new_dir_vpath != NULL && subshell_alive && strcmp (subshell_cwd, pcwd))
pcwd = vfs_translate_path (vfs_path_as_str (current_panel->cwd_vpath));
if (strcmp (subshell_cwd, pcwd) != 0)
*new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */
g_free (pcwd);
}
/* Restart the subshell if it has died by SIGHUP, SIGQUIT, etc. */
while (!subshell_alive && quit == 0 && mc_global.tty.use_subshell)
@ -1175,9 +1176,9 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
if (vpath != NULL)
{
char *translate;
const char *translate;
translate = vfs_translate_path_n (vfs_path_as_str (vpath));
translate = vfs_translate_path (vfs_path_as_str (vpath));
if (translate != NULL)
{
GString *temp;
@ -1185,8 +1186,6 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
temp = subshell_name_quote (translate);
write_all (mc_global.tty.subshell_pty, temp->str, temp->len);
g_string_free (temp, TRUE);
g_free (translate);
}
else
{