FDclone 2.08b patch [1/4]
しらいです。
file & directory 管理ツール FDclone 2.08b の patch その 1
です。
Submitted-by: shirai@chandra2
Archive-name: FD-2.08b.patch/part01
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is FD-2.08b.patch, a shell archive (produced by GNU sharutils 4.2)
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2006-03-30 00:00 JST by <shirai@chandra2>.
# Source directory was `/usr/home/shirai/src/fd2'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This is part 1 of a multipart archive.
# Do not concatenate these parts, unpack them in order with `/bin/sh'.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 185215 -rw-r--r-- FD-2.08b.patch
#
echo=echo
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh03503; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
if test -r _sh03503/seq; then
$echo 'Must unpack archives in sequence!'
$echo 'Please unpack part' '`cat _sh03503/seq`' 'next!'
exit 1
fi
# ============= FD-2.08b.patch ==============
if test -f 'FD-2.08b.patch' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'FD-2.08b.patch' '(file already exists)'
rm -f _sh03503/new
else
> _sh03503/new
$echo 'x -' extracting 'FD-2.08b.patch' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'FD-2.08b.patch' &&
diff -urNP ../FD-2.08a/HISTORY ./HISTORY
--- ../FD-2.08a/HISTORY Tue Feb 7 00:00:00 2006
+++ ./HISTORY Thu Mar 30 00:00:00 2006
@@ -1,3 +1,16 @@
+Ver. 2.08b Cygwin 1.5.19 対応。
+ (03/30/06) PTYMODE=1 時のコマンドラインからの内部コマンド実行に対応。
+ 一部の環境で入力キーを取りこぼすことがある点を修正。
+ "!文字列" 形式のヒストリが非検出時に異常終了する点を修正。
+ メタ文字を含むファイル名補完がおかしかった点を修正。
+ PTYMODE=1 時にマクロでマークファイルが無視される点を修正。
+ PTYMODE=1 時に ANSICOLOR=2 指定が効かなくなる点を修正。
+ PTYMODE=1 時にカレントディレクトリ変更が伝わらない点を修正。
+ mlterm で終了後の端末状態がおかしくなる点を修正。
+ 表示すべきファイルがない時に OUT_DIR が効かない点を修正。
+ bgnotify フラグが EXECUTE_SH を抜けると効かなくなる点を修正。
+ バックグラウンドジョブがおかしな出力をすることがある点を修正。
+
X Ver. 2.08a NetBSD 3.0 対応。
X (02/07/06) PTYINKCODE の設定がうまく機能していなかった点を修正。
X varargs を用いる環境で compile に失敗していた点を修正。
diff -urNP ../FD-2.08a/HISTORY.eng ./HISTORY.eng
--- ../FD-2.08a/HISTORY.eng Tue Feb 7 00:00:00 2006
+++ ./HISTORY.eng Thu Mar 30 00:00:00 2006
@@ -1,3 +1,16 @@
+Ver. 2.08b Support Cygwin 1.5.19.
+ (03/30/06) Support internal commands with the command line on PTYMODE=1.
+ Bug that inputted key is dropped in some environments is fixed.
+ Abortion when "!string"-type history is not found is fixed.
+ Unsuitable filename completion with meta character is fixed.
+ Bug that macros ignore any mark files on PTYMODE=1 is fixed.
+ Bug that ANSICOLOR=2 is ineffective on PTYMODE=1 is fixed.
+ Bug that current directory is not passed on PTYMODE=1 is fixed.
+ Bug that terminal status of mlterm will be broken is fixed.
+ Bug that OUT_DIR is ineffective with no file is fixed.
+ Bug that 'bgnotify' is ineffective out of EXECUTE_SH is fixed.
+ Bug that some background jobs output strange string is fixed.
+
X Ver. 2.08a Support NetBSD 3.0.
X (02/07/06) Failure to work according to 'PTYINKCODE' setting is fixed.
X Failure to compile on some environments using varargs is fixed.
diff -urNP ../FD-2.08a/Makefile.in ./Makefile.in
--- ../FD-2.08a/Makefile.in Tue Feb 7 00:00:00 2006
+++ ./Makefile.in Thu Mar 30 00:00:00 2006
@@ -136,7 +136,7 @@
X main__OBJ__: main.c
X $(CC) $(FDCFLAGS) $(DEFCFLAGS) __UNITBLPATH__ -c __OUT__ $*.c
X
-term__OBJ__: term.c
+termio__OBJ__: termio.c
X $(CC) $(FDCFLAGS) __FDSETSIZE__ -c __OUT__ $*.c
X
X system__OBJ__: system.c
@@ -436,6 +436,10 @@
X -e '/# launcher definition/,/^$$/ {' \
X -e '/^$$/ {' \
X -e 'i \' \
+ -e 'launch ".tar.Z" "gzip -cd %C|tar tvf -" "%a %u/%g %s %y-%m-%d %t %*f"' \
+ -e 'i \' \
+ -e 'launch ".taZ" "gzip -cd %C|tar tvf -" "%a %u/%g %s %y-%m-%d %t %*f"' \
+ -e 'i \' \
X -e 'launch ".ipk" "gzip -cd %C|tar xOf - ./data.tar.gz|gzip -cd|tar tvf -" \\' \
X -e 'i \' \
X -e ' "%a %u/%g %s %y-%m-%d %t %*f"' \
@@ -448,6 +452,10 @@
X -e '/# archiver definition/,/^$$/ {' \
X -e '/^$$/ {' \
X -e 'i \' \
+ -e 'arch ".tar.Z" "echo ERROR; false" "gzip -cd %C|tar xf - %TA"' \
+ -e 'i \' \
+ -e 'arch ".taZ" "echo ERROR; false" "gzip -cd %C|tar xf - %TA"' \
+ -e 'i \' \
X -e 'arch ".ipk" "echo ERROR; false" \\' \
X -e 'i \' \
X -e ' "gzip -cd %C|tar xOf - ./data.tar.gz|gzip -cd|tar xf - %TA"' \
@@ -591,7 +599,7 @@
X frontend__OBJ__: types.h
X frontend__OBJ__: printf.h
X frontend__OBJ__: kctype.h
-frontend__OBJ__: pathname.h term.h func.h
+frontend__OBJ__: pathname.h term.h funcno.h func.h
X frontend__OBJ__: dosdisk.h kanji.h termemu.h system.h
X frontend__OBJ__: termio.h
X frontend__OBJ__: wait.h
diff -urNP ../FD-2.08a/README ./README
--- ../FD-2.08a/README Tue Feb 7 00:00:00 2006
+++ ./README Thu Mar 30 00:00:00 2006
@@ -3,7 +3,7 @@
X # FDclone Ver. 2.08 に関して
X #
X # Takashi SHIRAI, <shirai@unixusers.net>
-# Feb 7, 2006
+# Mar 30, 2006
X #
X ############################################################
X
diff -urNP ../FD-2.08a/README.eng ./README.eng
--- ../FD-2.08a/README.eng Tue Feb 7 00:00:00 2006
+++ ./README.eng Thu Mar 30 00:00:00 2006
@@ -3,7 +3,7 @@
X # About FDclone Ver. 2.08
X #
X # Takashi SHIRAI, <shirai@unixusers.net>
-# Feb 7, 2006
+# Mar 30, 2006
X #
X ############################################################
X
diff -urNP ../FD-2.08a/apply.c ./apply.c
--- ../FD-2.08a/apply.c Tue Feb 7 00:00:00 2006
+++ ./apply.c Thu Mar 30 00:00:00 2006
@@ -438,8 +438,8 @@
X }
X if (s_islnk(&st)) return(0);
X
- if (!(tmp = strrdelim(path, 0))) strcpy(dir, ".");
- else if (tmp == path) strcpy(dir, _SS_);
+ if (!(tmp = strrdelim(path, 0))) copycurpath(dir);
+ else if (tmp == path) copyrootpath(dir);
X else strncpy2(dir, path, tmp - path);
X
X if (nodoslstat(dir, &st) < 0) {
@@ -1480,7 +1480,7 @@
X
X verbose = 1;
X if (!dir) {
- dir = ".";
+ dir = curpath;
X verbose = 0;
X }
X else if (isdotdir(dir) == 1) {
@@ -1519,7 +1519,7 @@
X destdir = NULL;
X copypolicy = (issamedir(destpath, NULL)) ? (FLAG_SAMEDIR | 2) : 0;
X #ifndef _NODOSDRIVE
- if (dospath3("")) waitmes();
+ if (dospath3(nullstr)) waitmes();
X #endif
X if (mark > 0
X || (!isdir(&(filelist[filepos])) || islink(&(filelist[filepos]))))
diff -urNP ../FD-2.08a/archive.c ./archive.c
--- ../FD-2.08a/archive.c Tue Feb 7 00:00:00 2006
+++ ./archive.c Thu Mar 30 00:00:00 2006
@@ -1145,7 +1145,7 @@
X if (browselist) {
X int i;
X
- if (!browsevar) arch = strdup2("");
+ if (!browsevar) arch = strdup2(nullstr);
X else {
X len = 0;
X for (i = 0; browsevar[i]; i++)
@@ -1187,7 +1187,7 @@
X len = TD_ARCH;
X }
X Xputterm(END_STANDOUT);
- Xcprintf2("%-*.*k", len, len, arch);
+ cputstr(len, arch);
X free(arch);
X
X Xlocate(TC_MARK, TL_PATH);
@@ -1219,7 +1219,7 @@
X len = D_ARCH;
X }
X Xputterm(END_STANDOUT);
- Xcprintf2("%-*.*k", len, len, arch);
+ cputstr(len, arch);
X free(arch);
X
X Xtflush();
@@ -1645,7 +1645,7 @@
X
X maxfile = 0;
X addlist();
- filelist[0].name = strdup2("..");
+ filelist[0].name = strdup2(parentpath);
X #ifndef NOSYMLINK
X filelist[0].linkname = NULL;
X #endif
@@ -1800,7 +1800,7 @@
X
X if (parent < 0) return;
X for (i = 0; i < maxfile; i++)
- if (!strcmp(filelist[i].name, "..")) return;
+ if (isdotdir(filelist[i].name) == 1) return;
X memmove((char *)&(filelist[1]), (char *)&(filelist[0]),
X maxfile++ * sizeof(namelist));
X memcpy((char *)&(filelist[0]),
@@ -1867,7 +1867,7 @@
X cp = strrdelim2(file, cp);
X if (!cp) *archivedir = '\0';
X else {
- if (cp == file) strcpy(archivedir, _SS_);
+ if (cp == file) copyrootpath(archivedir);
X else strncpy2(archivedir, file, cp - file);
X file = ++cp;
X }
@@ -1887,7 +1887,7 @@
X if (browselist) {
X int i, n, flags, dupfilepos;
X
- if (!path || !*path) path = "..";
+ if (!path || !*path) path = parentpath;
X if ((cp = strdelim(path, 0))) {
X for (i = 1; cp[i]; i++) if (cp[i] != _SC_) break;
X if (cp[i]) {
@@ -1930,7 +1930,7 @@
X return(path);
X }
X browselevel = n;
- return("..");
+ return(parentpath);
X }
X #endif /* !_NOBROWSE */
X
@@ -1942,11 +1942,11 @@
X else len = strlen(path);
X
X cp = path;
- if (len == 2 && path[0] == '.' && path[1] == '.') cp = "";
+ if (len == 2 && path[0] == '.' && path[1] == '.') cp = nullstr;
X if (searcharcdir(cp, len)) {
X if (*(cp = archivedir)) cp = strcatdelim(archivedir);
X strncpy2(cp, path, len);
- file = "..";
+ file = parentpath;
X }
X else if (*cp || !(file = archoutdir())) {
X strcpy(archivedir, duparcdir);
@@ -2052,7 +2052,7 @@
X }
X }
X #ifndef _NODOSDRIVE
- else if ((drive = tmpdosdupl("", &tmpdir, 1)) < 0) {
+ else if ((drive = tmpdosdupl(nullstr, &tmpdir, 1)) < 0) {
X Xputterm(T_BELL);
X return(-1);
X }
@@ -2086,7 +2086,7 @@
X }
X archivefile = (filelist && filepos < maxfile)
X ? filelist[filepos].name : NULL;
- if (!archivefile) archivefile = "";
+ if (!archivefile) archivefile = nullstr;
X archivefile = strdup2(archivefile);
X *archivedir = '\0';
X archtmpdir = tmpdir;
@@ -2305,7 +2305,7 @@
X
X strcpy(path, arc);
X if ((dest = strrdelim(path, 1))) *(++dest) = '\0';
- else strcpy(path, ".");
+ else copycurpath(path);
X if ((n = archdostmpdir(path, &tmpdest, full)) < 0) {
X warning(ENOENT, arc);
X return(0);
@@ -2322,7 +2322,7 @@
X }
X }
X #ifndef _NODOSDRIVE
- else if ((drive = tmpdosdupl("", &tmpdir, 0)) < 0) {
+ else if ((drive = tmpdosdupl(nullstr, &tmpdir, 0)) < 0) {
X free(dest);
X return(0);
X }
@@ -2421,11 +2421,11 @@
X dir = evalpath(dir, 0);
X }
X if (!dir) return(0);
- if (!*dir) strcpy(path, ".");
+ if (!*dir) copycurpath(path);
X else {
X cp = strcpy2(path, dir);
X #ifdef _USEDOSPATH
- if (_dospath(dir) && !dir[2]) strcpy(cp, ".");
+ if (_dospath(dir) && !dir[2]) copycurpath(cp);
X #endif
X }
X free(dir);
diff -urNP ../FD-2.08a/backend.c ./backend.c
--- ../FD-2.08a/backend.c Tue Feb 7 00:00:00 2006
+++ ./backend.c Thu Mar 30 00:00:00 2006
@@ -214,6 +214,7 @@
X
X if (last_attr != pty[w].attr) {
X putterm(T_NORMAL);
+ last_fg = last_bg = (short)-1;
X if (pty[w].attr & A_BOLD) putterm(T_BOLD);
X if (pty[w].attr & A_REVERSE) putterm(T_REVERSE);
X if (pty[w].attr & A_DIM) putterm(T_DIM);
@@ -228,6 +229,7 @@
X tputs2(cp, 1);
X free(cp);
X }
+ else cprintf2("\033[%dm", pty[w].fg + ANSI_NORMAL);
X last_fg = pty[w].fg;
X }
X if (last_bg != pty[w].bg && pty[w].bg >= (short)0) {
@@ -235,6 +237,7 @@
X tputs2(cp, 1);
X free(cp);
X }
+ else cprintf2("\033[%dm", pty[w].bg + ANSI_REVERSE);
X last_bg = pty[w].bg;
X }
X }
@@ -1130,7 +1133,7 @@
X int fd, n;
X {
X ptyinfo_t tmp;
- char *s, *arg;
+ char *s, *arg, *cwd;
X p_id_t pid;
X short w1, w2, row[MAXWINDOWS];
X int i;
@@ -1209,7 +1212,6 @@
X }
X else {
X pty[MAXWINDOWS].fg = w1;
- pty[MAXWINDOWS].bg = (short)-1;
X }
X break;
X case TE_MOVECURSOR:
@@ -1322,13 +1324,16 @@
X if (s) free(s);
X break;
X }
+ if (recvstring(fd, &cwd) < 0) cwd = NULL;
X resetptyterm(w1, 1);
X
X sendbuf(ptylist[w1].fd, &n, sizeof(n));
X sendstring(ptylist[w1].fd, s);
X sendstring(ptylist[w1].fd, arg);
+ sendstring(ptylist[w1].fd, cwd);
X if (s) free(s);
X if (arg) free(arg);
+ if (cwd) free(cwd);
X break;
X default:
X break;
@@ -1433,7 +1438,7 @@
X int backend(VOID_A)
X {
X char result[MAXWINDOWS + 1];
- int i, n, fds[MAXWINDOWS];
+ int i, n, fds[MAXWINDOWS + 1];
X
X hideclock = -1;
X dumbterm = 1;
@@ -1452,11 +1457,12 @@
X evalsignal();
X #endif
X
- for (i = 0; i < MAXWINDOWS; i++) fds[i] = ptylist[i].fd;
- if (selectpty(emufd, fds, result, -1) <= 0) continue;
+ for (i = 0; i < MAXWINDOWS; i++)
+ fds[i] = (ptylist[i].pid) ? ptylist[i].fd : -1;
+ fds[i] = emufd;
+ if (selectpty(MAXWINDOWS + 1, fds, result, -1) <= 0) continue;
X
X if (result[MAXWINDOWS] && (n = evalinput(emufd)) > 0) continue;
-
X for (i = 0; i < MAXWINDOWS; i++)
X if (result[i] && ptylist[i].pid) evaloutput(i);
X }
diff -urNP ../FD-2.08a/browse.c ./browse.c
--- ../FD-2.08a/browse.c Tue Feb 7 00:00:00 2006
+++ ./browse.c Thu Mar 30 00:00:00 2006
@@ -74,6 +74,10 @@
X extern int internal_status;
X extern int hideclock;
X extern int fd_restricted;
+#ifndef _NOPTY
+extern int ptymode;
+extern int parentfd;
+#endif
X
X #ifndef _NOCOLOR
X static int NEAR getcolorid __P_((namelist *));
@@ -246,7 +250,7 @@
X Xputterm(T_STANDOUT);
X Xcputs2(TS_PATH);
X Xputterm(END_STANDOUT);
- Xcprintf2("%-*.*k", TD_PATH, TD_PATH, fullpath);
+ cputstr(TD_PATH, fullpath);
X
X Xlocate(TC_MARK, TL_PATH);
X Xcprintf2("%<*d", TD_MARK, mark);
@@ -267,7 +271,7 @@
X Xputterm(T_STANDOUT);
X Xcputs2(S_PATH);
X Xputterm(END_STANDOUT);
- Xcprintf2("%-*.*k", D_PATH, D_PATH, fullpath);
+ cputstr(D_PATH, fullpath);
X
X Xtflush();
X }
@@ -315,7 +319,7 @@
X if (len < 0) len = 0;
X Xputterm(T_STANDOUT);
X for (j = 0; j < len; j++) Xputch2(' ');
- Xcprintf2("%-*.*k", width - len, width - len, helpindex[i]);
+ cputstr(width - len, helpindex[i]);
X Xputterm(END_STANDOUT);
X }
X
@@ -393,7 +397,7 @@
X Xputterm(T_STANDOUT);
X Xcputs2(S_FIND);
X Xputterm(END_STANDOUT);
- if (findpattern) Xcprintf2("%-*.*k", D_FIND, D_FIND, findpattern);
+ if (findpattern) cputstr(D_FIND, findpattern);
X
X Xtflush();
X }
@@ -427,7 +431,7 @@
X else
X #endif
X Xputterm(T_STANDOUT);
- Xcprintf2("%-*.*k", width - 2, width - 2, filestack[i].name);
+ cputstr(width - 2, filestack[i].name);
X #ifndef _NOCOLOR
X x += width - 2;
X if (bgcolor >= 0) Xchgcolor(bgcolor, 1);
@@ -466,7 +470,8 @@
X off_t total, fre, bsize;
X
X if (!hassizeinfo() || !*fullpath) return;
- if (getinfofs(".", &total, &fre, &bsize) < 0) total = fre = (off_t)-1;
+ if (getinfofs(curpath, &total, &fre, &bsize) < 0)
+ total = fre = (off_t)-1;
X
X #ifndef _NOTRADLAYOUT
X if (istradlayout()) {
@@ -643,7 +648,7 @@
X snprintf2(buf, width + 1, "%*.*s", width, width, "<VOL>");
X #else /* !MSDOS */
X # ifndef _NODOSDRIVE
- else if (dospath2("") && s_isfifo(namep))
+ else if (dospath2(nullstr) && s_isfifo(namep))
X snprintf2(buf, width + 1, "%*.*s", width, width, "<VOL>");
X # endif
X else if (isdev(namep))
@@ -714,11 +719,14 @@
X int len;
X
X if (!filelist || filepos < 0 || maxfile < 0) return;
+#ifndef _NOPTY
+ if (parentfd >= 0) return;
+#endif
X
X #ifndef _NOTRADLAYOUT
X if (istradlayout()) {
X Xlocate(TC_INFO + TW_INFO, TL_STATUS);
- Xcprintf2("%*s", TD_INFO, "");
+ cputspace(TD_INFO);
X
X Xlocate(TC_INFO + TW_INFO, TL_STATUS);
X if (filepos >= maxfile) {
@@ -1067,7 +1075,7 @@
X if (def) for (i = 0; i < max; i++)
X if (!strpathcmp(def, list[i].name)) return(i);
X
- if (list == filelist && max > 1 && !strcmp(list[1].name, ".."))
+ if (list == filelist && max > 1 && isdotdir(list[1].name) == 1)
X return(1);
X
X return(0);
@@ -1094,7 +1102,7 @@
X if (isstandout) Xputterm(T_STANDOUT);
X cp = NOFIL_K;
X if (i <= strlen2(cp)) cp = "NoFiles";
- Xcprintf2("%-*.*k", i, i, cp);
+ cputstr(i, cp);
X if (isstandout) Xputterm(END_STANDOUT);
X win_x = calc_x = i + 2;
X win_y = calc_y = filetop(win);
@@ -1159,9 +1167,6 @@
X # endif
X n = -1;
X for (win = 0; win < windows; win++) {
-# ifndef _NOPTY
- if (ptylist[win].pid && ptylist[win].status < 0) continue;
-# endif
X if (win == dupwin) {
X # ifndef _NOTREE
X if (treepath) rewritetree();
@@ -1177,6 +1182,9 @@
X x = win_x;
X y = win_y;
X }
+# ifndef _NOPTY
+ else if (ptylist[win].pid && ptylist[win].status < 0) continue;
+# endif
X else if (filelist
X && (filepos < maxfile || (!filepos && !maxfile)))
X listupfile(filelist, maxfile,
@@ -1277,7 +1285,15 @@
X VOID rewritefile(all)
X int all;
X {
+ int x, y;
+
X if (!filelist || filepos < 0 || maxfile < 0) return;
+#ifndef _NOPTY
+ if (parentfd >= 0) return;
+#endif
+
+ x = win_x;
+ y = win_y;
X if (all > 0) {
X title();
X helpbar();
@@ -1308,6 +1324,11 @@
X listupwin(filelist[filepos].name);
X #endif /* !_NOSPLITWIN */
X }
+
+ if (!all) {
+ win_x = x;
+ win_y = y;
+ }
X Xlocate(win_x, win_y);
X Xtflush();
X }
@@ -1385,7 +1406,7 @@
X search_x = len;
X len = Xkanjiputs(str[2 - s - i]);
X Xputterm(END_STANDOUT);
- Xcprintf2("%-*.*k", n_column - len - 1, n_column - len - 1, buf);
+ cputstr(n_column - len - 1, buf);
X if ((search_x += len) >= n_column) search_x = n_column - 1;
X search_y = L_HELP;
X if (i) filepos = pos;
@@ -1449,9 +1470,9 @@
X }
X #endif
X
- if (!(dirp = Xopendir("."))) {
+ if (!(dirp = Xopendir(curpath))) {
X lostcwd(NULL);
- if (!(dirp = Xopendir("."))) error(".");
+ if (!(dirp = Xopendir(curpath))) error(curpath);
X }
X
X while ((dp = searchdir(dirp, re, arcre))) {
@@ -1513,7 +1534,7 @@
X else
X #endif
X {
- blocksize = getblocksize(".");
+ blocksize = getblocksize(curpath);
X if (sorttype < 100) sorton = sorttype;
X if (readfilelist(re, arcre)) {
X #ifndef _NOPRECEDE
@@ -1562,7 +1583,7 @@
X waitmes();
X
X #ifndef _NOARCHIVE
- if (archivefile) def = (*file) ? file : "";
+ if (archivefile) def = (*file) ? file : nullstr;
X #endif
X getfilelist();
X
@@ -1657,7 +1678,8 @@
X # endif
X else if (chgorder && writefs < 1 && no != WRITE_DIR
X && !fd_restricted
- && (i = writablefs(".")) > 0 && underhome(NULL) > 0) {
+ && (i = writablefs(curpath)) > 0
+ && underhome(NULL) > 0) {
X chgorder = 0;
X if (yesno(WRTOK_K)) arrangedir(i);
X }
@@ -1682,6 +1704,9 @@
X no = ptyusercomm(macrolist[no - FUNCLISTSIZ],
X filelist[filepos].name, 0);
X no = evalstatus(no);
+#ifndef _NOPTY
+ if (ptymode && isearch) no = FNC_NONE;
+#endif
X }
X
X #ifndef _NOPTY
@@ -1729,7 +1754,7 @@
X
X tmp = (filepos >= 0) ? filelist[filepos].name : NULL;
X if (!(cp = archchdir(tmp))) {
- if (!tmp) tmp = "..";
+ if (!tmp) tmp = parentpath;
X warning(-1, tmp);
X strcpy(file, tmp);
X }
@@ -1749,12 +1774,16 @@
X #endif /* !_NOARCHIVE */
X if (no >= FNC_EFFECT) {
X no -= FNC_EFFECT;
- strcpy(file, (maxfile) ? filelist[filepos].name : ".");
+ if (!maxfile && !ischgdir(&(filelist[filepos]))) cp = curpath;
+ else cp = filelist[filepos].name;
+ strcpy(file, cp);
X }
+
+ i = (maxfile || !ischgdir(&(filelist[0]))) ? maxfile : 1;
X #ifndef _NOARCHIVE
X if (!archivefile)
X #endif
- for (i = 0; i < maxfile; i++) {
+ while (i-- > 0) {
X free(filelist[i].name);
X filelist[i].name = NULL;
X }
@@ -1798,7 +1827,7 @@
X i = *file;
X *file = '\0';
X if (file == cp) {
- if (chdir2(_SS_) < 0) error(_SS_);
+ if (chdir2(rootpath) < 0) error(rootpath);
X }
X else if (chdir2(cp) < 0) {
X hideclock = 2;
@@ -1905,17 +1934,17 @@
X #endif /* !_NOSPLITWIN */
X calcwin();
X
- strcpy(file, ".");
+ copycurpath(file);
X _chdir2(fullpath);
X
X for (;;) {
- if (!def && !strcmp(file, "..")) {
+ if (!def && isdotdir(file) == 1) {
X strcpy(prev, getbasename(fullpath));
X if (*prev) def = prev;
- else strcpy(file, ".");
+ else copycurpath(file);
X }
X
- if (strcmp(file, ".")) {
+ if (isdotdir(file) != 2) {
X #ifdef _USEDOSEMU
X char buf[MAXPATHLEN];
X #endif
@@ -1942,7 +1971,7 @@
X if (ischgdir) def = NULL;
X else {
X strcpy(prev, file);
- strcpy(file, ".");
+ copycurpath(file);
X def = prev;
X }
X }
diff -urNP ../FD-2.08a/builtin.c ./builtin.c
--- ../FD-2.08a/builtin.c Tue Feb 7 00:00:00 2006
+++ ./builtin.c Thu Mar 30 00:00:00 2006
@@ -66,6 +66,9 @@
X #ifndef _NOKANJICONV
X extern int unicodebuffer;
X #endif
+#ifndef _NOPTY
+extern int parentfd;
+#endif
X
X static VOID NEAR builtinerror __P_((char *[], char *, int));
X #ifdef _NOORIGSHELL
@@ -143,7 +146,7 @@
X #endif
X
X static CONST char *builtinerrstr[] = {
- "",
+ NULL,
X #define ER_FEWMANYARG 1
X "Too few or many arguments",
X #define ER_OUTOFLIMIT 2
@@ -246,7 +249,8 @@
X if (argv && argv[0]) fprintf2(stderr, "%k: ", argv[0]);
X if (s) fprintf2(stderr, "%k: ", s);
X fprintf2(stderr, "%s.",
- (n >= 0) ? builtinerrstr[n] : strerror2(duperrno));
+ (n >= 0 && builtinerrstr[n])
+ ? builtinerrstr[n] : strerror2(duperrno));
X fputnl(stderr);
X }
X
@@ -1330,7 +1334,7 @@
X freemacro(bindlist[n].d_func);
X if (bindlist[n].key >= K_F(1) && bindlist[n].key <= K_F(10)) {
X free(helpindex[bindlist[n].key - K_F(1)]);
- helpindex[bindlist[n].key - K_F(1)] = strdup2("");
+ helpindex[bindlist[n].key - K_F(1)] = strdup2(nullstr);
X }
X memmove((char *)&(bindlist[n]), (char *)&(bindlist[n + 1]),
X (MAXBINDTABLE - n) * sizeof(bindtable));
@@ -1598,6 +1602,7 @@
X }
X free(sp);
X free(drvlist);
+ free(devp -> name);
X return(no);
X }
X fdtype[no].offset = 0;
@@ -2166,7 +2171,8 @@
X
X i = n;
X for (; n < argc; n++) if (!strchr(argv[n], '=')) break;
- if ((f = parsehist((n < argc) ? argv[n] : "!", NULL)) < 0) {
+ f = parsehist((n < argc) ? argv[n] : "!", NULL, '\0');
+ if (f < 0) {
X builtinerror(argv, argv[n], ER_EVENTNOFOUND);
X entryhist(0, tmp, 0);
X free(tmp);
@@ -2209,12 +2215,12 @@
X if (!editor) editor = EDITOR;
X
X if (list) {
- f = parsehist((n < argc) ? argv[n] : "-16", NULL);
- l = parsehist((n + 1 < argc) ? argv[n + 1] : "!", NULL);
+ f = parsehist((n < argc) ? argv[n] : "-16", NULL, '\0');
+ l = parsehist((n + 1 < argc) ? argv[n + 1] : "!", NULL, '\0');
X }
X else {
- f = parsehist((n < argc) ? argv[n] : "!", NULL);
- l = (n + 1 < argc) ? parsehist(argv[n + 1], NULL) : f;
+ f = parsehist((n < argc) ? argv[n] : "!", NULL, '\0');
+ l = (n + 1 < argc) ? parsehist(argv[n + 1], NULL, '\0') : f;
X }
X if (f < 0 || l < 0) {
X if (f < 0) builtinerror(argv, argv[n], ER_EVENTNOFOUND);
@@ -2687,7 +2693,7 @@
X }
X if (!(wastty = isttyiomode)) ttyiomode(1);
X duppromptstr = promptstr;
- promptstr = (argc >= 2) ? argv[1] : "";
+ promptstr = (argc >= 2) ? argv[1] : nullstr;
X s = inputstr(NULL, 0, -1, NULL, -1);
X promptstr = duppromptstr;
X if (!wastty) stdiomode();
@@ -2711,7 +2717,7 @@
X builtinerror(argv, NULL, ER_NOTDUMBTERM);
X return(-1);
X }
- if (argc < 2) s = "";
+ if (argc < 2) s = nullstr;
X else s = argv[1];
X
X if (!(wastty = isttyiomode)) ttyiomode(1);
@@ -3278,6 +3284,12 @@
X fputnl(stderr);
X return(RET_NOTICE);
X }
+#ifndef _NOPTY
+ if (parentfd >= 0) {
+ sendparent(TE_INTERNAL, n, argv[1]);
+ return(RET_SUCCESS);
+ }
+#endif
X ttyiomode(0);
X internal_status = (*funclist[n].func)(argv[1]);
X locate(0, n_line - 1);
diff -urNP ../FD-2.08a/command.c ./command.c
--- ../FD-2.08a/command.c Tue Feb 7 00:00:00 2006
+++ ./command.c Thu Mar 30 00:00:00 2006
@@ -55,6 +55,7 @@
X #endif
X #ifndef _NOPTY
X extern int ptymode;
+extern int ptyinternal;
X #endif
X
X static VOID NEAR replacefname __P_((char *));
@@ -325,8 +326,9 @@
X if (filepos < maxfile) free(filelist[filepos].name);
X else for (maxfile = 0; maxfile < filepos; maxfile++)
X if (!filelist[maxfile].name)
- filelist[maxfile].name = strdup2("");
- filelist[filepos].name = (name) ? name : strdup2("..");
+ filelist[maxfile].name = strdup2(nullstr);
+ filelist[filepos].name = (name) ? name : strdup2(parentpath);
+ filelist[filepos].tmpflags |= F_ISCHGDIR;
X }
X
X static int cur_up(arg)
@@ -749,7 +751,7 @@
X else
X #endif
X if (!isdir(&(filelist[filepos]))
- || !strcmp(filelist[filepos].name, "."))
+ || isdotdir(filelist[filepos].name) == 2)
X return(warning_bell(arg));
X
X return(FNC_CHDIR);
@@ -902,7 +904,7 @@
X {
X char *path;
X
- path = strdup2(_SS_);
+ path = strdup2(rootpath);
X if (chdir3(path, 1) < 0) error(path);
X replacefname(path);
X
@@ -1077,7 +1079,8 @@
X }
X #endif
X #ifndef _NODOSDRIVE
- else if ((drive = tmpdosdupl("", &dir, 1)) < 0) return(FNC_CANCEL);
+ else if ((drive = tmpdosdupl(nullstr, &dir, 1)) < 0)
+ return(FNC_CANCEL);
X #endif
X
X if (!execenv("FD_PAGER", filelist[filepos].name)) {
@@ -1120,7 +1123,7 @@
X if (archivefile) return(FNC_CANCEL);
X #endif
X #ifndef _NODOSDRIVE
- if ((drive = tmpdosdupl("", &dir, 1)) < 0) return(FNC_CANCEL);
+ if ((drive = tmpdosdupl(nullstr, &dir, 1)) < 0) return(FNC_CANCEL);
X #endif
X if (!execenv("FD_EDITOR", filelist[filepos].name)) {
X #ifdef EDITOR
@@ -1214,7 +1217,7 @@
X int fs;
X
X if (writefs >= 2 || findpattern) return(warning_bell(arg));
- if ((fs = writablefs(".")) <= 0) {
+ if ((fs = writablefs(curpath)) <= 0) {
X warning(0, NOWRT_K);
X return(FNC_CANCEL);
X }
@@ -1237,7 +1240,7 @@
X
X checkscreen(WCOLUMNMIN, WHEADERMAX + WFOOTER + WFILEMIN);
X #ifndef _NODOSDRIVE
- if ((drive = dospath3(""))) flushdrv(drive, NULL);
+ if ((drive = dospath3(nullstr))) flushdrv(drive, NULL);
X #endif
X
X return(FNC_EFFECT);
@@ -1276,6 +1279,7 @@
X {
X int i;
X
+ VOID_C checkallpty();
X for (i = 0; i < MAXWINDOWS; i++) if (ptylist[i].pid) break;
X if (i < MAXWINDOWS && !yesno(KILL_K)) return(1);
X
@@ -1407,7 +1411,7 @@
X }
X if (strdelim(file, 0)) {
X free(file);
- file = strdup2("..");
+ file = strdup2(parentpath);
X }
X replacefname(file);
X
@@ -1507,7 +1511,7 @@
X
X if (!(findregexp = prepareregexp(FINDD_K, arg))) return(FNC_CANCEL);
X destpath = NULL;
- cp = isdir(&(filelist[filepos])) ? filelist[filepos].name : ".";
+ cp = isdir(&(filelist[filepos])) ? filelist[filepos].name : curpath;
X applydir(cp, findfile, finddir, NULL, ORD_NORMAL, NOFND_K);
X regexp_free(findregexp);
X if (!destpath) return(FNC_CANCEL);
@@ -1528,7 +1532,8 @@
X int n;
X {
X if (n < 0) return(FNC_CANCEL);
- if (internal_status > FNC_FAIL) return(internal_status);
+ if (internal_status == FNC_QUIT || internal_status > FNC_CANCEL)
+ return(internal_status);
X
X return(FNC_EFFECT);
X }
@@ -1627,7 +1632,7 @@
X else
X #endif
X #ifndef _NODOSDRIVE
- if ((drive = tmpdosdupl("", &dir, 1)) < 0) ret = -1;
+ if ((drive = tmpdosdupl(nullstr, &dir, 1)) < 0) ret = -1;
X else if (drive) {
X ret = ptyusercomm(com, filelist[filepos].name,
X F_ARGSET | F_IGNORELIST);
@@ -1732,7 +1737,7 @@
X return(FNC_CANCEL);
X else if (!*(path = evalpath(path, 0))) {
X free(path);
- path = strdup2(".");
+ path = strdup2(curpath);
X }
X
X ret = infofs(path);
@@ -1844,8 +1849,10 @@
X return(FNC_UPDATE);
X }
X free(path);
- if (findpattern) free(findpattern);
- findpattern = NULL;
+ if (findpattern) {
+ free(findpattern);
+ findpattern = NULL;
+ }
X replacefname(NULL);
X
X return(FNC_EFFECT);
@@ -1889,7 +1896,7 @@
X }
X }
X #ifndef _NODOSDRIVE
- else if ((drive = tmpdosdupl("", &dir, 0)) < 0) {
+ else if ((drive = tmpdosdupl(nullstr, &dir, 0)) < 0) {
X free(dev);
X return(FNC_CANCEL);
X }
@@ -1950,9 +1957,9 @@
X &= ~(F_ISMRK | F_WSMRK | F_ISARG);
X if (filelist) return;
X maxfile = winvar[oldwin].v_maxfile;
+ i = ((maxfile) ? maxfile : 1) * sizeof(namelist);
X addlist();
- memcpy((char *)filelist, (char *)(winvar[oldwin].v_filelist),
- winvar[oldwin].v_maxfile * sizeof(namelist));
+ memcpy((char *)filelist, (char *)(winvar[oldwin].v_filelist), i);
X for (i = 0; i < winvar[oldwin].v_maxfile; i++)
X filelist[i].name = strdup2(winvar[oldwin].v_filelist[i].name);
X filepos = winvar[oldwin].v_filepos;
@@ -2061,7 +2068,7 @@
X {
X if (nextwin() < 0) return(FNC_NONE);
X # ifndef _NOPTY
- if (ptylist[win].pid && ptylist[win].status < 0) {
+ if (!ptyinternal && ptylist[win].pid && ptylist[win].status < 0) {
X rewritefile(0);
X VOID_C frontend();
X if (internal_status > FNC_FAIL) return(internal_status);
@@ -2142,7 +2149,7 @@
X if (chdir3(fullpath, 1) < 0) lostcwd(fullpath);
X
X # ifndef _NOPTY
- if (ptylist[win].pid && ptylist[win].status < 0) {
+ if (!ptyinternal && ptylist[win].pid && ptylist[win].status < 0) {
X rewritefile(0);
X VOID_C frontend();
X if (internal_status > FNC_FAIL) return(internal_status);
diff -urNP ../FD-2.08a/custom.c ./custom.c
--- ../FD-2.08a/custom.c Tue Feb 7 00:00:00 2006
+++ ./custom.c Thu Mar 30 00:00:00 2006
@@ -179,6 +179,8 @@
X u_char type;
X } envtable;
X
+#define env_str(n) (&(envlist[n].env[FDESIZ]))
+#define fdenv_str(n) (envlist[n].env)
X #ifdef FORCEDSTDC
X #define def_str(n) (envlist[n].def.str)
X #define def_num(n) (envlist[n].def.num)
@@ -535,7 +537,7 @@
X char *cp;
X int n;
X
- cp = getenv2(envlist[no].env);
+ cp = getenv2(fdenv_str(no));
X switch (envlist[no].type) {
X case T_BOOL:
X if (!cp) n = def_num(no);
@@ -670,7 +672,10 @@
X
X if (!stable) /*EMPTY*/;
X else if (pp -> lang == NOCNV) {
- pp -> last = NULL;
+ if (!(pp -> flags & P_STABLE)) {
+ if (pp -> last) free(pp -> last);
+ pp -> last = NULL;
+ }
X stable = 0;
X }
X else if (pp -> flags & P_STABLE) /*EMPTY*/;
@@ -703,7 +708,10 @@
X }
X if (kanjierrno) pp -> lang = DEFCODE;
X }
- pp -> last = strdup2(path);
+ if (!(pp -> flags & P_STABLE)) {
+ if (pp -> last) free(pp -> last);
+ pp -> last = strdup2(path);
+ }
X }
X
X static VOID NEAR savepathlang(VOID_A)
@@ -795,6 +803,12 @@
X {
X int i;
X
+# ifndef _NOKANJIFCONV
+ for (i = 0; i < PATHLISTSIZ; i++) {
+ if (pathlist[i].last) free(pathlist[i].last);
+ pathlist[i].last = NULL;
+ }
+# endif
X for (i = 0; i < ENVLISTSIZ; i++) switch (envlist[i].type) {
X case T_PATH:
X case T_PATHS:
@@ -840,7 +854,7 @@
X {
X Xlocate(0, y);
X Xputterm(T_STANDOUT);
- Xcprintf2("%*s", w, "");
+ cputspace(w);
X Xputterm(END_STANDOUT);
X }
X
@@ -1097,9 +1111,8 @@
X savepathlang();
X #endif
X for (i = 0; i < ENVLISTSIZ; i++) {
- setenv2(envlist[i].env, list[i * 2], 0);
- setenv2(&(envlist[i].env[FDESIZ]),
- list[i * 2 + 1], 0);
+ setenv2(fdenv_str(i), list[i * 2], 0);
+ setenv2(env_str(i), list[i * 2 + 1], 0);
X _evalenv(i);
X }
X #ifndef _NOKANJIFCONV
@@ -1110,10 +1123,8 @@
X else {
X list = (char **)malloc2(ENVLISTSIZ * 2 * sizeof(char *));
X for (i = 0; i < ENVLISTSIZ; i++) {
- list[i * 2] = strdup2(getshellvar(envlist[i].env, -1));
- list[i * 2 + 1] =
- strdup2(getshellvar(&(envlist[i].env[FDESIZ]),
- -1));
+ list[i * 2] = strdup2(getshellvar(fdenv_str(i), -1));
+ list[i * 2 + 1] = strdup2(getshellvar(env_str(i), -1));
X }
X }
X
@@ -1129,9 +1140,9 @@
X savepathlang();
X #endif
X for (i = 0; i < ENVLISTSIZ; i++) {
- setenv2(envlist[i].env, NULL, 0);
+ setenv2(fdenv_str(i), NULL, 0);
X cp = (envlist[i].type == T_CHARP) ? def_str(i) : NULL;
- setenv2(&(envlist[i].env[FDESIZ]), cp, 0);
+ setenv2(env_str(i), cp, 0);
X _evalenv(i);
X }
X #ifndef _NOKANJIFCONV
@@ -1316,18 +1327,18 @@
X # endif
X # ifndef _NOPTY
X case T_KEYCODE:
- cp = getenv2(envlist[no].env);
+ cp = getenv2(fdenv_str(no));
X break;
X # endif
X default:
- if (!(cp = getenv2(envlist[no].env))) cp = def_str(no);
+ if (!(cp = getenv2(fdenv_str(no)))) cp = def_str(no);
X break;
X }
X
- if (!getenv2(envlist[no].env))
+ if (!getenv2(fdenv_str(no)))
X cp = new = strcatalloc(strdup2(cp),
X (cp && *cp) ? VDEF_K : VUDEF_K);
- Xcprintf2("%-*.*k", MAXCUSTVAL, MAXCUSTVAL, cp);
+ cputstr(MAXCUSTVAL, cp);
X n = strlen2(cp);
X if (n > MAXCUSTVAL - 1) n = MAXCUSTVAL - 1;
X if (new) free(new);
@@ -1344,7 +1355,7 @@
X for (n = 0; n < MAXSELECTSTRS; n++) val[n] = n;
X
X new = NULL;
- env = &(envlist[no].env[FDESIZ]);
+ env = env_str(no);
X switch (envlist[no].type) {
X case T_BOOL:
X n = (*((int *)(envlist[no].var))) ? 1 : 0;
@@ -1385,7 +1396,7 @@
X break;
X case T_PATH:
X case T_PATHS:
- if (!(cp = getenv2(envlist[no].env))) cp = def_str(no);
+ if (!(cp = getenv2(fdenv_str(no)))) cp = def_str(no);
X new = inputcustenvstr(env, 1, cp, HST_PATH);
X if (new == (char *)-1) return(0);
X cp = new;
@@ -1636,7 +1647,7 @@
X n += p;
X }
X # endif /* !_NOKANJICONV */
- str[NOCNV] = "";
+ str[NOCNV] = nullstr;
X # if !defined (_NOENGMES) && !defined (_NOJPNMES)
X str[ENG] = "C";
X # endif
@@ -1674,7 +1685,7 @@
X # endif /* FD >= 2 */
X # ifndef _NOPTY
X case T_KEYCODE:
- if (!(cp = getenv2(envlist[no].env))) cp = "";
+ if (!(cp = getenv2(fdenv_str(no)))) cp = nullstr;
X new = inputcustenvstr(env, 0, cp, -1);
X if (new == (char *)-1) return(0);
X if (new && getkeycode(new, 0) < 0) {
@@ -1686,15 +1697,14 @@
X break;
X # endif /* !_NOPTY */
X default:
- if (!(cp = getenv2(envlist[no].env))) cp = def_str(no);
+ if (!(cp = getenv2(fdenv_str(no)))) cp = def_str(no);
X new = inputcustenvstr(env, 0, cp, -1);
X if (new == (char *)-1) return(0);
X cp = new;
X break;
X }
X
- if (getshellvar(envlist[no].env, -1))
- n = setenv2(envlist[no].env, cp, 0);
+ if (getshellvar(fdenv_str(no), -1)) n = setenv2(fdenv_str(no), cp, 0);
X else n = setenv2(env, cp, 0);
X if (new) free(new);
X if (n < 0) warning(-1, env);
@@ -1719,11 +1729,11 @@
X
X for (i = n = 0; i < ENVLISTSIZ; i++) {
X if ((!flaglist || !(flaglist[i] & 2))
- && (cp = getshellvar(&(envlist[i].env[FDESIZ]), -1))
+ && (cp = getshellvar(env_str(i), -1))
X && (envlist[i].type != T_CHARP || strenvcmp(cp, def_str(i))))
X n++;
X if ((!flaglist || !(flaglist[i] & 1))
- && getshellvar(envlist[i].env, -1))
+ && getshellvar(fdenv_str(i), -1))
X n++;
X }
X if (!n || !fp) return(n);
@@ -1732,16 +1742,16 @@
X fputs("# shell variables definition\n", fp);
X for (i = 0; i < ENVLISTSIZ; i++) {
X if ((!flaglist || !(flaglist[i] & 2))
- && (cp = getshellvar(&(envlist[i].env[FDESIZ]), -1))
+ && (cp = getshellvar(env_str(i), -1))
X && (envlist[i].type != T_CHARP || strenvcmp(cp, def_str(i)))) {
X cp = killmeta(cp);
- fprintf2(fp, "%s=%s\n", &(envlist[i].env[FDESIZ]), cp);
+ fprintf2(fp, "%s=%s\n", env_str(i), cp);
X free(cp);
X }
X if ((!flaglist || !(flaglist[i] & 1))
- && (cp = getshellvar(envlist[i].env, -1))) {
+ && (cp = getshellvar(fdenv_str(i), -1))) {
X cp = killmeta(cp);
- fprintf2(fp, "%s=%s\n", envlist[i].env, cp);
+ fprintf2(fp, "%s=%s\n", fdenv_str(i), cp);
X free(cp);
X }
X }
@@ -1760,10 +1770,8 @@
X
X for (n = 0; argv[n]; n++) {
X for (i = 0; i < ENVLISTSIZ; i++) {
- ident = envlist[i].env;
- if (!strnenvcmp(argv[n], ident, len[n])) break;
- ident += FDESIZ;
- if (!strnenvcmp(argv[n], ident, len[n])) break;
+ if (!strnenvcmp(argv[n], fdenv_str(i), len[n])) break;
+ if (!strnenvcmp(argv[n], env_str(i), len[n])) break;
X }
X if (i < ENVLISTSIZ) break;
X }
@@ -1776,12 +1784,12 @@
X f = 0; /* fake for -Wuninitialized */
X # endif
X for (i = 0; i < ENVLISTSIZ; i++) {
- ident = envlist[i].env;
+ ident = fdenv_str(i);
X if (!strnenvcmp(argv[n], ident, len[n])) {
X f = 1;
X break;
X }
- ident += FDESIZ;
+ ident = env_str(i);
X if (!strnenvcmp(argv[n], ident, len[n])) {
X f = 2;
X break;
@@ -1841,10 +1849,8 @@
X
X for (n = 1; argv[n]; n++) {
X for (i = 0; i < ENVLISTSIZ; i++) {
- ident = envlist[i].env;
- if (!strenvcmp(argv[n], ident)) break;
- ident += FDESIZ;
- if (!strenvcmp(argv[n], ident)) break;
+ if (!strenvcmp(argv[n], fdenv_str(i))) break;
+ if (!strenvcmp(argv[n], env_str(i))) break;
X }
X if (i < ENVLISTSIZ) break;
X }
@@ -1857,12 +1863,12 @@
X f = 0; /* fake for -Wuninitialized */
X # endif
X for (i = 0; i < ENVLISTSIZ; i++) {
- ident = envlist[i].env;
+ ident = fdenv_str(i);
X if (!strenvcmp(argv[n], ident)) {
X f = 1;
X break;
X }
- ident += FDESIZ;
+ ident = env_str(i);
X if (!strenvcmp(argv[n], ident)) {
X f = 2;
X break;
@@ -1944,7 +1950,7 @@
X int len, width;
X
X if (bindlist[no].key < 0) {
- Xcprintf2("%*s", MAXCUSTVAL, "");
+ cputspace(MAXCUSTVAL);
X return(0);
X }
X if (bindlist[no].f_func < FUNCLISTSIZ)
@@ -1957,14 +1963,13 @@
X else cp2 = NULL;
X if (!cp2) {
X width = MAXCUSTVAL;
- Xcprintf2("%-*.*k", width, width, cp1);
+ cputstr(width, cp1);
X }
X else {
X width = (MAXCUSTVAL - 1) / 2;
- Xcprintf2("%-*.*k", width, width, cp1);
+ cputstr(width, cp1);
X putsep();
- Xcprintf2("%-*.*k",
- MAXCUSTVAL - 1 - width, MAXCUSTVAL - 1 - width, cp2);
+ cputstr(MAXCUSTVAL - 1 - width, cp2);
X }
X len = strlen2(cp1);
X if (len > --width) len = width;
@@ -2264,11 +2269,11 @@
X
X key.code = keyseqlist[no];
X if (getkeyseq(&key) < 0 || !(key.len)) {
- Xcprintf2("%*s", MAXCUSTVAL, "");
+ cputspace(MAXCUSTVAL);
X return(0);
X }
X cp = encodestr(key.str, key.len);
- Xcprintf2("%-*.*k", MAXCUSTVAL, MAXCUSTVAL, cp);
+ cputstr(MAXCUSTVAL, cp);
X len = strlen2(cp);
X if (len > MAXCUSTVAL - 1) len = MAXCUSTVAL - 1;
X free(cp);
@@ -2519,19 +2524,19 @@
X int len, width;
X
X if (no >= maxlaunch) {
- Xcprintf2("%*s", MAXCUSTVAL, "");
+ cputspace(MAXCUSTVAL);
X return(0);
X }
X if (!launchlist[no].format) {
X width = MAXCUSTVAL;
- Xcprintf2("%-*.*k", width, width, launchlist[no].comm);
+ cputstr(width, launchlist[no].comm);
X }
X else {
X width = (MAXCUSTVAL - 1 - 6) / 2;
- Xcprintf2("%-*.*k", width, width, launchlist[no].comm);
+ cputstr(width, launchlist[no].comm);
X putsep();
X width = MAXCUSTVAL - 1 - 6 - width;
- Xcprintf2("%-*.*k", width, width, launchlist[no].format[0]);
+ cputstr(width, launchlist[no].format[0]);
X putsep();
X Xcprintf2("%-2d", (int)(launchlist[no].topskip));
X putsep();
@@ -2563,7 +2568,7 @@
X }
X Xcprintf2("%.*k", len, list -> ext + 1);
X putsep();
- Xcprintf2("%-*.*k", MAXCUSTVAL, MAXCUSTVAL, list -> comm);
+ cputstr(MAXCUSTVAL, list -> comm);
X putsep();
X fillline(yy + y++, n_column);
X nf = ni = ne = 0;
@@ -2593,8 +2598,7 @@
X Xputterm(END_STANDOUT);
X putsep();
X }
- Xcprintf2("%-*.*k",
- MAXCUSTVAL, MAXCUSTVAL, list -> format[nf]);
+ cputstr(MAXCUSTVAL, list -> format[nf]);
X putsep();
X nf++;
X }
@@ -2612,8 +2616,7 @@
X Xputterm(END_STANDOUT);
X putsep();
X }
- Xcprintf2("%-*.*k",
- MAXCUSTVAL, MAXCUSTVAL, list -> lignore[ni]);
+ cputstr(MAXCUSTVAL, list -> lignore[ni]);
X putsep();
X ni++;
X }
@@ -2631,8 +2634,7 @@
X Xputterm(END_STANDOUT);
X putsep();
X }
- Xcprintf2("%-*.*k",
- MAXCUSTVAL, MAXCUSTVAL, list -> lerror[ne]);
+ cputstr(MAXCUSTVAL, list -> lerror[ne]);
X putsep();
X ne++;
X }
@@ -3069,18 +3071,13 @@
X int len, width;
X
X if (no >= maxarchive) {
- Xcprintf2("%*s", MAXCUSTVAL, "");
+ cputspace(MAXCUSTVAL);
X return(0);
X }
X width = (MAXCUSTVAL - 1) / 2;
- if (!archivelist[no].p_comm) Xcprintf2("%*s", width, "");
- else Xcprintf2("%-*.*k", width, width, archivelist[no].p_comm);
+ cputstr(width, archivelist[no].p_comm);
X putsep();
- if (!archivelist[no].u_comm)
- Xcprintf2("%*s", MAXCUSTVAL - 1 - width, "");
- else Xcprintf2("%-*.*k",
- MAXCUSTVAL - 1 - width, MAXCUSTVAL - 1 - width,
- archivelist[no].u_comm);
+ cputstr(MAXCUSTVAL - 1 - width, archivelist[no].u_comm);
X len = (archivelist[no].p_comm) ? strlen2(archivelist[no].p_comm) : 0;
X if (len > --width) len = width;
X
@@ -3325,11 +3322,11 @@
X int i, len, w1, w2, width;
X
X if (!fdtype[no].name) {
- Xcprintf2("%*s", MAXCUSTVAL, "");
+ cputspace(MAXCUSTVAL);
X return(0);
X }
X width = (MAXCUSTVAL - 1) / 2;
- Xcprintf2("%-*.*k", width, width, fdtype[no].name);
+ cputstr(width, fdtype[no].name);
X putsep();
X
X w1 = MAXCUSTVAL - 1 - width;
@@ -3342,7 +3339,7 @@
X i = strlen(buf);
X snprintf2(&(buf[i]), sizeof(buf) - i, " #offset=%'Ld",
X fdtype[no].offset / fdtype[no].sect);
- Xcprintf2("%-*.*k", w1, w1, buf);
+ cputstr(w1, buf);
X }
X else
X # endif /* HDDMOUNT */
@@ -3369,8 +3366,7 @@
X break;
X }
X w1 -= (w2 + 1) * 3;
- if (i >= MEDIADESCRSIZ) Xcprintf2("%*s", w1, "");
- else Xcprintf2("%-*.*k", w1, w1, mediadescr[i].name);
+ cputstr(w1, (i < MEDIADESCRSIZ) ? mediadescr[i].name : NULL);
X }
X len = strlen2(fdtype[no].name);
X if (len > --width) len = width;
@@ -3665,7 +3661,7 @@
X # else
X mes[4] = COVWR_K;
X # endif
- Xcprintf2("%-*.*k", MAXCUSTVAL, MAXCUSTVAL, mes[no]);
+ cputstr(MAXCUSTVAL, mes[no]);
X len = strlen2(mes[no]);
X if (len > MAXCUSTVAL - 1) len = MAXCUSTVAL - 1;
X
@@ -4063,7 +4059,7 @@
X cp = NEWET_K;
X switch (custno) {
X case 0:
- cp = &(envlist[no].env[FDESIZ]);
+ cp = env_str(no);
X break;
X case 1:
X if (bindlist[no].key >= 0)
@@ -4119,7 +4115,7 @@
X cp = name[no];
X break;
X default:
- cp = "";
+ cp = nullstr;
X break;
X }
X
@@ -4182,8 +4178,7 @@
X Xcprintf2("%.*k", MAXCUSTVAL, NIMPL_K);
X if (cs_len[i - start] > MAXCUSTVAL - 1)
X cs_len[i - start] = MAXCUSTVAL - 1;
- else Xcprintf2("%*s",
- MAXCUSTVAL - cs_len[i - start], "");
+ else cputspace(MAXCUSTVAL - cs_len[i - start]);
X break;
X }
X putsep();
diff -urNP ../FD-2.08a/doscom.c ./doscom.c
--- ../FD-2.08a/doscom.c Tue Feb 7 00:00:00 2006
+++ ./doscom.c Thu Mar 30 00:00:00 2006
@@ -293,14 +293,14 @@
X # else
X # define L_SET 0
X # endif
-#endif
+#endif /* !L_SET */
X #ifndef L_INCR
X # ifdef SEEK_CUR
X # define L_INCR SEEK_CUR
X # else
X # define L_INCR 1
X # endif
-#endif
+#endif /* !L_INCR */
X
X extern char *malloc2 __P_((ALLOC_T));
X extern char *realloc2 __P_((VOID_P, ALLOC_T));
@@ -411,7 +411,7 @@
X #endif
X
X static CONST char *doserrstr[] = {
- "",
+ NULL,
X #define ER_REQPARAM 1
X "Required parameter missing",
X #define ER_TOOMANYPARAM 2
@@ -757,7 +757,7 @@
X kanjifputs(s, stderr);
X fputnl(stderr);
X }
- fputs(doserrstr[n], stderr);
+ if (doserrstr[n]) fputs(doserrstr[n], stderr);
X fputnl(stderr);
X }
X
@@ -1536,7 +1536,7 @@
X if ((n = getdiropt(argc, argv)) < 0)
X return(RET_FAIL);
X if (argc <= n) {
- dir = ".";
+ dir = curpath;
X file = "*";
X }
X else if (argc > n + 1) {
@@ -1552,7 +1552,7 @@
X else {
X strcpy(buf, argv[n]);
X if (!(file = strrdelim(buf, 1))) {
- dir = ".";
+ dir = curpath;
X file = argv[n];
X }
X else {
diff -urNP ../FD-2.08a/dosdisk.c ./dosdisk.c
--- ../FD-2.08a/dosdisk.c Tue Feb 7 00:00:00 2006
+++ ./dosdisk.c Thu Mar 30 00:00:00 2006
@@ -283,8 +283,8 @@
X static int NEAR readdent __P_((dosDIR *, dent_t *, int));
X static dosDIR *NEAR _dosopendir __P_((char *, char *, int));
X static int NEAR _dosclosedir __P_((dosDIR *));
-static struct dirent *NEAR _dosreaddir __P_((dosDIR *, int));
-static struct dirent *NEAR finddirent __P_((dosDIR *, char *, int, int));
+static struct dosdirent *NEAR _dosreaddir __P_((dosDIR *, int));
+static struct dosdirent *NEAR finddirent __P_((dosDIR *, char *, int, int));
X static dosDIR *NEAR splitpath __P_((char **, char *, int));
X static int NEAR getdent __P_((char *, int *));
X static int NEAR writedent __P_((int));
@@ -3133,7 +3133,7 @@
X int needlfn;
X {
X dosDIR *xdirp;
- struct dirent *dp;
+ struct dosdirent *dp;
X dent_t *dentp;
X cache_t *cache;
X char *cp, *cachepath, buf[DOSMAXPATHLEN - 2];
@@ -3361,19 +3361,19 @@
X return(0);
X }
X
-static struct dirent *NEAR _dosreaddir(xdirp, all)
+static struct dosdirent *NEAR _dosreaddir(xdirp, all)
X dosDIR *xdirp;
X int all;
X {
X dent_t *dentp;
- static st_dirent d;
- struct dirent *dp;
+ static st_dosdirent d;
+ struct dosdirent *dp;
X char *cp, buf[LFNENTSIZ * 2 + 1];
X long loc, clust, offset;
X u_int ch;
X int i, j, cnt, sum;
X
- dp = (struct dirent *)&d;
+ dp = (struct dosdirent *)&d;
X dentp = dd2dentp(xdirp -> dd_fd);
X dp -> d_name[0] = '\0';
X dp -> d_reclen = DOSDIRENT;
@@ -3462,11 +3462,11 @@
X return(dp);
X }
X
-struct dirent *dosreaddir(dirp)
+struct dosdirent *dosreaddir(dirp)
X DIR *dirp;
X {
X dosDIR *xdirp;
- struct dirent *dp;
+ struct dosdirent *dp;
X int i;
X #if !MSDOS
X int c;
@@ -3490,12 +3490,12 @@
X return(dp);
X }
X
-static struct dirent *NEAR finddirent(xdirp, fname, len, needlfn)
+static struct dosdirent *NEAR finddirent(xdirp, fname, len, needlfn)
X dosDIR *xdirp;
X char *fname;
X int len, needlfn;
X {
- struct dirent *dp;
+ struct dosdirent *dp;
X u_char dosname[8 + 3 + 1];
X char tmp[8 + 1 + 3 + 1];
X
@@ -4024,7 +4024,7 @@
X char *path, *resolved;
X {
X dosDIR *xdirp;
- struct dirent *dp;
+ struct dosdirent *dp;
X char *cp, buf[DOSMAXPATHLEN];
X int dd, drive;
X
@@ -4690,7 +4690,7 @@
X char *path;
X {
X dosDIR *xdirp;
- struct dirent *dp;
+ struct dosdirent *dp;
X cache_t cache;
X long clust, offset;
X int sum, ret;
diff -urNP ../FD-2.08a/dosdisk.h ./dosdisk.h
--- ../FD-2.08a/dosdisk.h Tue Feb 7 00:00:00 2006
+++ ./dosdisk.h Thu Mar 30 00:00:00 2006
@@ -62,21 +62,21 @@
X # else
X # define L_SET 0
X # endif
-#endif
+#endif /* !L_SET */
X #ifndef L_INCR
X # ifdef SEEK_CUR
X # define L_INCR SEEK_CUR
X # else
X # define L_INCR 1
X # endif
-#endif
+#endif /* !L_INCR */
X #ifndef L_XTND
X # ifdef SEEK_END
X # define L_XTND SEEK_END
X # else
X # define L_XTND 2
X # endif
-#endif
+#endif /* !L_XTND */
X
X #ifndef __attribute__
X #define __attribute__(x)
@@ -167,7 +167,7 @@
X l_off_t offset;
X # endif
X } devinfo;
-#endif
+#endif /* !MSDOS */
X
X typedef struct _devstat {
X u_char drive;
@@ -323,6 +323,19 @@
X typedef struct dirent st_dirent;
X #endif
X
+#ifdef CYGWIN
+ /* Some versions of Cygwin have neither d_fileno nor d_ino */
+struct dosdirent {
+ u_long d_fileno;
+ u_short d_reclen;
+ char d_name[MAXNAMLEN + 1];
+};
+typedef struct dosdirent st_dosdirent;
+#else
+#define dosdirent dirent
+#define st_dosdirent st_dirent
+#endif
+
X #ifndef _NODOSDRIVE
X #if MSDOS
X extern int dependdosfunc;
@@ -345,7 +358,7 @@
X extern int flushdrv __P_((int, VOID_T (*)__P_((VOID_A))));
X extern DIR *dosopendir __P_((char *));
X extern int dosclosedir __P_((DIR *));
-extern struct dirent *dosreaddir __P_((DIR *));
+extern struct dosdirent *dosreaddir __P_((DIR *));
X extern int dosrewinddir __P_((DIR *));
X extern int doschdir __P_((char *));
X extern char *dosgetcwd __P_((char *, int));
diff -urNP ../FD-2.08a/dosemu.c ./dosemu.c
--- ../FD-2.08a/dosemu.c Tue Feb 7 00:00:00 2006
+++ ./dosemu.c Thu Mar 30 00:00:00 2006
@@ -21,7 +21,7 @@
X # else
X typedef struct dirent st_dirent;
X # endif
-#endif
+#endif /* _NODOSDRIVE */
X
X #if !defined (_NOKANJIFCONV) || !defined (_NOROCKRIDGE)
X typedef struct _opendirpath_t {
@@ -240,7 +240,7 @@
X
X # ifndef _NODOSDRIVE
X if (((dosDIR *)dirp) -> dd_id == DID_IFDOSDRIVE) {
- dp = dosreaddir(dirp);
+ dp = (struct dirent *)dosreaddir(dirp);
X dos = 1;
X }
X else
@@ -250,9 +250,21 @@
X dos = 0;
X }
X if (!dp) return(NULL);
- src = dp -> d_name;
+
X dest = ((struct dirent *)&buf) -> d_name;
- memcpy((char *)(&buf), (char *)dp, dest - (char *)&buf);
+#ifdef CYGWIN
+ /* Some versions of Cygwin have neither d_fileno nor d_ino */
+ if (dos) {
+ src = ((struct dosdirent *)dp) -> d_name;
+ buf.d_reclen = ((struct dosdirent *)dp) -> d_reclen;
+ }
+ else
+#endif
+ {
+ src = dp -> d_name;
+ memcpy((char *)(&buf), (char *)dp, dest - (char *)&buf);
+ }
+
X if (isdotdir(src)) {
X strcpy(dest, src);
X return((struct dirent *)&buf);
@@ -306,7 +318,7 @@
X if ((drive = _dospath(path))) {
X if ((dd = preparedrv(drive)) < 0) n = -1;
X else if ((n = doschdir(path)) < 0) shutdrv(dd);
- else if ((n = (chdir(_SS_)) ? -1 : 0) >= 0) {
+ else if ((n = (chdir(rootpath)) ? -1 : 0) >= 0) {
X if (lastdrv >= 0) {
X if ((lastdrv % DOSNOFILE) != (dd % DOSNOFILE))
X shutdrv(lastdrv);
diff -urNP ../FD-2.08a/fd.man ./fd.man
--- ../FD-2.08a/fd.man Tue Feb 7 00:00:00 2006
+++ ./fd.man Thu Mar 30 00:00:00 2006
@@ -2,9 +2,9 @@
X .\" Copyright (c) 1995-2006 Takashi SHIRAI
X .\" <shirai@unixusers.net>
X .\"
-.\" @(#)fd.1 2.08a 02/07/06
+.\" @(#)fd.1 2.08b 03/30/06
X .\" fd - File & Directory maintenance tool
-.TH FD 1 "February 7, 2006"
+.TH FD 1 "March 30, 2006"
X .de sh
X .br
X .PP
diff -urNP ../FD-2.08a/fd_e.man ./fd_e.man
--- ../FD-2.08a/fd_e.man Tue Feb 7 00:00:00 2006
+++ ./fd_e.man Thu Mar 30 00:00:00 2006
@@ -2,9 +2,9 @@
X .\" Copyright (c) 1995-2006 Takashi SHIRAI
X .\" <shirai@unixusers.net>
X .\"
-.\" @(#)fd.1 2.08a 02/07/06
+.\" @(#)fd.1 2.08b 03/30/06
X .\" fd - File & Directory maintenance tool
-.TH FD 1 "February 7, 2006"
+.TH FD 1 "March 30, 2006"
X .de sh
X .br
X .PP
diff -urNP ../FD-2.08a/file.c ./file.c
--- ../FD-2.08a/file.c Tue Feb 7 00:00:00 2006
+++ ./file.c Thu Mar 30 00:00:00 2006
@@ -59,7 +59,7 @@
X # else
X # define L_SET 0
X # endif
-#endif
+#endif /* !L_SET */
X
X #ifdef _NODOSDRIVE
X #define nodoschdir Xchdir
@@ -288,10 +288,10 @@
X case 2:
X if ((cp1 = strrchr(((treelist *)vp1) -> name, '.')))
X cp1++;
- else cp1 = "";
+ else cp1 = nullstr;
X if ((cp2 = strrchr(((treelist *)vp2) -> name, '.')))
X cp2++;
- else cp2 = "";
+ else cp2 = nullstr;
X tmp = strpathcmp2(cp1, cp2);
X break;
X case 3:
@@ -372,7 +372,7 @@
X #endif
X else cp = underpath(cwd, homedir, len);
X
- if (buf) strcpy(buf, (cp) ? cp : "");
+ if (buf) strcpy(buf, (cp) ? cp : nullstr);
X #ifdef DEBUG
X free(homedir);
X homedir = NULL;
@@ -648,13 +648,13 @@
X cp = NOCWD_K;
X else if ((cp = gethomedir()) && !nodoschdir(cp) && nodosgetwd(path))
X cp = GOHOM_K;
- else if (!nodoschdir(_SS_) && nodosgetwd(path)) cp = GOROT_K;
- else error(_SS_);
+ else if (!nodoschdir(rootpath) && nodosgetwd(path)) cp = GOROT_K;
+ else error(rootpath);
X
X if (path != fullpath) strncpy2(fullpath, path, MAXPATHLEN - 1);
X warning(0, cp);
X #ifndef _NOUSEHASH
- searchhash(NULL, "", "");
+ searchhash(NULL, nullstr, nullstr);
X #endif
X errno = duperrno;
X }
@@ -1079,7 +1079,7 @@
X strcatdelim2(buf, dir, file);
X
X if (rawchdir(buf) != 0) return(0);
- rawchdir(_SS_);
+ rawchdir(rootpath);
X #if MSDOS
X spawnlpe(P_WAIT, "DELTREE.EXE", "DELTREE", "/Y", buf, NULL, environ);
X #else
@@ -1508,7 +1508,7 @@
X fnamp = strcatdelim2(path, tmpdir, NULL) - path;
X waitmes();
X
- if (!(dirp = Xopendir("."))) {
+ if (!(dirp = Xopendir(curpath))) {
X freevar(fnamelist);
X noconv--;
X lostcwd(path);
@@ -1558,8 +1558,8 @@
X
X #if !MSDOS
X if (fs != FSID_EFS) entnum = NULL; /* except IRIX File System */
- else if (!(entnum = getentnum(".", persec))) {
- warning(-1, ".");
+ else if (!(entnum = getentnum(curpath, persec))) {
+ warning(-1, curpath);
X restorefile(tmpdir, path, fnamp);
SHAR_EOF
: || $echo 'restore of' 'FD-2.08b.patch' 'failed'
fi
$echo 'End of' 'FD-2.08b.patch' 'part' '1'
$echo 'File' 'FD-2.08b.patch' 'is continued in part' '2'
echo 2 > _sh03503/seq
exit 0
--
しらい たかし
Fnews-brouse 1.9(20180406) -- by Mizuno, MWE <mwe@ccsf.jp>
GnuPG Key ID = ECC8A735
GnuPG Key fingerprint = 9BE6 B9E9 55A5 A499 CD51 946E 9BDC 7870 ECC8 A735