diff -ur ../old/FD-3.00j/browse.c ./browse.c --- ../old/FD-3.00j/browse.c Sat Sep 25 00:00:00 2010 +++ ./browse.c Sat Apr 7 21:13:06 2012 @@ -81,8 +81,9 @@ #endif static int NEAR readfilelist __P_((CONST reg_t *, CONST char *)); static VOID NEAR getfilelist __P_((VOID_A)); -static int NEAR browsedir __P_((char *, CONST char *)); -static char *NEAR initcwd __P_((CONST char *, char *, int)); +static int NEAR getfuncno __P_((int)); +static int NEAR browsedir __P_((VOID_A)); +static VOID NEAR initcwd __P_((CONST char *, int)); int curcolumns = 0; int defcolumns = 0; @@ -1295,6 +1296,7 @@ # endif /* !_NOARCHIVE */ Xfree(winvar[win].v_fullpath); winvar[win].v_fullpath = NULL; + setlastfile(NULL); if (filelist) { for (i = 0; i < maxfile; i++) Xfree(filelist[i].name); Xfree(filelist); @@ -1615,17 +1617,109 @@ if (sorton) qsort(filelist, maxfile, sizeof(namelist), cmplist); } -static int NEAR browsedir(file, def) -char *file; -CONST char *def; +VOID setlastfile(cp) +CONST char *cp; { + Xfree(lastfile); + lastfile = Xstrdup(cp); +} + +static int NEAR getfuncno(ch) +int ch; +{ + int n; + +#if FD >= 3 + if (ch == K_TIMEOUT) return(REREAD_DIR); +#endif + + for (n = 0; n < maxbind; n++) + if (ch == (int)(bindlist[n].key)) break; + if (n >= maxbind) return(NO_OPERATION); + +#ifndef _NOPRECEDE + if (haste && !havestat(&(filelist[filepos])) + && (hasdfunc(n) || (funclist[ffunc(n)].status & FN_NEEDSTATUS)) + && getstatus(&(filelist[filepos])) < 0) + return(WARNING_BELL); +#endif + + if (hasdfunc(n) && isdir(&(filelist[filepos]))) return(dfunc(n)); + + return(ffunc(n)); +} + +int dointernal(no, arg, mode, statp) +int no; +CONST char *arg; +int mode, *statp; +{ + int n, stat; + + stat = (FN_KILLSTACK | FN_RESCREEN | FN_REWIN); + if (no < FUNCLISTSIZ) stat = funclist[no].status; + if (statp) *statp = stat; + + if (maxfile <= 0 && !(stat & FN_NOFILE)) return(FNC_NONE); #ifndef _NOARCHIVE - CONST char *tmp; + if (!archivefile) /*EMPTY*/; + else if (no >= FUNCLISTSIZ || !(stat & FN_ARCHIVE)) return(FNC_NONE); +#endif + if (fd_restricted && (stat & FN_RESTRICT)) { + warning(0, RESTR_K); + return(FNC_NONE); + } + + if (!(stat & FN_KILLSTACK)) /*EMPTY*/; + else if (stackdepth > 0) { + chgorder = 0; + if (!yesno(KILOK_K)) return(FNC_NONE); + for (n = maxfile - 1; n > filepos; n--) + memcpy((char *)&(filelist[n + stackdepth]), + (char *)&(filelist[n]), sizeof(namelist)); + for (n = 0; n < stackdepth; n++) + memcpy((char *)&(filelist[n + filepos + 1]), + (char *)&(filestack[n]), sizeof(namelist)); + maxfile += stackdepth; + stackdepth = 0; + filepos = listupfile(filelist, maxfile, + filelist[filepos].name, 1); + stackbar(); + } +#ifndef _NOWRITEFS +# ifndef _NOARCHIVE + else if (archivefile) /*EMPTY*/; +# endif + else if (!chgorder || writefs >= 1 || no == WRITE_DIR) /*EMPTY*/; + else if (fd_restricted) /*EMPTY*/; + else if ((n = writablefs(curpath)) > 0 && underhome(NULL) > 0) { + chgorder = 0; + if (yesno(WRTOK_K)) arrangedir(n); + } +#endif /* !_NOWRITEFS */ + + if (no < FUNCLISTSIZ) { + if (mode == ICM_BINDKEY) arg = NULL; + no = (*funclist[no].func)(arg); + if (mode != ICM_CMDLINE) /*EMPTY*/; + else if (no < FNC_NONE || no >= FNC_EFFECT) + internal_status = no; + } + else { + no = evalstatus(ptyusercomm(getmacro(no), arg, 0)); +#ifdef DEP_PTY + if (ptymode && isearch) no = FNC_NONE; #endif + } + + return(no); +} + +static int NEAR browsedir(VOID_A) +{ #ifndef _NOPRECEDE int dupsorton; #endif - CONST char *cp; char buf[MAXNAMLEN + 1]; int ch, i, no, old, funcstat; @@ -1645,11 +1739,6 @@ win_x = win_y = 0; waitmes(); -#ifndef _NOARCHIVE - if (!archivefile) /*EMPTY*/; - else if (*file) def = file; - else def = nullstr; -#endif getfilelist(); for (i = 0; i < maxfile; i++) { @@ -1663,9 +1752,9 @@ helpbar(); rewritefile(-1); #ifdef _NOSPLITWIN - old = filepos = listupfile(filelist, maxfile, def, 1); + old = filepos = listupfile(filelist, maxfile, lastfile, 1); #else - old = filepos = listupwin(def); + old = filepos = listupwin(lastfile); #endif funcstat = 0; no = FNC_CANCEL; @@ -1704,83 +1793,11 @@ continue; } } - for (i = 0; i < maxbind; i++) - if (ch == (int)(bindlist[i].key)) break; -#if FD >= 3 - if (ch == K_TIMEOUT) return(REREAD_DIR); - else -#endif - if (i >= maxbind) no = NO_OPERATION; -#ifndef _NOPRECEDE - else if (haste && !havestat(&(filelist[filepos])) - && (hasdfunc(i) || (funclist[ffunc(i)].status & FN_NEEDSTATUS)) - && getstatus(&(filelist[filepos])) < 0) - no = WARNING_BELL; -#endif - else no = (hasdfunc(i) && isdir(&(filelist[filepos]))) - ? dfunc(i) : ffunc(i); - if (no < FUNCLISTSIZ) funcstat = funclist[no].status; -#ifndef _NOARCHIVE - else if (archivefile) continue; -#endif - else funcstat = (FN_KILLSTACK | FN_RESCREEN | FN_REWIN); - - if (funcstat & FN_KILLSTACK) { - if (stackdepth > 0) { - chgorder = 0; - if (!yesno(KILOK_K)) continue; - for (i = maxfile - 1; i > filepos; i--) - memcpy((char *)&(filelist[i - + stackdepth]), - (char *)&(filelist[i]), - sizeof(namelist)); - for (i = 0; i < stackdepth; i++) - memcpy((char *)&(filelist[i - + filepos + 1]), - (char *)&(filestack[i]), - sizeof(namelist)); - maxfile += stackdepth; - stackdepth = 0; - filepos = listupfile(filelist, maxfile, - filelist[filepos].name, 1); - stackbar(); - } -#ifndef _NOWRITEFS -# ifndef _NOARCHIVE - else if (archivefile) /*EMPTY*/; -# endif - else if (chgorder && writefs < 1 && no != WRITE_DIR - && !fd_restricted - && (i = writablefs(curpath)) > 0 - && underhome(NULL) > 0) { - chgorder = 0; - if (yesno(WRTOK_K)) arrangedir(i); - } -#endif /* !_NOWRITEFS */ - } curfilename = filelist[filepos].name; - if (maxfile <= 0 && !(funcstat & FN_NOFILE)) no = FNC_NONE; -#ifndef _NOARCHIVE - else if (archivefile && !(funcstat & FN_ARCHIVE)) - no = FNC_NONE; -#endif - else if (no < FUNCLISTSIZ) { - if (!fd_restricted || !(funcstat & FN_RESTRICT)) - no = (*funclist[no].func)(NULL); - else { - warning(0, RESTR_K); - no = FNC_NONE; - } - } - else { - no = ptyusercomm(getmacro(no), - filelist[filepos].name, 0); - no = evalstatus(no); -#ifdef DEP_PTY - if (ptymode && isearch) no = FNC_NONE; -#endif - } + setlastfile(NULL); + no = dointernal(getfuncno(ch), + filelist[filepos].name, ICM_BINDKEY, &funcstat); #ifdef DEP_PTY while (ptylist[win].pid && ptylist[win].status < 0) { @@ -1810,10 +1827,15 @@ } } + if (no >= FNC_EFFECT) { + if (lastfile) /*EMPTY*/; + else if (!maxfile) setlastfile(curpath); + else setlastfile(filelist[filepos].name); + } #ifndef _NOARCHIVE - if (archivefile) { + else if (archivefile) { if (no < 0) { - Xstrcpy(file, archivefile); + setlastfile(archivefile); # ifdef _NOBROWSE escapearch(); # else @@ -1822,44 +1844,18 @@ } while (browselist); # endif } - else if (no == FNC_CHDIR) { - tmp = (filepos >= 0) ? filelist[filepos].name : NULL; - if (!(cp = archchdir(tmp))) { - if (!tmp) tmp = parentpath; - warning(-1, tmp); - Xstrcpy(file, tmp); - } - else if (cp != (char *)-1) Xstrcpy(file, cp); - else { - Xstrcpy(file, archivefile); - escapearch(); - } - } - else if (no == FNC_EFFECT) { - if (filepos < 0) *file = '\0'; - else Xstrcpy(file, filelist[filepos].name); - } no = FNC_NONE; } - else -#endif /* !_NOARCHIVE */ - if (no >= FNC_EFFECT) { - no -= FNC_EFFECT; - if (!maxfile && !ischgdir(&(filelist[filepos]))) cp = curpath; - else cp = filelist[filepos].name; - Xstrcpy(file, cp); - } +#endif /* _NOARCHIVE */ #ifndef _NOARCHIVE - if (archivefile) i = 0; - else + if (archivefile) maxfile = 0; #endif - i = (maxfile || !ischgdir(&(filelist[0]))) ? maxfile : 1; - while (i-- > 0) { - Xfree(filelist[i].name); - filelist[i].name = NULL; + while (maxfile > 0) { + Xfree(filelist[--maxfile].name); + filelist[maxfile].name = NULL; } - maxfile = filepos = 0; + filepos = 0; #ifndef _NOPRECEDE if (haste && !sorton) sorton = dupsorton; #endif @@ -1867,15 +1863,16 @@ return(no); } -static char *NEAR initcwd(path, buf, internal) +static VOID NEAR initcwd(path, internal) CONST char *path; -char *buf; int internal; { - char *cp, *file; +#if MSDOS int i; +#endif + char *cp, *file, buf[MAXPATHLEN]; - if (!path) return(NULL); + if (!path) return; cp = Xstrdup(path); #ifdef DEP_FILECONV @@ -1895,48 +1892,45 @@ } #endif /* !MSDOS */ - if (chdir2(cp) >= 0) file = NULL; - else { - file = strrdelim(cp, 0); + if (chdir2(cp) >= 0) { + Xfree(cp); + return; + } + + file = strrdelim(cp, 0); #ifdef DEP_DOSEMU - if (!file && dospath2(cp)) file = &(cp[2]); + if (!file && dospath2(cp)) file = &(cp[2]); #endif - if (!file) file = cp; - else { - i = *file; - *file = '\0'; - if (file == cp) { - if (chdir2(rootpath) < 0) error(rootpath); - } - else if (chdir2(cp) < 0) { - hideclock = 2; - warning(-1, cp); + if (!file) { + setlastfile(cp); + Xfree(cp); + return; + } + + if (file == cp) copyrootpath(buf); + else VOID_C Xstrncpy(buf, cp, file - cp); + if (*file == _SC_) file++; + + if (chdir2(buf) < 0) { + hideclock = 2; + warning(-1, buf); #if MSDOS - Xstrcpy(fullpath, origpath); + Xstrcpy(fullpath, origpath); #endif - Xfree(cp); - return(NULL); - } - if (i == _SC_) file++; - else *file = i; - } - Xstrcpy(buf, file); - file = buf; + Xfree(cp); + return; } - Xfree(cp); - return(file); + setlastfile(file); + Xfree(cp); } VOID main_fd(pathlist, internal) char *CONST *pathlist; int internal; { -#ifdef DEP_DOSEMU - char buf[MAXPATHLEN]; -#endif - char *def, *cwd, file[MAXNAMLEN + 1], prev[MAXNAMLEN + 1]; + char *cwd; int n, argc, ischgdir; if (!pathlist) argc = 0; @@ -1944,7 +1938,6 @@ if (!pathlist[argc]) break; cwd = getwd2(); - def = NULL; for (n = MAXWINDOWS - 1; n >= 0; n--) { #ifndef _NOSPLITWIN win = n; @@ -1979,6 +1972,7 @@ #ifndef _NOTREE treepath = NULL; #endif + lastfile = NULL; findpattern = NULL; filelist = NULL; maxfile = maxent = filepos = 0; @@ -1990,14 +1984,14 @@ if (n >= argc) continue; chdir2(cwd); - def = initcwd(pathlist[n], prev, internal); + initcwd(pathlist[n], internal); #ifndef _NOSPLITWIN winvar[n].v_fullpath = Xstrdup(fullpath); if (n) { getfilelist(); sorton = sorttype % 100; - filepos = calcfilepos(filelist, maxfile, def); + filepos = calcfilepos(filelist, maxfile, lastfile); } #endif } @@ -2017,41 +2011,20 @@ #endif /* !_NOSPLITWIN */ calcwin(); - copycurpath(file); _chdir2(fullpath); for (;;) { - if (!def && isdotdir(file) == 1) { - Xstrcpy(prev, getbasename(fullpath)); - if (*prev) def = prev; - else copycurpath(file); - } - - if (isdotdir(file) != 2 - && chdir3(nodospath(buf, file), 1) < 0) { - hideclock = 2; - warning(-1, file); - Xstrcpy(prev, file); - def = prev; - } - #ifdef _NOARCHIVE - ischgdir = browsedir(file, def); + ischgdir = browsedir(); #else do { - ischgdir = browsedir(file, def); + ischgdir = browsedir(); } while (archivefile); #endif if (ischgdir < 0) { if (ischgdir > -2) chdir2(cwd); break; - } - if (ischgdir) def = NULL; - else { - Xstrcpy(prev, file); - copycurpath(file); - def = prev; } } diff -ur ../old/FD-3.00j/builtin.c ./builtin.c --- ../old/FD-3.00j/builtin.c Sat Sep 25 00:00:00 2010 +++ ./builtin.c Sat Apr 7 18:43:37 2012 @@ -3293,10 +3293,7 @@ builtinerror(argv, NULL, ER_NOTDUMBTERM); return(-1); } - if (fd_restricted && (funclist[n].status & FN_RESTRICT)) { - VOID_C Xfprintf(Xstderr, "%s: %K\n", argv[0], RESTR_K); - return(RET_NOTICE); - } + if (argc > 2 || !filelist || maxfile <= 0) { VOID_C Xfprintf(Xstderr, "%s: %K\n", argv[0], ILFNC_K); return(RET_NOTICE); @@ -3308,9 +3305,10 @@ } #endif ttyiomode(0); - internal_status = (*funclist[n].func)(argv[1]); + n = dointernal(n, argv[1], ICM_CMDLINE, NULL); locate(0, n_line - 1); stdiomode(); + if (n == FNC_FAIL) return(RET_FAIL); return(RET_SUCCESS); } diff -ur ../old/FD-3.00j/command.c ./command.c --- ../old/FD-3.00j/command.c Sat Sep 25 00:00:00 2010 +++ ./command.c Sat Apr 7 21:15:43 2012 @@ -53,7 +53,7 @@ extern int fdmode; #endif -static VOID NEAR replacefname __P_((char *)); +static int NEAR dochdir4 __P_((CONST char *, int)); static int cur_up __P_((CONST char *)); static int cur_down __P_((CONST char *)); static int cur_right __P_((CONST char *)); @@ -328,15 +328,16 @@ }; -static VOID NEAR replacefname(name) -char *name; +static int NEAR dochdir4(path, raw) +CONST char *path; +int raw; { - if (filepos < maxfile) Xfree(filelist[filepos].name); - else for (maxfile = 0; maxfile < filepos; maxfile++) - if (!filelist[maxfile].name) - filelist[maxfile].name = Xstrdup(nullstr); - filelist[filepos].name = (name) ? name : Xstrdup(parentpath); - filelist[filepos].tmpflags |= F_ISCHGDIR; + if (chdir4(path, raw) < 0) { + warning(-1, path); + return(FNC_CANCEL); + } + + return(FNC_EFFECT); } static int cur_up(arg) @@ -757,28 +758,18 @@ static int in_dir(arg) CONST char *arg; { -#ifndef _NOARCHIVE - if (archivefile) /*EMPTY*/; - else -#endif if (!isdir(&(filelist[filepos])) || isdotdir(filelist[filepos].name) == 2) return(warning_bell(arg)); - return(FNC_CHDIR); + return(dochdir4(filelist[filepos].name, 1)); } /*ARGSUSED*/ static int out_dir(arg) CONST char *arg; { -#ifndef _NOARCHIVE - if (archivefile) filepos = -1; - else -#endif - replacefname(NULL); - - return(FNC_CHDIR); + return(dochdir4(parentpath, 1)); } /*ARGSUSED*/ @@ -857,11 +848,8 @@ static int log_dir(arg) CONST char *arg; { -#ifndef _NOARCHIVE - CONST char *cp; - char dupfullpath[MAXPATHLEN]; -#endif char *path; + int no; if (arg && *arg) path = Xstrdup(arg); else if (!(path = inputstr(LOGD_K, 0, -1, NULL, HST_PATH))) @@ -870,57 +858,18 @@ Xfree(path); return(FNC_CANCEL); } -#ifndef _NOARCHIVE - if (archivefile && *path != '/') { - if (!(cp = archchdir(path))) { - warning(-1, path); - Xfree(path); - return(FNC_CANCEL); - } - Xfree(path); - if (cp != (char *)-1) filelist[filepos].name = (char *)cp; - else escapearch(); - return(FNC_EFFECT); - } - else -#endif - if (chdir3(path, 0) < 0) { - warning(-1, path); - Xfree(path); - return(FNC_CANCEL); - } + + no = dochdir4(path, 0); Xfree(path); -#ifndef _NOARCHIVE - if (archivefile) { - Xstrcpy(dupfullpath, fullpath); - while (archivefile) { -# ifdef _NOBROWSE - escapearch(); -# else - do { - escapearch(); - } while (browselist); -# endif - } - Xstrcpy(fullpath, dupfullpath); - } -#endif - replacefname(NULL); - return(FNC_EFFECT); + return(no); } /*ARGSUSED*/ static int log_top(arg) CONST char *arg; { - char *path; - - path = Xstrdup(rootpath); - if (chdir3(path, 1) < 0) error(path); - replacefname(path); - - return(FNC_EFFECT); + return(dochdir4(rootpath, 1)); } static VOID NEAR clearscreen(VOID_A) @@ -1431,7 +1380,7 @@ Xfree(file); file = Xstrdup(parentpath); } - replacefname(file); + setlastfile(file); return(FNC_EFFECT); } @@ -1540,10 +1489,13 @@ if (!(tmp = strrdelim(destpath, 0))) tmp = destpath; else { *(tmp++) = '\0'; - chdir3(destpath, 1); + if (dochdir4(destpath, 1) == FNC_CANCEL) { + Xfree(destpath); + return(FNC_HELPSPOT); + } } - replacefname(Xstrdup(tmp)); + setlastfile(tmp); Xfree(destpath); return(FNC_EFFECT); @@ -1862,19 +1814,14 @@ CONST char *arg; { char *path; + int no; if (!(path = tree(0, NULL))) return(FNC_UPDATE); - if (chdir3(path, 1) < 0) { - warning(-1, path); - Xfree(path); - return(FNC_UPDATE); - } + no = dochdir4(path, 1); + if (no == FNC_CANCEL) no = FNC_UPDATE; Xfree(path); - Xfree(findpattern); - findpattern = NULL; - replacefname(NULL); - return(FNC_EFFECT); + return(no); } #endif /* !_NOTREE */ @@ -1981,6 +1928,7 @@ memcpy((char *)filelist, (char *)(winvar[oldwin].v_filelist), i); for (i = 0; i < winvar[oldwin].v_maxfile; i++) filelist[i].name = Xstrdup(winvar[oldwin].v_filelist[i].name); + lastfile = Xstrdup(winvar[oldwin].v_lastfile); filepos = winvar[oldwin].v_filepos; sorton = winvar[oldwin].v_sorton; dispmode = winvar[oldwin].v_dispmode; diff -ur ../old/FD-3.00j/frontend.c ./frontend.c --- ../old/FD-3.00j/frontend.c Sat Sep 25 00:00:00 2010 +++ ./frontend.c Sat Apr 7 18:16:34 2012 @@ -976,7 +976,7 @@ changewin(MAXWINDOWS, (p_id_t)-1); if (!(wastty = isttyiomode)) Xttyiomode(0); ptyinternal++; - internal_status = (*funclist[n].func)(cp); + VOID_C dointernal(n, cp, ICM_CMDLINE, NULL); ptyinternal--; if (!wastty) Xstdiomode(); changewin(win, (p_id_t)-1); diff -ur ../old/FD-3.00j/func.h ./func.h --- ../old/FD-3.00j/func.h Sat Sep 25 00:00:00 2010 +++ ./func.h Sat Apr 7 18:20:39 2012 @@ -76,6 +76,7 @@ extern int _chdir2 __P_((CONST char *)); extern int chdir2 __P_((CONST char *)); extern int chdir3 __P_((CONST char *, int)); +extern int chdir4 __P_((CONST char *, int)); extern int mkdir2 __P_((char *, int)); extern int strncpy2 __P_((char *, CONST char *, int *, int)); extern VOID perror2 __P_((CONST char *)); @@ -498,4 +499,6 @@ extern VOID calcwin __P_((VOID_A)); extern VOID movepos __P_((int, int)); extern VOID rewritefile __P_((int)); +extern VOID setlastfile __P_((CONST char *)); +extern int dointernal __P_((int, CONST char *, int, int *)); extern VOID main_fd __P_((char *CONST *, int)); diff -ur ../old/FD-3.00j/libc.c ./libc.c --- ../old/FD-3.00j/libc.c Sat Sep 25 00:00:00 2010 +++ ./libc.c Sat Apr 7 19:07:22 2012 @@ -250,6 +250,59 @@ return(0); } +int chdir4(path, raw) +CONST char *path; +int raw; +{ + char *eol, dupfullpath[MAXPATHLEN]; + CONST char *cp; + +#ifndef _NOARCHIVE + if (!archivefile) /*EMPTY*/; + else if (*path != _SC_) { + if (isdotdir(path) == 1) path = NULL; + if (!(cp = archchdir(path))) return(-1); + + if (cp != (char *)-1) setlastfile(cp); + else { + setlastfile(archivefile); + escapearch(); + } + + return(0); + } +#endif /* !_NOARCHIVE */ + + Xstrcpy(dupfullpath, fullpath); + if (chdir3(path, raw) < 0) return(-1); + + if (!(cp = underpath(dupfullpath, fullpath, -1))) + setlastfile(parentpath); + else if (!*(cp++)) return(0); + else { + if ((eol = strdelim(cp, 0))) *eol = '\0'; + setlastfile(cp); + } + +#ifndef _NOARCHIVE + if (archivefile) { + Xstrcpy(dupfullpath, fullpath); + while (archivefile) { +# ifdef _NOBROWSE + escapearch(); +# else + do { + escapearch(); + } while (browselist); +# endif + } + Xstrcpy(fullpath, dupfullpath); + } +#endif /* !_NOARCHIVE */ + + return(0); +} + int mkdir2(path, mode) char *path; int mode; diff -ur ../old/FD-3.00j/pathname.c ./pathname.c --- ../old/FD-3.00j/pathname.c Sat Sep 25 00:00:00 2010 +++ ./pathname.c Sat Apr 7 18:54:21 2012 @@ -453,7 +453,7 @@ if (len < 0) len = strlen(dir); if ((cp = strrdelim2(dir, &(dir[len]))) && !cp[1]) len = cp - dir; - if (len <= 0 || strnpathcmp(path, dir, len)) return(NULL); + if (len > 0 && strnpathcmp(path, dir, len)) return(NULL); if (path[len] && path[len] != _SC_) return(NULL); return((char *)&(path[len])); diff -ur ../old/FD-3.00j/system.c ./system.c --- ../old/FD-3.00j/system.c Sat Sep 25 00:00:00 2010 +++ ./system.c Sat Apr 7 18:38:36 2012 @@ -364,6 +364,7 @@ extern int rmtmpfile __P_((CONST char *)); extern int chdir2 __P_((CONST char *)); extern int chdir3 __P_((CONST char *, int)); +extern int chdir4 __P_((CONST char *, int)); extern int setenv2 __P_((CONST char *, CONST char *, int)); extern char *getenv2 __P_((CONST char *)); # ifdef USESIGACTION @@ -383,6 +384,7 @@ static int NEAR rmtmpfile __P_((CONST char *)); # define chdir2 Xchdir int chdir3 __P_((CONST char *, int)); +# define chdir4 chdir3 int setenv2 __P_((CONST char *, CONST char *, int)); # ifdef USESIGACTION static sigcst_t NEAR signal2 __P_((int, sigcst_t)); @@ -8219,7 +8221,7 @@ } if (!next) { - if (chdir3(dir, 0) >= 0) { + if (chdir4(dir, 0) >= 0) { #ifdef FD physical_path = dupphysical_path; #endif @@ -8252,7 +8254,7 @@ dlen = strcatdelim(path) - path; } Xstrncpy(&(path[dlen]), dir, len); - if (chdir3(path, 1) >= 0) { + if (chdir4(path, 1) >= 0) { kanjifputs(path, Xstdout); VOID_C fputnl(Xstdout); Xfree(path); @@ -9118,7 +9120,7 @@ return(RET_FAIL); } cp = evalpath(Xstrdup(dirstack[0]), 0); - i = chdir3(cp, 1); + i = chdir4(cp, 1); Xfree(cp); if (i < 0) { execerror((trp -> comm) -> argv, @@ -9131,7 +9133,7 @@ # endif } else { - if (chdir3((trp -> comm) -> argv[1], 0) < 0) { + if (chdir4((trp -> comm) -> argv[1], 0) < 0) { execerror((trp -> comm) -> argv, (trp -> comm) -> argv[1], ER_BADDIR, 0); return(RET_FAIL); @@ -9163,7 +9165,7 @@ return(RET_FAIL); } cp = evalpath(Xstrdup(dirstack[0]), 0); - i = chdir3(cp, 1); + i = chdir4(cp, 1); Xfree(cp); if (i < 0) { execerror((trp -> comm) -> argv, dirstack[0], ER_BADDIR, 0); diff -ur ../old/FD-3.00j/types.h ./types.h --- ../old/FD-3.00j/types.h Sat Sep 25 00:00:00 2010 +++ ./types.h Sat Apr 7 21:17:53 2012 @@ -117,6 +117,7 @@ char *v_treepath; #endif char *v_fullpath; + char *v_lastfile; char *v_findpattern; namelist *v_filelist; int v_maxfile; @@ -156,6 +157,7 @@ #ifndef _NOTREE #define treepath (winvar[win].v_treepath) #endif +#define lastfile (winvar[win].v_lastfile) #define findpattern (winvar[win].v_findpattern) #define filelist (winvar[win].v_filelist) #define maxfile (winvar[win].v_maxfile) @@ -251,6 +253,9 @@ #define FNC_CHDIR 5 #define FNC_QUIT (-1) #define FNC_FAIL (-2) + +#define ICM_BINDKEY 0 +#define ICM_CMDLINE 1 #define FSID_UFS 1 #define FSID_EFS 2