Ticket #2120: command.c.diff

File command.c.diff, 1.8 KB (added by alexander.stohr, 13 years ago)

this should fix the issue and close the entry

  • command.c

    old new  
    302302do_cd_command (char *orig_cmd) 
    303303{ 
    304304    int len; 
     305    int operand_pos = 3; 
    305306    const char *cmd; 
    306307 
    307308    /* Any final whitespace should be removed here 
     
    319320 
    320321    cmd = orig_cmd; 
    321322    if (cmd[2] == 0) 
    322         cmd = "cd "; 
     323        cmd = "cd "; /* 0..2 => given text, 3 => \0 */ 
     324 
     325    /* allow any amount of white space in front of the path operand */ 
     326    while (cmd[operand_pos] == ' ' || cmd[operand_pos] == '\t') 
     327        operand_pos++; 
    323328 
    324329    if (get_current_type () == view_tree) 
    325330    { 
     
    327332        { 
    328333            sync_tree (mc_config_get_home_dir ()); 
    329334        } 
    330         else if (strcmp (cmd + 3, "..") == 0) 
     335        else if (strcmp (cmd + operand_pos, "..") == 0) 
    331336        { 
    332337            char *dir = current_panel->cwd; 
    333338            len = strlen (dir); 
     
    338343            else 
    339344                sync_tree (PATH_SEP_STR); 
    340345        } 
    341         else if (cmd[3] == PATH_SEP) 
     346        else if (cmd[operand_pos] == PATH_SEP) 
    342347        { 
    343             sync_tree (cmd + 3); 
     348            sync_tree (cmd + operand_pos); 
    344349        } 
    345350        else 
    346351        { 
    347352            char *old = current_panel->cwd; 
    348353            char *new; 
    349             new = concat_dir_and_file (old, cmd + 3); 
     354            new = concat_dir_and_file (old, cmd + operand_pos); 
    350355            sync_tree (new); 
    351356            g_free (new); 
    352357        } 
    353358    } 
    354     else if (!examine_cd (&cmd[3])) 
     359    else if (!examine_cd (&cmd[operand_pos])) 
    355360    { 
    356         char *d = strip_password (g_strdup (&cmd[3]), 1); 
     361        char *d = strip_password (g_strdup (&cmd[operand_pos]), 1); 
    357362        message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\"\n%s"), d, unix_error_string (errno)); 
    358363        g_free (d); 
    359364        return;