しらいです。

 file & directory 管理ツール FDclone 2.08e の patch その 1
です。

Submitted-by: shirai@chandra2
Archive-name: FD-2.08e.patch/part01

---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is FD-2.08e.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-07-28 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
# ------ ---------- ------------------------------------------
# 236466 -rw-r--r-- FD-2.08e.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 _sh01537; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
if test -r _sh01537/seq; then
  $echo 'Must unpack archives in sequence!'
  $echo 'Please unpack part' '`cat _sh01537/seq`' 'next!'
  exit 1
fi
# ============= FD-2.08e.patch ==============
if test -f 'FD-2.08e.patch' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'FD-2.08e.patch' '(file already exists)'
  rm -f _sh01537/new
else
  > _sh01537/new
  $echo 'x -' extracting 'FD-2.08e.patch' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'FD-2.08e.patch' &&
diff -urNP ../FD-2.08d/HISTORY ./HISTORY
--- ../FD-2.08d/HISTORY Tue Jun 13 00:00:00 2006
+++ ./HISTORY   Fri Jul 28 00:00:00 2006
@@ -1,3 +1,13 @@
+Ver. 2.08e     カスタマイザの ANSIPALETTE 項目をメニュー化。
+ (07/28/06)    カスタマイザの PTYMENUKEY 項目をキー入力による設定に変更。
+               カスタマイザで EDITOR, PAGER 等の内部変数を設定できるよう修正。
+               SORTTYPE の設定が即座に反映されない点を修正。
+               sparc64 環境で異常終了する点を修正。
+               PTYMODE=1 時に UTF8 環境でカーソル位置がおかしくなる点を修正。
+               書込み権のないディレクトリコピー/移動に失敗する点を修正。
+               ドライブ名を冠したファイル名補完に失敗していた点を修正。
+               SFN 表記のディレクトリタイムスタンプ変更失敗を修正。(MS-DOS 版)
+
X Ver. 2.08d    疑似端末のコマンドラインから日本語入力できなかった点を修正。
X  (06/13/06)   コマンドラインから仮名入力できなかった点を修正。
X               履歴インクリメンタルサーチ時の表示がおかしかった点を修正。
@@ -23,7 +33,7 @@
X  (02/07/06)   PTYINKCODE の設定がうまく機能していなかった点を修正。
X               varargs を用いる環境で compile に失敗していた点を修正。
X               sgtty を用いる環境で compile に失敗していた点を修正。
-               端末名未登録時に fdsh でキー入力出来なかった点を修正。
+               端末名未登録時に fdsh でキー入力できなかった点を修正。
X               組込みコマンド echo が DEFKCODE を見ていなかった点を修正。
X 
X Ver. 2.08     内部変数 PTYINKCODE, PTYOUTKCODE の追加。
@@ -40,7 +50,7 @@
X 
X Ver. 2.07c    重複するパス名デリミタで終わるアーカイバ出力に対応。
X  (12/13/05)   fdsh から fd を起動する際の引数が重複評価されていた点を修正。
-               カスタマイザで FNAMEKCODE に HEX/CAP を定義出来ない点を修正。
+               カスタマイザで FNAMEKCODE に HEX/CAP を定義できない点を修正。
X               選択メニューで画面が崩れることがある点を修正。
X               PTYMODE=1 時の LANGUAGE 値の動的変更対応ミスを修正。
X               fdsh を -N オプション付きで起動すると異常終了する点を修正。
@@ -53,7 +63,7 @@
X Ver. 2.07a    表示すべきファイルがない時に画面が更新されない不具合を修正。
X  (06/22/05)   Darwin (Mac OS X) 環境で起動に失敗する点を修正。
X               内蔵シェルで `` に囲まれた \ を評価するように仕様変更。
-               内蔵シェルで新規ファイル記述子へリダイレクト出来ない点を修正。
+               内蔵シェルで新規ファイル記述子へリダイレクトできない点を修正。
X 
X Ver. 2.07     内部変数 PTYMODE, PTYTERM, PTYMENUKEY の追加。
X  (05/26/05)   内部変数 DEFKCODE の追加。
@@ -76,11 +86,11 @@
X Ver. 2.06b    UTF-8 コードによるキー入力に対応。
X  (12/14/04)   全てのファイルサイズを 0 と表示してしまう OS 環境に対応。
X               Cygwin 環境で FDD への無駄なアクセスを抑制。
-               ShiftJIS 環境で一部漢字が入力出来ない点を修正。
+               ShiftJIS 環境で一部漢字が入力できない点を修正。
X 
X Ver. 2.06a    マークファイルへの処理で設問中の interrupt キーを有効に。
X  (09/08/04)   リンク実体が同じファイルへのコピーが失敗していた点を修正。
-               シンボリックリンクの上書きコピーが出来なかった点を修正。
+               シンボリックリンクの上書きコピーができなかった点を修正。
X               日本語文字列を含むマクロ展開に失敗していた点を修正。
X               実体の無いシンボリックリンク名補完に失敗していた点を修正。
X               ファイル移動のキャンセル時にカーソル位置が移動する点を修正。
@@ -102,7 +112,7 @@
X               UNIX 版から組込みコマンド mkdir/rmdir を削除。
X               SIGSTOP/SIGCONT を独自に操作する kernel に対応。
X 
-Ver. 2.05f     「\」で終わるコマンド行を正しく処理出来ない点を修正。
+Ver. 2.05f     「\」で終わるコマンド行を正しく処理できない点を修正。
X  (06/23/04)   アーカイブブラウザでマークがある時のランチャ起動ミスを修正。
X               USEGETCURSOR が機能していなかった点を修正。
X               起動オプション -r が効いていなかった点を修正。
@@ -126,7 +136,7 @@
X 
X Ver. 2.05b    文字列入力時に InsLine キーで異常終了していた点を修正。
X  (01/14/04)   getopt のオプション文字に英小文字しか使えなかった点を修正。
-               EUC 環境で片仮名キーにキー割当て出来なかった点を修正。
+               EUC 環境で片仮名キーにキー割当てできなかった点を修正。
X               16bit OS で初期設定ファイルエラー表示がおかしかった点を修正。
X               CODEEUC 未指定時に文字列入力でカーソルを戻せなかった点を修正。
X               terminfo 環境で端末表示がおかしくなることがある点を修正。
diff -urNP ../FD-2.08d/HISTORY.eng ./HISTORY.eng
--- ../FD-2.08d/HISTORY.eng     Tue Jun 13 00:00:00 2006
+++ ./HISTORY.eng       Fri Jul 28 00:00:00 2006
@@ -1,3 +1,13 @@
+Ver. 2.08e     Support the menu method for 'ANSIPALETTE' on customizer.
+ (07/28/06)    Support the key-input method for 'PTYMENUKEY' on customizer.
+               Support the setting of "EDITOR", "PAGER", etc. on customizer.
+               Bug that the setting of 'SORTTYPE' takes no effect is fixed.
+               Abortion with sparc64 architecture is fixed.
+               Unsuitable cursor position with UTF8 on PTYMODE=1 is fixed.
+               Failure to copy/move the unwritable directory is fixed.
+               Failure to complete the filename with a drive name is fixed.
+               Failure to change timespamp of SFN directory is fixed. (MS-DOS)
+
X Ver. 2.08d    Bug that command line rejects any Japanese on the pty is fixed.
X  (06/13/06)   Bug that command line rejects any Kana is fixed.
X               Mis-indicating for the incremental history search is fixed.
diff -urNP ../FD-2.08d/Makefile.in ./Makefile.in
--- ../FD-2.08d/Makefile.in     Tue Jun 13 00:00:00 2006
+++ ./Makefile.in       Fri Jul 28 00:00:00 2006
@@ -11,7 +11,7 @@
X MANSEC        = 1
X TOPDIR        = $(BUILD)$(PREFIX)
X BINDIR        = $(TOPDIR)/bin
-DATADIR        = $(TOPDIR)/share
+DATADIR        = $(TOPDIR)/share/fd
X MANDIR        = $(TOPDIR)/man/man$(MANSEC)
X CATDIR        = $(TOPDIR)/man/cat$(MANSEC)
X JMANDIR       = $(TOPDIR)/man__LANGDIR__/man$(MANSEC)
@@ -91,7 +91,7 @@
X ALIAS = fdsh
X OBJ1  = main__OBJ__ printf__OBJ__ termio__OBJ__ term__OBJ__ \
X       pathname__OBJ__ system__OBJ__ posixsh__OBJ__ doscom__OBJ__ log__OBJ__
-OBJ2   = dosdisk__OBJ__ __OBJS__ \
+OBJ2   = dosdisk__OBJ__ __EMUOBJS__ \
X       pty__OBJ__ termemu__OBJ__ frontend__OBJ__ backend__OBJ__ \
X       libc__OBJ__ file__OBJ__ apply__OBJ__ \
X       parse__OBJ__ builtin__OBJ__ shell__OBJ__
@@ -134,7 +134,7 @@
X       @$(ECHO) $(OBJ3) >> $(ARGS)
X 
X main__OBJ__: main.c
-       $(CC) $(FDCFLAGS) $(DEFCFLAGS) __UNITBLPATH__ -c __OUT__ $*.c
+       $(CC) $(FDCFLAGS) $(DEFCFLAGS) __TBLPATH__ -c __OUT__ $*.c
X 
X termio__OBJ__: termio.c
X       $(CC) $(FDCFLAGS) __FDSETSIZE__ -c __OUT__ $*.c
@@ -233,6 +233,7 @@
X               $(CHMOD) a+r-x $(BLDRC); \
X       fi
X       -if [ -f $(UNITBL) ]; then \
+               [ -d __DATADIR__ ] || mkdir __DATADIR__; \
X               $(INSTALL) $(UNITBL) __DATADIR__; \
X               $(CHMOD) a+r-x __DATADIR__/$(UNITBL); \
X       fi
@@ -298,7 +299,7 @@
X       makedepend \
X               -s "# DO NOT DELETE THIS LINE -- make depend depends on it." \
X               -f Makefile.tmp -- $(CFLAGS) -- $(SRC)
-       rm -f Makefile.tmp.bak
+       -$(RM) Makefile.tmp.bak
X       $(SED) -e '/^# DO NOT DELETE THIS LINE/,$$d' Makefile.in.bak \
X               > Makefile.in
X       $(ECHO) "# DO NOT DELETE THIS LINE -- make depend depends on it." \
@@ -308,7 +309,8 @@
X               -e 's/\.o/\_\_OBJ\_\_/g' \
X               -e 's/ *$$//' \
X               -e '/: *$$/d' Makefile.tmp >> Makefile.in
-       rm -f Makefile.in.bak Makefile.tmp
+       -$(RM) Makefile.in.bak
+       -$(RM) Makefile.tmp
X 
X 
X ############################################################
@@ -408,11 +410,11 @@
X       gzip -f $(TITLE)sh-$$VER.tar)
X 
X lzh: $(SOURCES)
-       rm -f $(TITLE)$(VERSION).lzh
+       -$(RM) $(TITLE)$(VERSION).lzh
X       lha a $(TITLE)$(VERSION).lzh $(SOURCES)
X 
X shar: $(SOURCES)
-       rm -f $(TITLE)$(VERSION).shar.[0-9][0-9]
+       -$(RM) $(TITLE)$(VERSION).shar.[0-9][0-9]
X       shar -L50 -apc -n $(TITLE)$(VERSION) -o $(TITLE)$(VERSION).shar \
X       -T $(SRCS) -C $(JSRCS)
X 
@@ -505,17 +507,26 @@
X       tar cf ../ipk.tar ./debian-binary ./data.tar.gz ./control.tar.gz)
X       gzip ./ipk.tar
X       mv ./ipk.tar.gz ./fd_$(VERSION)-1_arm.ipk
-       -rm -rf $(IPKWDIR) $(IPKTDIR)
+       -$(RM) -r $(IPKWDIR) $(IPKTDIR)
X 
X clean:
-       -rm -f core *__OBJ__
-       -rm -f funcno.h kanji.h
-       -rm -f kanjicnv$(EXE) expfunc$(EXE)
-       -rm -f mkfuncno$(EXE) mkunitbl$(EXE)
-       -rm -f fdsh$(EXE) fdbsh$(EXE)
-       -rm -f $(PROGRAM)$(EXE) $(PROGRAM).$(MANSEC) $(PROGRAM).$(MANSEC)c
-       -rm -f $(PROGRAM).eng $(PROGRAM).doc
-       -rm -f $(ARGS) __UNITBL__
+       -$(RM) core
+       -$(RM) *__OBJ__
+       -$(RM) funcno.h
+       -$(RM) kanji.h
+       -$(RM) kanjicnv$(EXE)
+       -$(RM) expfunc$(EXE)
+       -$(RM) mkfuncno$(EXE)
+       -$(RM) mkunitbl$(EXE)
+       -$(RM) fdsh$(EXE)
+       -$(RM) fdbsh$(EXE)
+       -$(RM) $(PROGRAM)$(EXE)
+       -$(RM) $(PROGRAM).$(MANSEC)
+       -$(RM) $(PROGRAM).$(MANSEC)c
+       -$(RM) $(PROGRAM).eng
+       -$(RM) $(PROGRAM).doc
+       -$(RM) $(ARGS)
+       -$(RM) __UNITBL__
X # DO NOT DELETE THIS LINE -- make depend depends on it.
X 
X main__OBJ__: fd.h
@@ -529,24 +540,31 @@
X printf__OBJ__: printf.h
X printf__OBJ__: kctype.h
X termio__OBJ__: machine.h config.h
-termio__OBJ__: printf.h termio.h
+termio__OBJ__: printf.h
+termio__OBJ__: termio.h
X term__OBJ__: machine.h config.h
-term__OBJ__: printf.h
-term__OBJ__: kctype.h
+term__OBJ__: printf.h kctype.h
X term__OBJ__: termio.h
X term__OBJ__: term.h
X pathname__OBJ__: machine.h config.h
-pathname__OBJ__: printf.h kctype.h
+pathname__OBJ__: printf.h
+pathname__OBJ__: kctype.h
X pathname__OBJ__: pathname.h
-system__OBJ__: machine.h config.h printf.h kctype.h
+system__OBJ__: machine.h config.h
+system__OBJ__: printf.h
+system__OBJ__: kctype.h
X system__OBJ__: pathname.h
X system__OBJ__: system.h termio.h
X system__OBJ__: wait.h
-posixsh__OBJ__: machine.h config.h printf.h kctype.h
+posixsh__OBJ__: machine.h config.h
+posixsh__OBJ__: printf.h
+posixsh__OBJ__: kctype.h
X posixsh__OBJ__: pathname.h
X posixsh__OBJ__: system.h termio.h
X posixsh__OBJ__: wait.h
-doscom__OBJ__: machine.h config.h printf.h kctype.h
+doscom__OBJ__: machine.h config.h
+doscom__OBJ__: printf.h
+doscom__OBJ__: kctype.h
X doscom__OBJ__: pathname.h
X doscom__OBJ__: system.h termio.h
X doscom__OBJ__: wait.h
@@ -661,9 +679,9 @@
X shell__OBJ__: dosdisk.h kanji.h system.h termio.h
X shell__OBJ__: wait.h
X shell__OBJ__: termemu.h
-kanji__OBJ__: machine.h config.h
-kanji__OBJ__: kctype.h pathname.h
-kanji__OBJ__: term.h
+kanji__OBJ__: machine.h
+kanji__OBJ__: config.h
+kanji__OBJ__: printf.h kctype.h
X input__OBJ__: fd.h
X input__OBJ__: machine.h config.h
X input__OBJ__: types.h
diff -urNP ../FD-2.08d/README ./README
--- ../FD-2.08d/README  Tue Jun 13 00:00:00 2006
+++ ./README    Fri Jul 28 00:00:00 2006
@@ -3,7 +3,7 @@
X #     FDclone Ver. 2.08 に関して
X #
X #     Takashi SHIRAI, <shirai@unixusers.net>
-#      Jun 13, 2006
+#      Jul 28, 2006
X #
X ############################################################
X 
diff -urNP ../FD-2.08d/README.eng ./README.eng
--- ../FD-2.08d/README.eng      Tue Jun 13 00:00:00 2006
+++ ./README.eng        Fri Jul 28 00:00:00 2006
@@ -3,7 +3,7 @@
X #     About FDclone Ver. 2.08
X #
X #     Takashi SHIRAI, <shirai@unixusers.net>
-#      Jun 13, 2006
+#      Jul 28, 2006
X #
X ############################################################
X 
diff -urNP ../FD-2.08d/TECHKNOW ./TECHKNOW
--- ../FD-2.08d/TECHKNOW        Tue Jun 13 00:00:00 2006
+++ ./TECHKNOW  Fri Jul 28 00:00:00 2006
@@ -132,11 +132,11 @@
X       詳細は 2. の項目を参照して下さい。
X 
X NOFILEMACRO
-       cc(1) がマクロ __FILE__ を評価出来ません。
+       cc(1) がマクロ __FILE__ を評価できません。
X NOFUNCMACRO
-       cc(1) がマクロ __FUNCTION__ を評価出来ません。
+       cc(1) がマクロ __FUNCTION__ を評価できません。
X NOLINEMACRO
-       cc(1) がマクロ __LINE__ を評価出来ません。
+       cc(1) がマクロ __LINE__ を評価できません。
X FORCEDSTDC
X       __STDC__ がプリデファインされていないけれども、プロ
X       トタイプ宣言等に ANSI 標準 C の書式を要求する仕様に
@@ -904,6 +904,7 @@
X       _NOEDITMODE     編集モードの代替キー機能が使用不能
X       _NOKANJICONV    漢字コードが動的に変更不能
X       _NOKANJIFCONV   filename の漢字コードが動的に変更不能
+       _NOUNICODE      UNICODE の対応不能
X       _NOENGMES       英語メッセージが表示不能
X       _NOJPNMES       日本語メッセージが表示不能
X       _NOCOLOR        カラー表示機能が使用不能
diff -urNP ../FD-2.08d/TECHKNOW.eng ./TECHKNOW.eng
--- ../FD-2.08d/TECHKNOW.eng    Tue Jun 13 00:00:00 2006
+++ ./TECHKNOW.eng      Fri Jul 28 00:00:00 2006
@@ -953,6 +953,7 @@
X       _NOEDITMODE     cannot use alternative key in edit mode
X       _NOKANJICONV    cannot change kanji code dynamically
X       _NOKANJIFCONV   cannot change filename kanji code dynamically
+       _NOUNICODE      cannot support UNICODE
X       _NOENGMES       cannot display English messages
X       _NOJPNMES       cannot display Japanese messages
X       _NOCOLOR        cannot use color display
@@ -1077,7 +1078,7 @@
X users or processes may not access it, etc.
X 
X 
-10. Browse the Builtin Command
+10.Browse the Builtin Command
X 
X   The manual describes only specifications then this document
X will refer to an usage for browse the builtin command with
diff -urNP ../FD-2.08d/ToAdmin ./ToAdmin
--- ../FD-2.08d/ToAdmin Tue Jun 13 00:00:00 2006
+++ ./ToAdmin   Fri Jul 28 00:00:00 2006
@@ -36,7 +36,7 @@
X ベルは独立して設定できるようになっています。
X  /etc/fd2rc でこのログ設定をしておき、尚且つそれらの設定変
X 数を readonly 属性にしておけば、FDclone 起動後に設定変更によ
-りログを回避することが出来なくなります。
+りログを回避することができなくなります。
X 
X  こういった、root ならではの問題点に対し、きちんと問題意識
X を持って頂き、安易に root 権限で FDclone を起動することがな
diff -urNP ../FD-2.08d/apply.c ./apply.c
--- ../FD-2.08d/apply.c Tue Jun 13 00:00:00 2006
+++ ./apply.c   Fri Jul 28 00:00:00 2006
@@ -58,14 +58,22 @@
X static int NEAR islowerdir __P_((VOID_A));
X static char *NEAR getdestdir __P_((char *, char *));
X static int NEAR getdestpath __P_((char *, char *, struct stat *));
+static int NEAR getcopypolicy __P_((char *));
+static int NEAR getremovepolicy __P_((char *));
X static int NEAR checkdupl __P_((char *, char *, struct stat *, struct stat *));
X static int NEAR checkrmv __P_((char *, int));
+#ifndef        _NOEXTRACOPY
+static int NEAR isxdev __P_((char *, struct stat *));
+#endif
+static VOID NEAR preparecopy __P_((VOID_A));
+static VOID NEAR preparemove __P_((VOID_A));
X static int safecopy __P_((char *));
X static int safemove __P_((char *));
X static int cpdir __P_((char *));
X static int touchdir __P_((char *));
X #ifndef       _NOEXTRACOPY
-static int mvdir __P_((char *));
+static int mvdir1 __P_((char *));
+static int mvdir2 __P_((char *));
X #endif
X static VOID NEAR showmode __P_((attrib_t *, int, int));
X static VOID NEAR showattr __P_((namelist *, attrib_t *, int));
@@ -80,10 +88,10 @@
X static int forcecpdir __P_((char *));
X static int forcetouchdir __P_((char *));
X 
-int copypolicy = 0;
-int removepolicy = 0;
X char *destpath = NULL;
X 
+static int copypolicy = 0;
+static int removepolicy = 0;
X static short attrnlink = 0;
X static u_short attrmode = 0;
X #ifdef        HAVEFLAGS
@@ -96,9 +104,10 @@
X static gid_t attrgid = (gid_t)-1;
X # endif
X #endif        /* !_NOEXTRAATTR */
-static time_t attrtime = 0;
+static time_t attrtime = (time_t)0;
X static char *destdir = NULL;
-static short destnlink = 0;
+static short destnlink = (short)0;
+static u_short destmode = (u_short)0;
X static time_t destmtime = (time_t)-1;
X static time_t destatime = (time_t)-1;
X #ifndef       _NOEXTRACOPY
@@ -263,32 +272,120 @@
X       return(0);
X }
X 
+static int NEAR getcopypolicy(s)
+char *s;
+{
+#if    !defined (_NOEXTRACOPY) && !defined (_NODOSDRIVE)
+       int dupdestdrive;
+#endif
+       char *cp, *str[MAXCOPYITEM];
+       int n, ch, val[MAXCOPYITEM];
+
+       for (;;) {
+               Xlocate(0, L_CMDLINE);
+               Xputterm(L_CLEAR);
+               Xkanjiputs(s);
+
+               str[0] = UPDAT_K;
+               val[0] = CPP_UPDATE;
+               str[1] = RENAM_K;
+               val[1] = CPP_RENAME;
+               str[2] = OVERW_K;
+               val[2] = CPP_OVERWRITE;
+               str[3] = NOCPY_K;
+               val[3] = CPP_NOCOPY;
+#ifndef        _NOEXTRACOPY
+               str[4] = FORWD_K;
+               val[4] = CPP_FORWUPDATE;
+#endif
+
+               n = CPP_UPDATE;
+               ch = selectstr(&n, MAXCOPYITEM, 0, str, val);
+               if (ch == K_ESC) return(CHK_ERROR);
+               else if (ch != K_CR) return(CHK_CANCEL);
+#ifndef        _NOEXTRACOPY
+               if (n == CPP_FORWUPDATE) {
+                       str[0] = UPDAT_K;
+                       str[1] = OVERW_K;
+                       val[0] = CPP_FORWUPDATE;
+                       val[1] = CPP_FORWOVERWRITE;
+                       if (selectstr(&n, 2, 0, str, val) != K_CR) continue;
+# ifndef       _NODOSDRIVE
+                       dupdestdrive = destdrive;
+# endif
+
+                       if (!(cp = getdestdir(FRWDD_K, NULL))) continue;
+# ifndef       _NODOSDRIVE
+                       forwarddrive = destdrive;
+                       destdrive = dupdestdrive;
+# endif
+                       if (issamedir(cp, NULL) || issamedir(cp, destpath)) {
+                               warning(EINVAL, cp);
+                               free(cp);
+                               continue;
+                       }
+                       forwardpath = cp;
+               }
+#endif /* !_NOEXTRACOPY */
+
+               copypolicy = n;
+               break;
+       }
+
+       return(copypolicy);
+}
+
+static int NEAR getremovepolicy(s)
+char *s;
+{
+       char *str[4];
+       int n, ch, val[4];
+
+       Xlocate(0, L_CMDLINE);
+       Xputterm(L_CLEAR);
+       Xkanjiputs(s);
+
+       str[0] = ANYES_K;
+       val[0] = CHK_OK;
+       str[1] = ANNO_K;
+       val[1] = CHK_ERROR;
+       str[2] = ANALL_K;
+       val[2] = RMP_REMOVEALL;
+       str[3] = ANKEP_K;
+       val[3] = RMP_KEEPALL;
+       n = CHK_OK;
+       ch = selectstr(&n, 4, 0, str, val);
+       if (ch == K_ESC) return(CHK_ERROR);
+       else if (ch != K_CR) return(CHK_CANCEL);
+       else if (n <= 0) return(n);
+       removepolicy = n;
+
+       return(removepolicy);
+}
+
X static int NEAR checkdupl(file, dest, stp1, stp2)
X char *file, *dest;
X struct stat *stp1, *stp2;
X {
-       char *cp, *tmp, *str[MAXCOPYITEM];
-       int i, n, ch, val[MAXCOPYITEM];
X #ifndef       _NOEXTRACOPY
X       char path[MAXPATHLEN];
X #endif
-#if    !defined (_NOEXTRACOPY) && !defined (_NODOSDRIVE)
-       int dupdestdrive;
-#endif
+       char *cp, *tmp;
+       int i, n;
X 
-       if (getdestpath(file, dest, stp1) < 0) return(-1);
+       if (getdestpath(file, dest, stp1) < 0) return(CHK_ERROR);
X       if (Xlstat(dest, stp2) < 0) {
X               stp2 -> st_mode = S_IWRITE;
-               if (errno == ENOENT) return(0);
+               if (errno == ENOENT) return(CHK_OK);
X               warning(-1, dest);
-               return(-1);
+               return(CHK_ERROR);
X       }
X       if (!s_isdir(stp2)) n = (copypolicy & ~FLAG_SAMEDIR);
-       else if (!s_isdir(stp1)) n = 2;
+       else if (!s_isdir(stp1)) n = CPP_RENAME;
X #ifdef        _NOEXTRACOPY
-       else return(1);
+       else return(CHK_EXIST);
X #else
-       else if (!(copypolicy & FLAG_SAMEDIR)) return(1);
+       else if (!(copypolicy & FLAG_SAMEDIR)) return(CHK_EXIST);
X       else {
X               n = (copypolicy &= ~FLAG_SAMEDIR);
X               copypolicy = 0;
@@ -296,137 +393,96 @@
X #endif
X 
X       for (;;) {
-               if (!n || n == 2) {
-                       Xlocate(0, L_CMDLINE);
-                       Xputterm(L_CLEAR);
+               if (!n || n == CPP_RENAME) {
X                       cp = SAMEF_K;
X                       i = strlen2(cp) - strsize("%.*s");
X                       cp = asprintf3(cp, n_column - i, dest);
-                       Xkanjiputs(cp);
-                       free(cp);
-               }
-               if (!n) {
-                       str[0] = UPDAT_K;
-                       val[0] = 1;
-                       str[1] = RENAM_K;
-                       val[1] = 2;
-                       str[2] = OVERW_K;
-                       val[2] = 3;
-                       str[3] = NOCPY_K;
-                       val[3] = 4;
-#ifndef        _NOEXTRACOPY
-                       str[4] = FORWD_K;
-                       val[4] = 5;
-#endif
-                       i = 1;
-                       ch = selectstr(&i, MAXCOPYITEM, 0, str, val);
-                       if (ch == K_ESC) return(-1);
-                       else if (ch != K_CR) return(-2);
-#ifndef        _NOEXTRACOPY
-                       if (i == 5) {
-                               str[0] = UPDAT_K;
-                               str[1] = OVERW_K;
-                               val[0] = 5;
-                               val[1] = 6;
-                               if (selectstr(&i, 2, 0, str, val) != K_CR)
-                                       continue;
-# ifndef       _NODOSDRIVE
-                               dupdestdrive = destdrive;
-# endif
-
-                               if (!(tmp = getdestdir(FRWDD_K, NULL)))
-                                       continue;
-# ifndef       _NODOSDRIVE
-                               forwarddrive = destdrive;
-                               destdrive = dupdestdrive;
-# endif
-                               if (issamedir(tmp, NULL)
-                               || issamedir(tmp, destpath)) {
-                                       warning(EINVAL, tmp);
-                                       free(tmp);
-                                       continue;
-                               }
-                               forwardpath = tmp;
+                       if (!n) n = getcopypolicy(cp);
+                       else {
+                               Xlocate(0, L_CMDLINE);
+                               Xputterm(L_CLEAR);
+                               Xkanjiputs(cp);
X                       }
-#endif /* !_NOEXTRACOPY */
-                       copypolicy = n = i;
+                       free(cp);
+                       if (n < 0) return(n);
X               }
X               switch (n) {
-                       case 1:
+                       case CPP_UPDATE:
X                               if (stp1 -> st_mtime < stp2 -> st_mtime)
-                                       return(-1);
-                               return(2);
+                                       return(CHK_ERROR);
+                               return(CHK_EXIST);
X /*NOTREACHED*/
X                               break;
-                       case 2:
+                       case CPP_RENAME:
X                               lcmdline = L_INFO;
X                               tmp = inputstr(NEWNM_K, 1, -1, NULL, -1);
-                               if (!tmp) return(-1);
+                               if (!tmp) return(CHK_ERROR);
X                               strcpy(getbasename(dest), tmp);
X                               free(tmp);
X                               if (Xlstat(dest, stp2) < 0) {
X                                       stp2 -> st_mode = S_IWRITE;
-                                       if (errno == ENOENT) return(0);
+                                       if (errno == ENOENT) return(CHK_OK);
X                                       warning(-1, dest);
-                                       return(-1);
+                                       return(CHK_ERROR);
X                               }
-                               if (s_isdir(stp1) && s_isdir(stp2)) return(1);
+                               if (s_isdir(stp1) && s_isdir(stp2))
+                                       return(CHK_EXIST);
X                               Xputterm(T_BELL);
X                               break;
-                       case 3:
-                               return(2);
+                       case CPP_OVERWRITE:
+                               return(CHK_OVERWRITE);
X /*NOTREACHED*/
X                               break;
X #ifndef       _NOEXTRACOPY
-                       case 5:
+                       case CPP_FORWUPDATE:
X                               if (stp1 -> st_mtime < stp2 -> st_mtime)
-                                       return(-1);
+                                       return(CHK_ERROR);
X /*FALLTHRU*/
-                       case 6:
+                       case CPP_FORWOVERWRITE:
X                               strcatdelim2(path, forwardpath, file);
X                               cp = strrdelim(path, 0);
X                               *cp = '\0';
X                               if (mkdir2(path, 0777) < 0
X                               && errno != EEXIST) {
X                                       warning(-1, path);
-                                       return(-1);
+                                       return(CHK_ERROR);
X                               }
X                               *cp = _SC_;
X                               if (safemvfile(dest, path, stp2, NULL) < 0) {
X                                       warning(-1, path);
-                                       return(-1);
+                                       return(CHK_ERROR);
X                               }
-                               return(2);
+                               return(CHK_OVERWRITE);
X /*NOTREACHED*/
X                               break;
X #endif        /* !_NOEXTRACOPY */
X                       default:
-                               return(-1);
+                               return(CHK_ERROR);
X /*NOTREACHED*/
X                               break;
X               }
X       }
X 
X /*NOTREACHED*/
-       return(0);
+       return(CHK_OK);
X }
X 
X static int NEAR checkrmv(path, mode)
X char *path;
X int mode;
X {
-       char *cp, *str[4];
-       int ch, len, val[4];
+       char *cp;
+       int n, len;
X #if   MSDOS
X 
-       if (Xaccess(path, mode) >= 0) return(0);
+       if (Xaccess(path, mode) >= 0) return(CHK_OK);
X #else /* !MSDOS */
X       struct stat *stp, st;
X       char *tmp, dir[MAXPATHLEN];
X 
X # ifndef      _NODOSDRIVE
X       if (dospath2(path)) {
-               if (Xaccess(path, mode) >= 0) return(0);
+               if (Xaccess(path, mode) >= 0) return(CHK_OK);
X               stp = NULL;
X       }
X       else
@@ -434,9 +490,9 @@
X       {
X               if (nodoslstat(path, &st) < 0) {
X                       warning(-1, path);
-                       return(-1);
+                       return(CHK_ERROR);
X               }
-               if (s_islnk(&st)) return(0);
+               if (s_islnk(&st)) return(CHK_OK);
X 
X               if (!(tmp = strrdelim(path, 0))) copycurpath(dir);
X               else if (tmp == path) copyrootpath(dir);
@@ -444,17 +500,19 @@
X 
X               if (nodoslstat(dir, &st) < 0) {
X                       warning(-1, dir);
-                       return(-1);
+                       return(CHK_ERROR);
X               }
-               if (Xaccess(path, mode) >= 0) return(0);
+               if (Xaccess(path, mode) >= 0) return(CHK_OK);
X               stp = &st;
X       }
X #endif        /* !MSDOS */
-       if (errno == ENOENT) return(0);
+
+       if (errno == ENOENT) return(CHK_OK);
X       if (errno != EACCES) {
X               warning(-1, path);
-               return(-1);
+               return(CHK_ERROR);
X       }
+
X #if   !MSDOS
X       if (stp) {
X               int duperrno;
@@ -469,31 +527,63 @@
X               if (!(mode & F_ISWRI)) {
X                       errno = duperrno;
X                       warning(-1, path);
-                       return(-1);
+                       return(CHK_ERROR);
X               }
X       }
X #endif        /* !MSDOS */
-       if (removepolicy > 0) return(removepolicy - 2);
-       Xlocate(0, L_CMDLINE);
-       Xputterm(L_CLEAR);
-       cp = DELPM_K;
-       len = strlen2(cp) - strsize("%.*s");
-       cp = asprintf3(cp, n_column - len, path);
-       Xkanjiputs(cp);
-       free(cp);
-       str[0] = ANYES_K;
-       str[1] = ANNO_K;
-       str[2] = ANALL_K;
-       str[3] = ANKEP_K;
-       val[0] = 0;
-       val[1] = -1;
-       val[2] = 2;
-       val[3] = 1;
-       ch = selectstr(&removepolicy, 4, 0, str, val);
-       if (ch == K_ESC) removepolicy = -1;
-       else if (ch != K_CR) removepolicy = -2;
X 
-       return((removepolicy > 0) ? removepolicy - 2 : removepolicy);
+       if (removepolicy > 0) n = removepolicy;
+       else {
+               cp = DELPM_K;
+               len = strlen2(cp) - strsize("%.*s");
+               cp = asprintf3(cp, n_column - len, path);
+               n = getremovepolicy(cp);
+               free(cp);
+       }
+       if (n > 0) n -= RMP_BIAS;
+
+       return(n);
+}
+
+#ifndef        _NOEXTRACOPY
+/*ARGSUSED*/
+static int NEAR isxdev(path, stp)
+char *path;
+struct stat *stp;
+{
+# if   !MSDOS
+       struct stat st1, st2;
+# endif
+
+# ifdef        _USEDOSPATH
+       if (dospath(path, NULL) != dospath(destpath, NULL)) {
+               if (stp && Xlstat(path, stp) < 0) return(-1);
+               return(1);
+       }
+# endif
+
+# if   !MSDOS
+       if (!stp) stp = &st1;
+       if (Xlstat(path, stp) < 0 || Xlstat(destpath, &st2) < 0) return(-1);
+       if (stp -> st_dev != st2.st_dev) return(1);
+# endif
+
+       return(0);
+}
+#endif /* !_NOEXTRACOPY */
+
+static VOID NEAR preparecopy(VOID_A)
+{
+       copypolicy = (issamedir(destpath, NULL))
+               ? (FLAG_SAMEDIR | CPP_RENAME) : 0;
+#ifndef        _NODOSDRIVE
+       if (dospath3(nullstr)) waitmes();
+#endif
+}
+
+static VOID NEAR preparemove(VOID_A)
+{
+       copypolicy = removepolicy = 0;
X }
X 
X static int safecopy(path)
@@ -504,10 +594,10 @@
X       int n;
X 
X       if ((n = checkdupl(path, dest, &st1, &st2)) < 0)
-               return((n < -1) ? -2 : 1);
-       if (safecpfile(path, dest, &st1, &st2) < 0) return(-1);
+               return((n == CHK_CANCEL) ? APL_CANCEL : APL_IGNORE);
+       if (safecpfile(path, dest, &st1, &st2) < 0) return(APL_ERROR);
X 
-       return(0);
+       return(APL_OK);
X }
X 
X static int safemove(path)
@@ -519,10 +609,10 @@
X 
X       if ((n = checkdupl(path, dest, &st1, &st2)) < 0
X       || (n = checkrmv(path, W_OK)) < 0)
-               return((n < -1) ? -2 : 1);
-       if (safemvfile(path, dest, &st1, &st2) < 0) return(-1);
+               return((n == CHK_CANCEL) ? APL_CANCEL : APL_IGNORE);
+       if (safemvfile(path, dest, &st1, &st2) < 0) return(APL_ERROR);
X 
-       return(0);
+       return(APL_OK);
X }
X 
X static int cpdir(path)
@@ -531,95 +621,129 @@
X       struct stat st1, st2;
X       char dest[MAXPATHLEN];
X 
-       destnlink = (TCH_MODE | TCH_UID | TCH_GID);
X       switch (checkdupl(path, dest, &st1, &st2)) {
-               case 2:
+               case CHK_OVERWRITE:
X               /* Already exist, but not directory */
-                       if (Xunlink(dest) < 0) return(-1);
+                       if (Xunlink(dest) < 0) return(APL_ERROR);
X /*FALLTHRU*/
-               case 0:
+               case CHK_OK:
X               /* Not exist */
-#if    MSDOS
-                       if (Xmkdir(dest, (st1.st_mode & 0777) | S_IWRITE) < 0)
-#else
X                       if (Xmkdir(dest, st1.st_mode & 0777) < 0)
-#endif
-                               return(-1);
-                       destnlink |= (TCH_ATIME | TCH_MTIME);
+                               return(APL_ERROR);
+                       destnlink = (TCH_UID | TCH_GID
+                               | TCH_ATIME | TCH_MTIME);
+                       destmode = st1.st_mode;
X                       destmtime = st1.st_mtime;
X                       destatime = st1.st_atime;
X                       break;
-               case -1:
-               case -2:
+               case CHK_ERROR:
+               case CHK_CANCEL:
X               /* Abandon copy */
-                       return(-2);
+                       return(APL_CANCEL);
X /*NOTREACHED*/
X                       break;
X               default:
X               /* Already exist */
-                       destnlink |= (TCH_ATIME | TCH_MTIME);
+                       destnlink = (TCH_ATIME | TCH_MTIME);
+                       destmode = st2.st_mode;
X                       destmtime = st2.st_mtime;
X                       destatime = st2.st_atime;
X                       break;
X       }
X 
+       if (!(destmode & S_IWRITE)) {
+               st1.st_nlink = TCH_MODE;
+               st1.st_mode = (destmode | S_IWRITE);
+               if (touchfile(dest, &st1) >= 0) destnlink |= TCH_MODE;
+       }
+
X       if (destdir) free(destdir);
X       destdir = &(dest[strlen(destpath)]);
X       while (*destdir == _SC_) destdir++;
X       destdir = strdup2(destdir);
X 
-       return(0);
+       return(APL_OK);
X }
X 
X /*ARGSUSED*/
X static int touchdir(path)
X char *path;
X {
-#if    defined (_USEDOSCOPY) || !defined (_NOEXTRACOPY)
X       struct stat st;
X       char dest[MAXPATHLEN];
X 
-# if   !defined (_USEDOSCOPY)
-       if (!inheritcopy) return(0);
-# endif
-       if (getdestpath(path, dest, &st) < 0) return(-2);
+       if (getdestpath(path, dest, &st) < 0) return(APL_CANCEL);
X       st.st_nlink = destnlink;
+       st.st_mode = destmode;
X       st.st_mtime = destmtime;
X       st.st_atime = destatime;
-       if (touchfile(dest, &st) < 0) return(-1);
-#endif /* _USEDOSCOPY || !_NOEXTRACOPY */
+#ifndef        _USEDOSCOPY
+# ifndef       _NOEXTRACOPY
+       if (inheritcopy) /*EMPTY*/;
+       else
+# endif
+       st.st_nlink &= ~(TCH_ATIME | TCH_MTIME);
+#endif /* !_USEDOSCOPY */
+       if (touchfile(dest, &st) < 0) return(APL_ERROR);
X 
-       return(0);
+       return(APL_OK);
X }
X 
X #ifndef       _NOEXTRACOPY
-static int mvdir(path)
+static int mvdir1(path)
X char *path;
X {
X       struct stat st;
-       char dest[MAXPATHLEN];
X       int n;
X 
-       if (getdestpath(path, dest, &st) < 0) return(-2);
+       if ((n = checkrmv(path, R_OK | W_OK | X_OK)) < 0) {
+               errno = EACCES;
+               return((n == CHK_CANCEL) ? APL_CANCEL : APL_ERROR);
+       }
+       if ((n = cpdir(path)) < 0) return(n);
+       if (Xlstat(path, &st) < 0) return(APL_ERROR);
+       if (!(st.st_mode & S_IWRITE)) {
+               st.st_nlink = TCH_MODE;
+               st.st_mode |= S_IWRITE;
+               if (touchfile(path, &st) < 0) return(APL_ERROR);
+       }
+
+       return(n);
+}
+
+static int mvdir2(path)
+char *path;
+{
+       struct stat st;
+       char dest[MAXPATHLEN];
+
+       if (getdestpath(path, dest, &st) < 0) return(APL_CANCEL);
X       st.st_nlink = destnlink;
+       st.st_mode = destmode;
X       st.st_mtime = destmtime;
X       st.st_atime = destatime;
-       if (touchfile(dest, &st) < 0) return(-1);
-       if ((n = checkrmv(path, R_OK | W_OK | X_OK)) < 0)
-               return((n < -1) ? -2 : 1);
+       if (touchfile(dest, &st) < 0) return(APL_ERROR);
+       if (Xrmdir(path) < 0) return(APL_ERROR);
X 
-       return(Xrmdir(path));
+       return(APL_OK);
X }
X #endif        /* !_NOEXTRACOPY */
X 
+VOID prepareremove(VOID_A)
+{
+       removepolicy = 0;
+}
+
X int rmvfile(path)
X char *path;
X {
X       int n;
X 
-       if ((n = checkrmv(path, W_OK)) < 0) return((n < -1) ? -2 : 1);
+       if ((n = checkrmv(path, W_OK)) < 0)
+               return((n == CHK_CANCEL) ? APL_CANCEL : APL_IGNORE);
+       if (Xunlink(path) < 0) return(APL_ERROR);
X 
-       return(Xunlink(path));
+       return(APL_OK);
X }
X 
X int rmvdir(path)
@@ -628,9 +752,10 @@
X       int n;
X 
X       if ((n = checkrmv(path, R_OK | W_OK | X_OK)) < 0)
-               return((n < -1) ? -2 : 1);
+               return((n == CHK_CANCEL) ? APL_CANCEL : APL_IGNORE);
+       if (Xrmdir(path) < 0) return(APL_ERROR);
X 
-       return(Xrmdir(path));
+       return(APL_OK);
X }
X 
X int findfile(path)
@@ -643,11 +768,11 @@
X               Xcprintf2("[%.*k]", n_column - 2, path);
X               if (yesno(FOUND_K)) {
X                       destpath = strdup2(path);
-                       return(-2);
+                       return(APL_CANCEL);
X               }
X       }
X 
-       return(0);
+       return(APL_OK);
X }
X 
X int finddir(path)
@@ -656,11 +781,11 @@
X       if (regexp_exec(findregexp, getbasename(path), 1)) {
X               if (yesno(FOUND_K)) {
X                       destpath = strdup2(path);
-                       return(-2);
+                       return(APL_CANCEL);
X               }
X       }
X 
-       return(0);
+       return(APL_OK);
X }
X 
X static VOID NEAR showmode(attr, x, y)
@@ -1272,8 +1397,9 @@
X # endif
X #endif        /* !_NOEXTRAATTR */
X       st.st_mtime = attrtime;
+       if (touchfile(path, &st) < 0) return(APL_ERROR);
X 
-       return(touchfile(path, &st));
+       return(APL_OK);
X }
X 
X int applyfile(func, endmes)
@@ -1290,8 +1416,8 @@
X 
X       if (mark <= 0) {
X               i = (*func)(fnodospath(path, filepos));
-               if (i == -1) warning(-1, filelist[filepos].name);
-               else if (!i) ret++;
+               if (i == APL_ERROR) warning(-1, filelist[filepos].name);
+               else if (i == APL_OK) ret++;
X               return(ret);
X       }
X 
@@ -1307,12 +1433,12 @@
X               Xlocate(win_x, win_y);
X               Xtflush();
X               i = (*func)(fnodospath(path, filepos));
-               if (i < -1) {
+               if (i == APL_CANCEL) {
X                       endmes = NULL;
X                       break;
X               }
-               if (i < 0) warning(-1, filelist[filepos].name);
-               else if (!i && ret == filepos) ret++;
+               else if (i == APL_ERROR) warning(-1, filelist[filepos].name);
+               else if (i == APL_OK && ret == filepos) ret++;
X 
X               old = filepos;
X       }
@@ -1369,10 +1495,11 @@
X       struct dirent *dp;
X       struct stat st;
X       time_t dupmtime, dupatime;
+       u_short dupmode;
X       char *cp, *fname, path[MAXPATHLEN], **dirlist;
X       int ret, ndir, max, dupnlink;
X 
-       if (intrkey()) return(-2);
+       if (intrkey()) return(APL_CANCEL);
X 
X       if (verbose) {
X               Xlocate(0, L_CMDLINE);
@@ -1388,7 +1515,8 @@
X       if (!funcd1) order = (funcd2) ? ORD_NOPREDIR : ORD_NODIR;
X       strcpy(path, dir);
X 
-       ret = max = 0;
+       ret = APL_OK;
+       max = 0;
X       if (!order) dirlist = NULL;
X       else dirlist = getdirtree(path,
X               NULL, &max, (order == ORD_LOWER) ? 0 : 1);
@@ -1397,7 +1525,7 @@
X       destnlink = 0;
X       if ((order == ORD_NORMAL || order == ORD_LOWER)
X       && (ret = (*funcd1)(dir)) < 0) {
-               if (ret == -1) warning(-1, dir);
+               if (ret == APL_ERROR) warning(-1, dir);
X               if (dirlist) {
X                       for (ndir = 0; ndir < max; ndir++) free(dirlist[ndir]);
X                       free(dirlist);
@@ -1405,6 +1533,7 @@
X               return(ret);
X       }
X       dupnlink = destnlink;
+       dupmode = destmode;
X       dupmtime = destmtime;
X       dupatime = destatime;
X 
@@ -1413,12 +1542,12 @@
X                       ret = _applydir(dirlist[ndir], funcf,
X                               funcd1, funcd2, order, NULL, verbose);
X               else if ((ret = (*funcd1)(dirlist[ndir])) < 0) {
-                       if (ret == -1) warning(-1, dir);
-                       ret = -2;
+                       if (ret == APL_ERROR) warning(-1, dir);
+                       ret = APL_CANCEL;
X               }
X               else ret = _applydir(dirlist[ndir], funcf,
X                       funcd1, funcd2, ORD_NODIR, NULL, verbose);
-               if (ret < -1) {
+               if (ret == APL_CANCEL) {
X                       for (; ndir < max; ndir++) free(dirlist[ndir]);
X                       free(dirlist);
X                       return(ret);
@@ -1438,7 +1567,7 @@
X       else {
X               while ((dp = Xreaddir(dirp))) {
X                       if (intrkey()) {
-                               ret = -2;
+                               ret = APL_CANCEL;
X                               break;
X                       }
X                       if (isdotdir(dp -> d_name)) continue;
@@ -1447,19 +1576,20 @@
X                       if (Xlstat(path, &st) < 0) warning(-1, path);
X                       else if (s_isdir(&st)) continue;
X                       else if ((ret = (*funcf)(path)) < 0) {
-                               if (ret < -1) break;
+                               if (ret == APL_CANCEL) break;
X                               warning(-1, path);
X                       }
X               }
X               Xclosedir(dirp);
-               if (ret < -1) return(ret);
+               if (ret == APL_CANCEL) return(ret);
X       }
X 
X       destnlink = dupnlink;
+       destmode = dupmode;
X       destmtime = dupmtime;
X       destatime = dupatime;
X       if (funcd2 && (ret = (*funcd2)(dir)) < 0) {
-               if (ret < -1) return(ret);
+               if (ret == APL_CANCEL) return(ret);
X               warning(-1, dir);
X       }
X       if (endmes) warning(0, endmes);
@@ -1517,23 +1647,22 @@
X 
X       if (!destpath) return((tr) ? FNC_UPDATE : FNC_CANCEL);
X       destdir = NULL;
-       copypolicy = (issamedir(destpath, NULL)) ? (FLAG_SAMEDIR | 2) : 0;
-#ifndef        _NODOSDRIVE
-       if (dospath3(nullstr)) waitmes();
-#endif
X       if (mark > 0
-       || (!isdir(&(filelist[filepos])) || islink(&(filelist[filepos]))))
-               applyfile(safecopy, ENDCP_K);
-       else {
+       || (!isdir(&(filelist[filepos])) || islink(&(filelist[filepos])))) {
+               preparecopy();
+               VOID_C applyfile(safecopy, ENDCP_K);
+       }
X #ifdef        _NOEXTRACOPY
-               if (copypolicy) {
-                       warning(EEXIST, filelist[filepos].name);
-                       free(destpath);
-                       return((tr) ? FNC_UPDATE : FNC_CANCEL);
-               }
+       else if (issamedir(destpath, NULL)) {
+               warning(EEXIST, filelist[filepos].name);
+               free(destpath);
+               return((tr) ? FNC_UPDATE : FNC_CANCEL);
+       }
X #endif
+       else {
+               preparecopy();
X               order = (islowerdir()) ? ORD_LOWER : ORD_NORMAL;
-               applydir(filelist[filepos].name, safecopy,
+               VOID_C applydir(filelist[filepos].name, safecopy,
X                       cpdir, touchdir, order, ENDCP_K);
X       }
X 
@@ -1565,7 +1694,7 @@
X #ifndef       _NOEXTRACOPY
X       int order;
X #endif
-       int i;
+       int ret;
X 
X       if (!mark && isdotdir(filelist[filepos].name)) {
X               Xputterm(T_BELL);
@@ -1581,32 +1710,42 @@
X # endif
X #endif        /* !_NOTREE */
X 
-       if (!destpath || issamedir(destpath, NULL))
+       if (!destpath) return((tr) ? FNC_UPDATE : FNC_CANCEL);
+       if (issamedir(destpath, NULL)) {
+               free(destpath);
X               return((tr) ? FNC_UPDATE : FNC_CANCEL);
+       }
X       destdir = NULL;
-       copypolicy = removepolicy = 0;
-       if (mark > 0) filepos = applyfile(safemove, ENDMV_K);
+       if (mark > 0) {
+               preparemove();
+               filepos = applyfile(safemove, ENDMV_K);
+       }
X       else if (islowerdir()) warning(EINVAL, filelist[filepos].name);
X       else {
-               i = safemove(fnodospath(path, filepos));
-               if (!i) filepos++;
-               else if (i == -1) {
-#ifdef _NOEXTRACOPY
-                       warning(-1, filelist[filepos].name);
-#else  /* !_NOEXTRACOPY */
-                       if (errno != EXDEV
-                       || !isdir(&(filelist[filepos]))
-                       || islink(&(filelist[filepos])))
-                               warning(-1, filelist[filepos].name);
-                       else {
-                               order = (islowerdir())
-                                       ? ORD_LOWER : ORD_NORMAL;
-                               i = applydir(filelist[filepos].name, safemove,
-                                       cpdir, mvdir, order, ENDMV_K);
-                               if (i >= 0) filepos++;
-                       }
+#ifndef        _NOEXTRACOPY
+               if (!isdir(&(filelist[filepos]))
+               || islink(&(filelist[filepos])))
+                       ret = 0;
+               else ret = isxdev(fnodospath(path, filepos), NULL);
+               if (ret < 0) warning(-1, filelist[filepos].name);
+               else if (ret) {
+                       preparemove();
+# ifndef       _NODOSDRIVE
+                       if (dospath3(nullstr)) waitmes();
+# endif
+                       order = (islowerdir()) ? ORD_LOWER : ORD_NORMAL;
+                       ret = applydir(filelist[filepos].name, safemove,
+                               mvdir1, mvdir2, order, ENDMV_K);
+               }
+               else
X #endif        /* !_NOEXTRACOPY */
+               {
+                       preparemove();
+                       ret = safemove(fnodospath(path, filepos));
+                       if (ret == APL_ERROR)
+                               warning(-1, filelist[filepos].name);
X               }
+               if (ret == APL_OK) filepos++;
X       }
X 
X       if (filepos >= maxfile) filepos = maxfile - 1;
@@ -1633,14 +1772,16 @@
X       struct stat st;
X       char dest[MAXPATHLEN];
X 
-       if (getdestpath(path, dest, &st) < 0) return(0);
-       if (safecpfile(path, dest, &st, NULL) < 0) return(-1);
+       if (getdestpath(path, dest, &st) < 0) return(APL_OK);
+       if (safecpfile(path, dest, &st, NULL) < 0) return(APL_ERROR);
X #ifdef        HAVEFLAGS
X       st.st_flags = (u_long)-1;
X #endif
X 
X       st.st_nlink = (TCH_MODE | TCH_UID | TCH_GID | TCH_ATIME | TCH_MTIME);
-       return(touchfile(dest, &st));
+       if (touchfile(dest, &st) < 0) return(APL_ERROR);
+
+       return(APL_OK);
X }
X 
X static int forcecpdir(path)
@@ -1650,22 +1791,20 @@
X       char dest[MAXPATHLEN];
X       int mode;
X 
-       if (isdotdir(path)) return(0);
-       if (getdestpath(path, dest, &st) < 0) return(0);
-       mode = (st.st_mode & 0777);
-#if    MSDOS
-       mode |= S_IWRITE;
-#endif
-       if (Xmkdir(dest, mode) >= 0) return(0);
-       if (errno != EEXIST) return(-1);
+       if (isdotdir(path)) return(APL_OK);
+       if (getdestpath(path, dest, &st) < 0) return(APL_OK);
+       mode = ((st.st_mode & 0777) | S_IWRITE);
+       if (Xmkdir(dest, mode) >= 0) return(APL_OK);
+       if (errno != EEXIST) return(APL_ERROR);
X       if (stat2(dest, &st) >= 0) {
-               if (s_isdir(&st)) return(0);
-               if (Xunlink(dest) >= 0 && Xmkdir(dest, mode) >= 0) return(0);
+               if (s_isdir(&st)) return(APL_OK);
+               if (Xunlink(dest) >= 0 && Xmkdir(dest, mode) >= 0)
+                       return(APL_OK);
X       }
X 
X       errno = EEXIST;
X 
-       return(-1);
+       return(APL_ERROR);
X }
X 
X static int forcetouchdir(path)
@@ -1674,14 +1813,16 @@
X       struct stat st;
X       char dest[MAXPATHLEN];
X 
-       if (isdotdir(path)) return(0);
-       if (getdestpath(path, dest, &st) < 0) return(-2);
+       if (isdotdir(path)) return(APL_OK);
+       if (getdestpath(path, dest, &st) < 0) return(APL_CANCEL);
X #ifdef        HAVEFLAGS
X       st.st_flags = (u_long)-1;
X #endif
X 
X       st.st_nlink = (TCH_MODE | TCH_UID | TCH_GID | TCH_ATIME | TCH_MTIME);
-       return(touchfile(dest, &st));
+       if (touchfile(dest, &st) < 0) return(APL_ERROR);
+
+       return(APL_OK);
X }
X 
X int forcemovefile(dest)
@@ -1690,7 +1831,8 @@
X       int ret;
X 
X       destpath = dest;
-       ret = applydir(NULL, forcecpfile, forcecpdir, forcetouchdir, 1, NULL);
+       ret = applydir(NULL, forcecpfile,
+               forcecpdir, forcetouchdir, ORD_NORMAL, NULL);
X       destpath = NULL;
X 
X       return(ret);
diff -urNP ../FD-2.08d/archive.c ./archive.c
--- ../FD-2.08d/archive.c       Tue Jun 13 00:00:00 2006
+++ ./archive.c Fri Jul 28 00:00:00 2006
@@ -2195,12 +2195,19 @@
X char *path, *file, *full, *tmpdir;
X #endif
X {
+#if    MSDOS
+       int drive;
+#endif
X       char *cp;
X 
X       cp = file;
X #ifdef        _USEDOSPATH
+# if   MSDOS
+       if ((drive = _dospath(cp))) cp += 2;
+# else
X       if (_dospath(cp)) cp += 2;
-#endif
+# endif
+#endif /* _USEDOSPATH */
X 
X #ifndef       _NODOSDRIVE
X       if (tmpdir) strcpy(path, tmpdir);
@@ -2215,16 +2222,11 @@
X               return(NULL);
X       }
X #if   MSDOS
-       else if (cp > file) {
-               int drive;
-
-               path[0] = *file;
-               path[1] = ':';
-               path[2] = _SC_;
-               if ((drive = toupper2(*file)) == toupper2(*full))
-                       strcpy(&(path[3]), &(full[3]));
-               else if (!unixgetcurdir(&(path[3]), drive - 'A' + 1))
-                       return(NULL);
+       else if (drive) {
+               file = gendospath(path, drive, _SC_);
+               drive = toupper2(drive);
+               if (drive == toupper2(*full)) strcpy(file, &(full[3]));
+               else if (!unixgetcurdir(file, drive - 'A' + 1)) return(NULL);
X       }
X #endif
X       else strcpy(path, full);
@@ -2353,7 +2355,7 @@
X       if (tmpdest) {
X               if (!ret) {
X                       if (_chdir2(tmpdest) < 0) ret = 1;
-                       else forcemovefile(dest);
+                       else VOID_C forcemovefile(dest);
X               }
X               free(dest);
X               removetmp(tmpdest, NULL);
@@ -2501,7 +2503,7 @@
X 
X #ifndef       _NODOSDRIVE
X       if (tmpdest) {
-               if (!ret) forcemovefile(dest);
+               if (!ret) VOID_C forcemovefile(dest);
X               free(dest);
X               removetmp(tmpdest, NULL);
X       }
diff -urNP ../FD-2.08d/backend.c ./backend.c
--- ../FD-2.08d/backend.c       Tue Jun 13 00:00:00 2006
+++ ./backend.c Fri Jul 28 00:00:00 2006
@@ -47,6 +47,7 @@
X #define       A_BLINK         00010
X #define       A_STANDOUT      00020
X #define       A_UNDERLINE     00040
+#define        A_INVISIBLE     00100
X #define       T_NOAUTOMARGIN  00001
X #define       T_MULTIBYTE     00002
X #define       T_NOAPPLIKEY    00004
@@ -419,15 +420,15 @@
X {
X #ifndef       _NOKANJICONV
X       char buf[MAXKANJIBUF + 1], buf2[MAXKANJIBUF + 1];
-       int len, code, incode, outcode;
+       u_int u;
+       int incode, outcode;
X #endif
-       int width;
+       int i, width;
X 
X #ifndef       _NOKANJICONV
X       outcode = (outputkcode != NOCNV) ? outputkcode : DEFCODE;
X       incode = (w < MAXWINDOWS && ptylist[w].outcode != NOCNV)
X               ? ptylist[w].outcode : outcode;
-       code = (incode != M_UTF8) ? incode : UTF8;
X #endif
X 
X       if ((pty[w].termflags & T_NOAUTOMARGIN)
@@ -442,16 +443,26 @@
X               else if (pty[w].last1 == C_EKANA) /*EMPTY*/;
X # endif
X #else /* !_NOKANJICONV */
-               else if (code == EUC) {
+               else if (incode == EUC) {
X                       if (pty[w].last1 != C_EKANA) width++;
X               }
-               else if (code == UTF8) {
+               else if (incode >= UTF8) {
X                       if (!ismsb(c)) pty[w].last1 = pty[w].last2 = (short)-1;
-                       else if (pty[w].last2 >= (short)0) width++;
+                       else if (pty[w].last2 >= (short)0) /*EMPTY*/;
X                       else if (!isutf2(pty[w].last1, c)) {
X                               pty[w].last2 = c;
X                               return;
X                       }
+
+                       i = 0;
+                       if (pty[w].last1 >= (short)0) buf[i++] = pty[w].last1;
+                       if (pty[w].last2 >= (short)0) buf[i++] = pty[w].last2;
+                       if (i) {
+                               buf[i++] = c;
+                               buf[i] = '\0';
+                               u = ucs2fromutf8((u_char *)buf, NULL);
+                               if (u < 0xff61 || u > 0xff9f) width++;
+                       }
X               }
X #endif        /* !_NOKANJICONV */
X               else width++;
@@ -464,9 +475,9 @@
X # endif
X #else /* !_NOKANJICONV */
X       else if ((pty[w].termflags & T_MULTIBYTE)
-       || (code == EUC && (c == C_EKANA || iseuc(c)))
-       || (code == SJIS && issjis1(c))
-       || (code == UTF8 && ismsb(c)))
+       || (incode == EUC && (c == C_EKANA || iseuc(c)))
+       || (incode == SJIS && issjis1(c))
+       || (incode >= UTF8 && ismsb(c)))
X #endif        /* !_NOKANJICONV */
X       {
X               pty[w].last1 = c;
@@ -482,21 +493,21 @@
X       surelocate(w, 0);
X       settermattr(w);
X       settermcode(w);
+       if (pty[w].attr & A_INVISIBLE) for (i = 0; i < width; i++) putch2(' ');
X #ifndef       _NOKANJICONV
-       if (!(pty[w].termflags & T_MULTIBYTE) && incode != outcode) {
-               len = 0;
-               if (pty[w].last1 >= (short)0) buf[len++] = pty[w].last1;
-               if (pty[w].last2 >= (short)0) buf[len++] = pty[w].last2;
-               if (!len) putch2(c);
+       else if (!(pty[w].termflags & T_MULTIBYTE) && incode != outcode) {
+               i = 0;
+               if (pty[w].last1 >= (short)0) buf[i++] = pty[w].last1;
+               if (pty[w].last2 >= (short)0) buf[i++] = pty[w].last2;
+               if (!i) putch2(c);
X               else {
-                       buf[len++] = c;
-                       buf[len] = '\0';
+                       buf[i++] = c;
+                       buf[i] = '\0';
X                       cputs2(ptykconv(buf, buf2, incode, outcode));
X               }
X       }
-       else
X #endif        /* !_NOKANJICONV */
-       {
+       else {
X               if (pty[w].last1 >= (short)0) putch2(pty[w].last1);
X               if (pty[w].last2 >= (short)0) putch2(pty[w].last2);
X               putch2(c);
@@ -595,10 +606,10 @@
X                                       pty[w].cur_x;
X                       else if (pty[w].cur_x == pty[w].tabstop[i]) break;
X                       else {
-                               memmove(&(pty[w].tabstop[i + 1]),
-                                       &(pty[w].tabstop[i]),
+                               memmove((char *)&(pty[w].tabstop[i + 1]),
+                                       (char *)&(pty[w].tabstop[i]),
X                                       ((pty[w].ntabstop)++ - i)
-                                       * sizeof(u_short));
+                                               * sizeof(u_short));
X                               pty[w].tabstop[i] = pty[w].cur_x;
X                       }
X                       break;
@@ -723,6 +734,9 @@
X                               case 7:
X                                       pty[w].attr |= A_REVERSE;
X                                       break;
+                               case 8:
+                                       pty[w].attr |= A_INVISIBLE;
+                                       break;
X                               case 22:
X                                       pty[w].attr &= ~A_BOLD;
X                                       break;
@@ -735,6 +749,18 @@
X                               case 27:
X                                       pty[w].attr &= ~A_REVERSE;
X                                       break;
+                               case 28:
+                                       pty[w].attr &= ~A_INVISIBLE;
+                                       break;
+                               case 37:
+                                       pty[w].fg = (short)-1;
+                                       break;
+                               case 47:
+                                       pty[w].bg = (short)-1;
+                                       break;
+                               case 100:
+                                       pty[w].fg = pty[w].bg = (short)-1;
+                                       break;
X                               default:
X                                       n = pty[w].escparam[i];
X                                       if (n >= 30 && n <= 37)
@@ -902,10 +928,11 @@
X                                                       break;
X                                       if (pty[w].cur_x != pty[w].tabstop[i])
X                                               break;
-                                       memmove(&(pty[w].tabstop[i]),
+                                       memmove((char *)&(pty[w].tabstop[i]),
+                                               (char *)
X                                               &(pty[w].tabstop[i + 1]),
X                                               (--(pty[w].ntabstop) - i)
-                                               * sizeof(u_short));
+                                                       * sizeof(u_short));
X                                       break;
X                               case 3:
X                                       pty[w].ntabstop = (u_char)0;
@@ -1308,11 +1335,11 @@
X                       break;
X               case TE_CHANGEINKCODE:
X                       if (recvbuf(fd, &w2, sizeof(w2)) < 0) break;
-                       ptylist[w1].incode = (char)w2;
+                       ptylist[w1].incode = (u_char)w2;
X                       break;
X               case TE_CHANGEOUTKCODE:
X                       if (recvbuf(fd, &w2, sizeof(w2)) < 0) break;
-                       ptylist[w1].outcode = (char)w2;
+                       ptylist[w1].outcode = (u_char)w2;
X                       break;
X #endif        /* !_NOKANJICONV */
X               case TE_AWAKECHILD:
@@ -1348,7 +1375,7 @@
X       char buf[2];
X #else
X       char buf[MAXKANJIBUF + 1], buf2[MAXKANJIBUF + 1];
-       int cnv, code, incode, outcode;
+       int cnv, incode, outcode;
X #endif
X       keyseq_t key;
X       int n;
@@ -1360,7 +1387,6 @@
X       incode = (inputkcode != NOCNV) ? inputkcode : DEFCODE;
X       outcode = (win < MAXWINDOWS && ptylist[win].incode != NOCNV)
X               ? ptylist[win].incode : incode;
-       code = (incode != M_UTF8) ? incode : UTF8;
X #endif
X 
X       if (ismetakey(key.code)) {
@@ -1399,7 +1425,7 @@
X #ifndef       _NOKANJICONV
X               if (incode == outcode) /*EMPTY*/;
X               else if (incode == SJIS && iskana2(key.code)) cnv++;
-               else if (code == UTF8) {
+               else if (incode >= UTF8) {
X                       if (!ismsb(key.code)) /*EMPTY*/;
X                       else if ((n = ptygetch(fd)) >= 0) {
X                               buf[1] = n;
diff -urNP ../FD-2.08d/browse.c ./browse.c
--- ../FD-2.08d/browse.c        Tue Jun 13 00:00:00 2006
+++ ./browse.c  Fri Jul 28 00:00:00 2006
@@ -27,23 +27,23 @@
X #  ifdef      SVR4
X #  include <sys/sysmacros.h>
X #   ifndef    major
-#   define     major(n)        ((((unsigned long)(n)) >> 18) & 0x3fff)
+#   define     major(n)        ((((u_long)(n)) >> 18) & 0x3fff)
X #   endif
X #   ifndef    minor
-#   define     minor(n)        (((unsigned long)(n)) & 0x3ffff)
+#   define     minor(n)        (((u_long)(n)) & 0x3ffff)
X #   endif
X #  else
X #   ifndef    major
-#   define     major(n)        ((((unsigned)(n)) >> 8) & 0xff)
+#   define     major(n)        ((((u_int)(n)) >> 8) & 0xff)
X #   endif
X #   ifndef    minor
-#   define     minor(n)        (((unsigned)(n)) & 0xff)
+#   define     minor(n)        (((u_int)(n)) & 0xff)
X #   endif
X #  endif
X # endif
X #endif
X 
-#define        CL_NORM         0
+#define        CL_REG          0
X #define       CL_BACK         1
X #define       CL_DIR          2
X #define       CL_RONLY        3
@@ -189,7 +189,7 @@
X       CL_DIR, CL_LINK, CL_SOCK, CL_FIFO, CL_BLOCK, CL_CHAR
X };
X static CONST char defpalette[] = {
-       ANSI_FG,        /* CL_NORM */
+       ANSI_FG,        /* CL_REG */
X       ANSI_BG,        /* CL_BACK */
X       ANSI_CYAN,      /* CL_DIR */
X       ANSI_GREEN,     /* CL_RONLY */
@@ -221,7 +221,7 @@
X               if ((namep -> st_mode & S_IFMT) == modelist[i])
X                       return(colorlist[i]);
X 
-       return(CL_NORM);
+       return(CL_REG);
X }
X 
X static int NEAR biascolor(color)
@@ -1869,6 +1869,9 @@
X char **pathlist;
X int evaled;
X {
+#ifdef _USEDOSEMU
+       char buf[MAXPATHLEN];
+#endif
X       char *def, *cwd, file[MAXNAMLEN + 1], prev[MAXNAMLEN + 1];
X       int i, argc, ischgdir;
X 
@@ -1960,17 +1963,12 @@
X                       else copycurpath(file);
X               }
X 
-               if (isdotdir(file) != 2) {
-#ifdef _USEDOSEMU
-                       char buf[MAXPATHLEN];
-#endif
-
-                       if (chdir3(nodospath(buf, file), 1) < 0) {
-                               hideclock = 2;
-                               warning(-1, file);
-                               strcpy(prev, file);
-                               def = prev;
-                       }
+               if (isdotdir(file) != 2
+               && chdir3(nodospath(buf, file), 1) < 0) {
+                       hideclock = 2;
+                       warning(-1, file);
+                       strcpy(prev, file);
+                       def = prev;
X               }
X 
X #ifdef        _NOARCHIVE
diff -urNP ../FD-2.08d/builtin.c ./builtin.c
--- ../FD-2.08d/builtin.c       Tue Jun 13 00:00:00 2006
+++ ./builtin.c Fri Jul 28 00:00:00 2006
@@ -63,7 +63,7 @@
X extern int hideclock;
X #endif
X extern int inruncom;
-#ifndef        _NOKANJICONV
+#ifdef _USEUNICODE
X extern int unicodebuffer;
X #endif
X #ifndef       _NOPTY
@@ -2517,7 +2517,7 @@
X       sum[3] = (u_long)0x10325476;
X 
X       n = b = 0;
-       memset(x, 0, sizeof(x));
+       memset((char *)x, 0, sizeof(x));
X       while ((c = Xfgetc(fpin)) != EOF) {
X               if (cl <= (u_long)0xffffffff - (u_long)BITSPERBYTE)
X                       cl += (u_long)BITSPERBYTE;
@@ -2533,7 +2533,7 @@
X                       if (++n >= MD5_BLOCKS) {
X                               n = 0;
X                               calcmd5(sum, x);
-                               memset(x, 0, sizeof(x));
+                               memset((char *)x, 0, sizeof(x));
X                       }
X               }
X       }
@@ -2542,7 +2542,7 @@
X       x[n] |= 1 << (b + BITSPERBYTE - 1);
X       if (n >= 14) {
X               calcmd5(sum, x);
-               memset(x, 0, sizeof(x));
+               memset((char *)x, 0, sizeof(x));
X       }
X       x[14] = cl;
X       x[15] = ch;
@@ -2671,8 +2671,9 @@
X               return(-1);
X       }
X 
-       if (in == M_UTF8 || out == M_UTF8) readunitable(1);
-       else if (in == UTF8 || out == UTF8) readunitable(0);
+#  ifdef       _USEUNICODE
+       if ((i = (in > out) ? in : out) >= UTF8) readunitable(i - UTF8);
+#  endif
X       while ((cp = fgets2(fpin, 0))) {
X               if (in != DEFCODE) {
X                       tmp = newkanjiconv(cp, in, DEFCODE, L_OUTPUT);
@@ -2686,7 +2687,9 @@
SHAR_EOF
  : || $echo 'restore of' 'FD-2.08e.patch' 'failed'
fi
$echo 'End of' 'FD-2.08e.patch' 'part' '1'
$echo 'File' 'FD-2.08e.patch' 'is continued in part' '2'
echo 2 > _sh01537/seq
exit 0
-- 
                                               しらい たかし