mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Use vfs_translate_path() to avoid extra string duplication.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
034e973fbf
commit
20ab79ba00
@ -924,8 +924,6 @@ init_subshell (void)
|
|||||||
int
|
int
|
||||||
invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
|
invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
|
||||||
{
|
{
|
||||||
char *pcwd;
|
|
||||||
|
|
||||||
/* Make the MC terminal transparent */
|
/* Make the MC terminal transparent */
|
||||||
tcsetattr (STDOUT_FILENO, TCSANOW, &raw_mode);
|
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);
|
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));
|
||||||
*new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */
|
if (strcmp (subshell_cwd, pcwd) != 0)
|
||||||
g_free (pcwd);
|
*new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */
|
||||||
|
}
|
||||||
|
|
||||||
/* Restart the subshell if it has died by SIGHUP, SIGQUIT, etc. */
|
/* Restart the subshell if it has died by SIGHUP, SIGQUIT, etc. */
|
||||||
while (!subshell_alive && quit == 0 && mc_global.tty.use_subshell)
|
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)
|
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)
|
if (translate != NULL)
|
||||||
{
|
{
|
||||||
GString *temp;
|
GString *temp;
|
||||||
@ -1185,8 +1186,6 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
|
|||||||
temp = subshell_name_quote (translate);
|
temp = subshell_name_quote (translate);
|
||||||
write_all (mc_global.tty.subshell_pty, temp->str, temp->len);
|
write_all (mc_global.tty.subshell_pty, temp->str, temp->len);
|
||||||
g_string_free (temp, TRUE);
|
g_string_free (temp, TRUE);
|
||||||
|
|
||||||
g_free (translate);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user