* subshell.c (subshell_name_quote): Eliminate sprintf(d, "%c", ...).
(do_subshell_chdir): Eliminate strlcpy() and optimize.
Этот коммит содержится в:
родитель
d332606fd5
Коммит
50a2118525
@ -1,3 +1,8 @@
|
|||||||
|
2005-01-14 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
|
* subshell.c (subshell_name_quote): Eliminate sprintf(d, "%c", ...).
|
||||||
|
(do_subshell_chdir): Eliminate strlcpy() and optimize.
|
||||||
|
|
||||||
2005-01-14 Pavel Shirshov <me@pavelsh.pp.ru>
|
2005-01-14 Pavel Shirshov <me@pavelsh.pp.ru>
|
||||||
|
|
||||||
* subshell.c (do_subshell_chdir): Use mc_realpath() to fix tcsh's
|
* subshell.c (do_subshell_chdir): Use mc_realpath() to fix tcsh's
|
||||||
|
@ -724,8 +724,7 @@ subshell_name_quote (const char *s)
|
|||||||
for (; *s; s++) {
|
for (; *s; s++) {
|
||||||
/* Must quote numbers, so that they are not glued to octals */
|
/* Must quote numbers, so that they are not glued to octals */
|
||||||
if (isalpha ((unsigned char) *s)) {
|
if (isalpha ((unsigned char) *s)) {
|
||||||
sprintf (d, "%c", (unsigned char) *s);
|
*d++ = (unsigned char) *s;
|
||||||
d += 1;
|
|
||||||
} else {
|
} else {
|
||||||
sprintf (d, "\\%03o", (unsigned char) *s);
|
sprintf (d, "\\%03o", (unsigned char) *s);
|
||||||
d += 4;
|
d += 4;
|
||||||
@ -734,8 +733,7 @@ subshell_name_quote (const char *s)
|
|||||||
} else {
|
} else {
|
||||||
for (; *s; s++) {
|
for (; *s; s++) {
|
||||||
if (isalnum ((unsigned char) *s)) {
|
if (isalnum ((unsigned char) *s)) {
|
||||||
sprintf (d, "%c", (unsigned char) *s);
|
*d++ = (unsigned char) *s;
|
||||||
d += 1;
|
|
||||||
} else {
|
} else {
|
||||||
sprintf (d, "\\0%03o", (unsigned char) *s);
|
sprintf (d, "\\0%03o", (unsigned char) *s);
|
||||||
d += 5;
|
d += 5;
|
||||||
@ -753,8 +751,6 @@ subshell_name_quote (const char *s)
|
|||||||
void
|
void
|
||||||
do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
|
do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
|
||||||
{
|
{
|
||||||
int bPathNotEq;
|
|
||||||
|
|
||||||
if (!
|
if (!
|
||||||
(subshell_state == INACTIVE
|
(subshell_state == INACTIVE
|
||||||
&& strcmp (subshell_cwd, current_panel->cwd))) {
|
&& strcmp (subshell_cwd, current_panel->cwd))) {
|
||||||
@ -771,8 +767,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
|
|||||||
because we set "HISTCONTROL=ignorespace") */
|
because we set "HISTCONTROL=ignorespace") */
|
||||||
write (subshell_pty, " cd ", 4);
|
write (subshell_pty, " cd ", 4);
|
||||||
if (*directory) {
|
if (*directory) {
|
||||||
char *temp;
|
char *temp = subshell_name_quote (directory);
|
||||||
temp = subshell_name_quote (directory);
|
|
||||||
if (temp) {
|
if (temp) {
|
||||||
write (subshell_pty, temp, strlen (temp));
|
write (subshell_pty, temp, strlen (temp));
|
||||||
g_free (temp);
|
g_free (temp);
|
||||||
@ -789,24 +784,30 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
|
|||||||
subshell_state = RUNNING_COMMAND;
|
subshell_state = RUNNING_COMMAND;
|
||||||
feed_subshell (QUIETLY, FALSE);
|
feed_subshell (QUIETLY, FALSE);
|
||||||
|
|
||||||
if (subshell_type == TCSH) {
|
if (subshell_alive) {
|
||||||
char rp_subshell_cwd[PATH_MAX];
|
int bPathNotEq = strcmp (subshell_cwd, current_panel->cwd);
|
||||||
char rp_current_panel_cwd[PATH_MAX];
|
|
||||||
|
|
||||||
if (mc_realpath(subshell_cwd, rp_subshell_cwd) == NULL)
|
if (bPathNotEq && subshell_type == TCSH) {
|
||||||
strlcpy(rp_subshell_cwd, subshell_cwd, PATH_MAX);
|
char rp_subshell_cwd[PATH_MAX];
|
||||||
|
char rp_current_panel_cwd[PATH_MAX];
|
||||||
|
|
||||||
if (mc_realpath(current_panel->cwd, rp_current_panel_cwd) == NULL)
|
char *p_subshell_cwd =
|
||||||
strlcpy(rp_current_panel_cwd, current_panel->cwd, PATH_MAX);
|
mc_realpath (subshell_cwd, rp_subshell_cwd);
|
||||||
|
char *p_current_panel_cwd =
|
||||||
|
mc_realpath (current_panel->cwd, rp_current_panel_cwd);
|
||||||
|
|
||||||
bPathNotEq = strcmp (rp_subshell_cwd, rp_current_panel_cwd);
|
if (p_subshell_cwd == NULL)
|
||||||
} else bPathNotEq = strcmp (subshell_cwd, current_panel->cwd);
|
p_subshell_cwd = subshell_cwd;
|
||||||
|
if (p_current_panel_cwd == NULL)
|
||||||
|
p_current_panel_cwd = current_panel->cwd;
|
||||||
|
bPathNotEq = strcmp (p_subshell_cwd, p_current_panel_cwd);
|
||||||
|
}
|
||||||
|
|
||||||
if (subshell_alive && bPathNotEq && strcmp (current_panel->cwd, ".")) {
|
if (bPathNotEq && strcmp (current_panel->cwd, ".")) {
|
||||||
char *cwd = strip_password (g_strdup (current_panel->cwd), 1);
|
char *cwd = strip_password (g_strdup (current_panel->cwd), 1);
|
||||||
fprintf (stderr, _("Warning: Cannot change to %s.\n"),
|
fprintf (stderr, _("Warning: Cannot change to %s.\n"), cwd);
|
||||||
cwd);
|
g_free (cwd);
|
||||||
g_free (cwd);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reset_prompt)
|
if (reset_prompt)
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user