FDclone 2.07c patch [4/4]
しらいです。
file & directory 管理ツール FDclone 2.07c の patch その 4
です。
Submitted-by: shirai@chandra2
Archive-name: FD-2.07c.patch/part04
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is `FD-2.07c.shar.04' (part 4 of FD-2.07c.patch).
# Do not concatenate these parts, unpack them in order with `/bin/sh'.
# File `FD-2.07c.patch' is being continued...
#
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 test ! -r _sh00578/seq; then
$echo 'Please unpack part 1 first!'
exit 1
fi
shar_sequence=`cat _sh00578/seq`
if test "$shar_sequence" != 4; then
$echo 'Please unpack part' "$shar_sequence" 'next!'
exit 1
fi
if test ! -f _sh00578/new; then
$echo 'x -' 'STILL SKIPPING' 'FD-2.07c.patch'
else
$echo 'x -' 'continuing file' 'FD-2.07c.patch'
sed 's/^X//' << 'SHAR_EOF' >> FD-2.07c.patch &&
X }
+ lockfile(Xfileno(fp), LCK_UNLOCK);
X Xfclose(fp);
X
X for (i++; i <= size; i++) history[n][i] = NULL;
@@ -1676,10 +1683,17 @@
X int i, size;
X
X if (!history[n] || !history[n][0]) return(-1);
- if (!(fp = Xfopen(file, "w"))) return(-1);
+ if (!file || !(fp = Xfopen(file, "w"))) return(-1);
+#ifndef NOFLOCK
+ if (lockfile(Xfileno(fp), LCK_WRITE) < 0) {
+ Xfclose(fp);
+ return(-1);
+ }
+#endif
X
X size = (savehist > (int)histsize[n]) ? (int)histsize[n] : savehist;
X for (i = size - 1; i >= 0; i--) convhistory(history[n][i], fp);
+ lockfile(Xfileno(fp), LCK_UNLOCK);
X Xfclose(fp);
X
X return(0);
diff -urNP ../FD-2.07b/system.c ./system.c
--- ../FD-2.07b/system.c Wed Sep 14 00:00:00 2005
+++ ./system.c Tue Dec 13 00:00:00 2005
@@ -100,16 +100,17 @@
X #ifdef FD
X #include "term.h"
X extern VOID calcwin __P_((VOID_A));
-extern VOID main_fd __P_((char **));
-extern VOID setlinecol __P_((VOID_A));
+extern VOID main_fd __P_((char **, int));
X extern VOID checkscreen __P_((int, int));
X # ifdef SIGWINCH
X extern VOID pollscreen __P_((int));
X # endif
X extern int sigvecset __P_((int));
-#ifndef _NOCUSTOMIZE
+# ifndef _NOCUSTOMIZE
X extern VOID saveorigenviron __P_((VOID_A));
-#endif
+# endif
+extern VOID initfd __P_((char **));
+extern VOID prepareexitfd __P_((int));
X extern int checkbuiltin __P_((char *));
X extern int checkinternal __P_((char *));
X extern int execbuiltin __P_((int, int, char *[]));
@@ -124,19 +125,14 @@
X extern int replacearg __P_((char **));
X extern VOID demacroarg __P_((char **));
X extern char *inputshellstr __P_((char *, int, char *));
-extern int entryhist __P_((int, char *, int));
-extern int loadhistory __P_((int, char *));
-extern int savehistory __P_((int, char *));
X extern int evalprompt __P_((char **, char *));
X # ifndef _NOKANJICONV
X extern char *kanjiconv2 __P_((char *, char *, int, int, int, int));
X extern char *newkanjiconv __P_((char *, int, int, int));
X # endif
-extern char *histfile;
-extern int savehist;
-#ifndef _NOEDITMODE
+# ifndef _NOEDITMODE
X extern char *editmode;
-#endif
+# endif
X extern int internal_status;
X extern char fullpath[];
X extern char *origpath;
@@ -145,6 +141,7 @@
X extern int noalrm;
X # endif
X extern int fd_restricted;
+extern int fdmode;
X extern int physical_path;
X # ifndef _NOKANJIFCONV
X extern int nokanjifconv;
@@ -224,16 +221,19 @@
X extern int _dospath __P_((char *));
X # endif
X extern char *Xgetwd __P_((char *));
+extern int Xstat __P_((char *, struct stat *));
X extern int Xaccess __P_((char *, int));
X extern int Xopen __P_((char *, int, int));
X # ifdef _NODOSDRIVE
-# define Xclose close
+# define Xclose(f) ((close(f)) ? -1 : 0)
X # define Xfdopen fdopen
X # define Xfclose fclose
+# define Xfileno fileno
X # else /* !_NODOSDRIVE */
X extern int Xclose __P_((int));
X extern FILE *Xfdopen __P_((int, char*));
X extern int Xfclose __P_((FILE *));
+extern int Xfileno __P_((FILE *));
X # endif /* !_NODOSDRIVE */
X # ifdef _NODOSDRIVE
X # define Xdup safe_dup
@@ -245,6 +245,9 @@
X #else /* !FD */
X # if MSDOS
X extern int _dospath __P_((char *));
+extern int Xstat __P_((char *, struct stat *));
+# else
+# define Xstat(p, s) ((stat(p, s)) ? -1 : 0)
X # endif
X # ifdef DJGPP
X extern char *Xgetwd __P_((char *));
@@ -254,26 +257,26 @@
X # else
X # define Xgetwd(p) (char *)getcwd(p, MAXPATHLEN)
X # endif
-extern int Xstat __P_((char *, struct stat *));
X # endif /* !DJGPP */
-#define Xaccess(p, m) (access(p, m) ? -1 : 0)
-#define Xunlink(p) (unlink(p) ? -1 : 0)
+#define Xaccess(p, m) ((access(p, m)) ? -1 : 0)
+#define Xunlink(p) ((unlink(p)) ? -1 : 0)
X #define Xopen open
-#define Xclose close
+#define Xclose(f) ((close(f)) ? -1 : 0)
X #define Xfdopen fdopen
X #define Xfclose fclose
+#define Xfileno fileno
X #define Xdup safe_dup
X #define Xdup2 safe_dup2
X # if MSDOS
X # ifdef DJGPP
-# define Xmkdir(p, m) (mkdir(p, m) ? -1 : 0)
+# define Xmkdir(p, m) ((mkdir(p, m)) ? -1 : 0)
X # else
X int Xmkdir __P_((char *, int));
X # endif
X # else
-# define Xmkdir mkdir
+# define Xmkdir ((mkdir(p, m)) ? -1 : 0)
X # endif
-#define Xrmdir(p) (rmdir(p) ? -1 : 0)
+#define Xrmdir(p) ((rmdir(p)) ? -1 : 0)
X #endif /* !FD */
X
X #ifndef O_BINARY
@@ -380,8 +383,8 @@
X extern char *strncpy2 __P_((char *, char *, int));
X
X #ifdef DEBUG
-extern VOID mtrace __P_ ((VOID));
-extern VOID muntrace __P_ ((VOID));
+extern VOID mtrace __P_ ((VOID_A));
+extern VOID muntrace __P_ ((VOID_A));
X extern char *_mtrace_file;
X #endif
X
@@ -908,10 +911,12 @@
X int bgnotify = 0;
X int jobok = -1;
X #endif
-#if defined (FD) && !defined (_NOEDITMODE)
+#ifdef FD
+# ifndef _NOEDITMODE
X int emacsmode = 0;
X int vimode = 0;
-#endif
+# endif
+#endif /* FD */
X int loginshell = 0;
X int noruncom = 0;
X
@@ -1256,7 +1261,7 @@
X {"emacs", &emacsmode, '\0'},
X {"vi", &vimode, '\0'},
X # endif
-#endif
+#endif /* FD */
X {NULL, &loginshell, 'l'},
X {NULL, &noruncom, 'N'},
X };
@@ -2378,14 +2383,20 @@
X VOID Xexit2(n)
X int n;
X {
+ if (mypid == orgpid) {
+#ifndef NOJOB
+ if (loginshell && interactive_io) killjob();
+#endif
X #ifdef FD
- if (havetty() && mypid == orgpid && interactive && !nottyout) {
- if (!dumbterm) putterm(T_NORMAL);
- endterm();
- inittty(1);
- keyflush();
- }
+ prepareexitfd(n);
+ if (havetty() && interactive && !nottyout) {
+ if (!dumbterm) putterm(T_NORMAL);
+ endterm();
+ inittty(1);
+ keyflush();
+ }
X #endif /* !FD */
+ }
X prepareexit(0);
X
X #ifdef DEBUG
@@ -2447,12 +2458,7 @@
X fputs(syntaxerrstr[syntaxerrno], stderr);
X fputnl(stderr);
X ret_status = RET_SYNTAXERR;
- if (errorexit) {
-#ifndef NOJOB
- if (loginshell && interactive_io) killjob();
-#endif
- Xexit2(RET_SYNTAXERR);
- }
+ if (errorexit) Xexit2(RET_SYNTAXERR);
X safeexit();
X }
X
@@ -2811,13 +2817,12 @@
X tty.sg_flags |= ECHO | CRMOD;
X tty.sg_flags &= ~(RAW | CBREAK | XTABS);
X # else
- tty.c_lflag |= ISIG | ICANON | IEXTEN
- | ECHO | ECHOE | ECHOCTL | ECHOKE;
+ tty.c_lflag |= (TIO_ICOOKED | TIO_LECHO);
X tty.c_lflag &= ~(PENDIN | ECHONL);
- tty.c_iflag |= BRKINT | IXON | ICRNL;
- tty.c_iflag &= ~(IGNBRK | ISTRIP);
- tty.c_oflag |= OPOST | ONLCR;
- tty.c_oflag &= ~(OCRNL | ONOCR | ONLRET | TAB3);
+ tty.c_iflag |= (TIO_ICOOKED | ICRNL);
+ tty.c_iflag &= TIO_INOCOOKED;
+ tty.c_oflag |= TIO_ONL;
+ tty.c_oflag &= (TIO_ONONL & ~TAB3);
X # endif
X tioctl(ttyio, REQSETP, &tty);
X # endif /* !FD */
@@ -2910,7 +2915,7 @@
X
X if (!fp) return;
X duperrno = errno;
- fd = fileno(fp);
+ fd = Xfileno(fp);
X if (fd != STDIN_FILENO && fd != STDOUT_FILENO && fd != STDERR_FILENO)
X Xfclose(fp);
X errno = duperrno;
@@ -2988,6 +2993,10 @@
X flags = (u_long)0;
X for (i = 1; arg[i]; i++) {
X if (isopt) {
+#ifdef FD
+ if (fdmode) /*EMPTY*/;
+ else
+#endif
X if (arg[i] == 'c' && !com && argc > 2) {
X com = 1;
X continue;
@@ -4022,7 +4031,7 @@
X #endif
X
X if (rp -> new != rp -> fd) {
- if (rp -> new < 0) Xclose(rp -> fd);
+ if (rp -> new < 0) VOID_C Xclose(rp -> fd);
X else {
X #if defined (FD) && !defined (_NODOSDRIVE)
X if (rp -> new >= DOSFDOFFSET) openpseudofd(rp);
@@ -4119,7 +4128,7 @@
X {
X struct stat st;
X
- if (!path || stat(path, &st) < 0) return;
+ if (!path || Xstat(path, &st) < 0) return;
X if (st.st_size > 0 && *mtimep && st.st_mtime > *mtimep) {
X # ifdef MINIMUMSHELL
X fputs("you have mail", stderr);
@@ -6520,7 +6529,7 @@
X buf = NULL;
X ret_status = RET_NOTEXEC;
X }
- else if (!(buf = readfile(fileno(fp), &len))) {
+ else if (!(buf = readfile(Xfileno(fp), &len))) {
X doperror(NULL, NULL);
X ret_status = RET_FATALERR;
X }
@@ -6532,9 +6541,9 @@
X if (len > 0 && buf[--len] == '\n') buf[len] = '\0';
X #endif
X #ifdef DJGPP
- ret_status = closepipe(fileno(fp), -1);
+ ret_status = closepipe(Xfileno(fp), -1);
X #else
- ret_status = closepipe(fileno(fp));
+ ret_status = closepipe(Xfileno(fp));
X #endif
X }
X
@@ -7722,12 +7731,6 @@
X path = strdup2(path);
X evar = exportvar;
X exportvar = NULL;
-#ifdef FD
- if (savehist > 0) savehistory(0, histfile);
-#endif
-#ifndef NOJOB
- if (loginshell && interactive_io) killjob();
-#endif
X
X if (errexit && !path) {
X #ifdef DEBUG
@@ -7736,6 +7739,12 @@
X Xexit2(RET_FAIL);
X }
X
+#ifndef NOJOB
+ if (loginshell && interactive_io) killjob();
+#endif
+#ifdef FD
+ prepareexitfd(0);
+#endif
X prepareexit(1);
X #ifdef DEBUG
X Xexecve(path, comm -> argv, evar, 0);
@@ -7863,15 +7872,7 @@
X #endif
X }
X if (exit_status < 0) exit_status = ret;
- else {
-#ifdef FD
- if (savehist > 0) savehistory(0, histfile);
-#endif
-#ifndef NOJOB
- if (loginshell && interactive_io) killjob();
-#endif
- Xexit2(ret);
- }
+ else Xexit2(ret);
X
X return(RET_SUCCESS);
X }
@@ -8945,7 +8946,7 @@
X argv = (trp -> comm) -> argv;
X n = 1;
X if ((trp -> comm) -> argc > 1 && argv[n][0] == '-'
- && argv[n][1] == 'n' && argv[n][2] == '\0')
+ && argv[n][1] == 'n' && !(argv[n][2]))
X n++;
X
X for (i = n; i < (trp -> comm) -> argc; i++) {
@@ -9130,7 +9131,7 @@
X argv = (trp -> comm) -> argv;
X n = 1;
X if ((trp -> comm) -> argc > 1 && argv[n][0] == '-'
- && argv[n][1] == 'n' && argv[n][2] == '\0')
+ && argv[n][1] == 'n' && !(argv[n][2]))
X n++;
X
X ret = RET_SUCCESS;
@@ -9224,10 +9225,11 @@
X ttyiomode(0);
X mode = termmode(1);
X shellmode = 0;
- main_fd(&((trp -> comm) -> argv[1]));
+ main_fd(&((trp -> comm) -> argv[1]), 1);
X shellmode = 1;
X termmode(mode);
X stdiomode();
+ fputnl(stderr);
X sigvecset(n);
X }
X
@@ -9812,7 +9814,7 @@
X }
X #ifdef FD
X if (type != CT_NONE && type != CT_FDINTERNAL && type != CT_FUNCTION)
- internal_status = -2;
+ internal_status = FNC_FAIL;
X #endif
X
X comm -> argc = argc;
@@ -10144,9 +10146,6 @@
X freestree(stree);
X if (errorexit && !noexit) {
X free(stree);
-#ifndef NOJOB
- if (loginshell && interactive_io) killjob();
-#endif
X Xexit2(RET_SYNTAXERR);
X }
X return(NULL);
@@ -10171,9 +10170,6 @@
X if (ret < 0 && errno) doperror(NULL, NULL);
X if ((errorexit && ret && !noexit) || terminated) {
X free(stree);
-#ifndef NOJOB
- if (loginshell && interactive_io) killjob();
-#endif
X Xexit2(ret);
X }
X
@@ -10355,9 +10351,9 @@
X FILE *fp;
X {
X # ifdef DJGPP
- return(closepipe(fileno(fp), -1));
+ return(closepipe(Xfileno(fp), -1));
X # else
- return(closepipe(fileno(fp)));
+ return(closepipe(Xfileno(fp)));
X # endif
X }
X #endif /* !FDSH */
@@ -10552,7 +10548,7 @@
X if (interactive) inittty(0);
X term = getconstvar("TERM");
X getterment((term) ? term : "");
-#endif
+#endif /* FD */
X
X return(0);
X }
@@ -10583,7 +10579,8 @@
X #ifdef FD
X if (loginshell) execruncom(SH_RCFILE, verbose);
X else execruncom(FD_RCFILE, verbose);
-#endif
+ evalenv();
+#endif /* FD */
X }
X
X int initshell(argc, argv)
@@ -10835,7 +10832,9 @@
X
X if (n > 2) {
X initrc(0);
- setsignal();
+#ifdef FD
+ initfd(argv);
+#endif /* FD */
X if (verboseinput) {
X kanjifputs(argv[2], stderr);
X #ifdef BASHSTYLE
@@ -10845,12 +10844,16 @@
X fflush(stderr);
X }
X shellmode = 1;
+ setsignal();
X n = _dosystem(argv[2]);
X resetsignal(0);
X Xexit2(n);
X }
X
X if (loginshell && chdir2(getconstvar("HOME")) < 0) {
+#ifdef FD
+ initfd(argv);
+#endif
X fputs("No directory", stderr);
X fputnl(stderr);
X Xexit2(RET_FAIL);
@@ -10981,18 +10984,9 @@
X ret_status = RET_SUCCESS;
X initrc(!loginshell);
X #ifdef FD
- if (interactive) {
- loadhistory(0, histfile);
- entryhist(1, origpath, 1);
- }
-#endif
+ initfd(argv);
+#endif /* FD */
X shell_loop(0);
-#ifdef FD
- if (savehist > 0) savehistory(0, histfile);
-#endif
-#ifndef NOJOB
- if (loginshell && interactive) killjob();
-#endif
X
X return(ret_status);
X }
diff -urNP ../FD-2.07b/system.h ./system.h
--- ../FD-2.07b/system.h Wed Sep 14 00:00:00 2005
+++ ./system.h Tue Dec 13 00:00:00 2005
@@ -380,10 +380,12 @@
X extern int bgnotify;
X extern int jobok;
X #endif
-#if defined (FD) && !defined (_NOEDITMODE)
+#ifdef FD
+# ifndef _NOEDITMODE
X extern int emacsmode;
X extern int vimode;
-#endif
+# endif
+#endif /* FD */
X extern int loginshell;
X extern int noruncom;
X
diff -urNP ../FD-2.07b/term.c ./term.c
--- ../FD-2.07b/term.c Wed Sep 14 00:00:00 2005
+++ ./term.c Tue Dec 13 00:00:00 2005
@@ -77,8 +77,6 @@
X #include "termio.h"
X #include "term.h"
X
-#define GETSIZE "\033[6n"
-#define SIZEFMT "\033[%d;%dR"
X #define WINTERMNAME "iris"
X #ifdef USESTRERROR
X #define strerror2 strerror
@@ -90,7 +88,7 @@
X #endif
X
X #ifdef DEBUG
-extern VOID muntrace __P_ ((VOID));
+extern VOID muntrace __P_ ((VOID_A));
X extern char *_mtrace_file;
X #endif
X
@@ -968,8 +966,7 @@
X #ifdef USESGTTY
X ttymode(0, CBREAK | RAW, LPASS8, LLITOUT | LPENDIN);
X #else
- ttymode(ISIG | ICANON | IEXTEN, PENDIN,
- BRKINT | IXON, IGNBRK | ISTRIP,
+ ttymode(TIO_LCOOKED, PENDIN, TIO_ICOOKED, ~TIO_INOCOOKED,
X OPOST, 0, VAL_VMIN, VAL_VTIME);
X #endif
X
@@ -981,7 +978,7 @@
X #ifdef USESGTTY
X ttymode(CBREAK, 0, LLITOUT, 0);
X #else
- ttymode(ISIG | IEXTEN, ICANON, BRKINT | IXON, IGNBRK, OPOST, 0, 1, 0);
+ ttymode(TIO_LCBREAK, ICANON, TIO_ICOOKED, IGNBRK, OPOST, 0, 1, 0);
X #endif
X
X return(0);
@@ -992,8 +989,7 @@
X #ifdef USESGTTY
X ttymode(RAW, 0, LLITOUT, 0);
X #else
- ttymode(0, ISIG | ICANON | IEXTEN,
- IGNBRK, BRKINT | IXON, 0, OPOST, 1, 0);
+ ttymode(0, TIO_LCOOKED, IGNBRK, TIO_ICOOKED, 0, OPOST, 1, 0);
X #endif
X
X return(0);
@@ -1004,7 +1000,7 @@
X #ifdef USESGTTY
X ttymode(ECHO, 0, LCRTBS | LCRTERA | LCRTKIL | LCTLECH, 0);
X #else
- ttymode(ECHO | ECHOE | ECHOCTL | ECHOKE, ECHONL, 0, 0, 0, 0, 0, 0);
+ ttymode(TIO_LECHO, ECHONL, 0, 0, 0, 0, 0, 0);
X #endif
X
X return(0);
@@ -1015,7 +1011,7 @@
X #ifdef USESGTTY
X ttymode(0, ECHO, 0, LCRTBS | LCRTERA);
X #else
- ttymode(0, ECHO | ECHOE | ECHOK | ECHONL, 0, 0, 0, 0, 0, 0);
+ ttymode(0, ~TIO_LNOECHO, 0, 0, 0, 0, 0, 0);
X #endif
X
X return(0);
@@ -1026,7 +1022,7 @@
X #ifdef USESGTTY
X ttymode(CRMOD, 0, 0, 0);
X #else
- ttymode(0, 0, ICRNL, 0, ONLCR, OCRNL | ONOCR | ONLRET, 0, 0);
+ ttymode(0, 0, ICRNL, 0, ONLCR, ~TIO_ONONL, 0, 0);
X #endif
X
X return(0);
@@ -1086,23 +1082,24 @@
X int ttyiomode(isnl)
X int isnl;
X {
+ if (ttyio < 0) /*EMPTY*/;
+ else {
X #if MSDOS
- raw2();
+ raw2();
X #else /* !MSDOS */
X # ifdef USESGTTY
- raw2();
- noecho2();
- nonl2();
- notabs();
+ raw2();
+ noecho2();
+ nonl2();
+ notabs();
X # else /* !USESGTTY */
- if (isnl) ttymode(0, (ISIG|ICANON|IEXTEN) | (ECHO|ECHOE|ECHOK|ECHONL),
- IGNBRK, (BRKINT|IXON) | ICRNL,
- OPOST | ONLCR | TAB3, 0, 1, 0);
- else ttymode(0, (ISIG|ICANON|IEXTEN) | (ECHO|ECHOE|ECHOK|ECHONL),
- IGNBRK, (BRKINT|IXON) | ICRNL,
- TAB3, OPOST | ONLCR, 1, 0);
+ if (isnl) ttymode(0, TIO_LCOOKED | ~TIO_LNOECHO,
+ IGNBRK, TIO_ICOOKED | ICRNL, TIO_ONL | TAB3, 0, 1, 0);
+ else ttymode(0, TIO_LCOOKED | ~TIO_LNOECHO,
+ IGNBRK, TIO_ICOOKED | ICRNL, TAB3, TIO_ONL, 1, 0);
X # endif /* !USESGTTY */
X #endif /* !MSDOS */
+ }
X if (!dumbterm) {
X putterm(T_KEYPAD);
X tflush();
@@ -1117,30 +1114,30 @@
X int isnl;
X
X isnl = (isttyiomode) ? isttyiomode - 1 : 0;
+ if (ttyio < 0) /*EMPTY*/;
+ else {
X #if MSDOS
- cooked2();
+ cooked2();
X #else /* !MSDOS */
X # ifdef USESGTTY
- cooked2();
- echo2();
- nl2();
- tabs();
- if (dumbterm > 2) ttymode(0, ECHO | CRMOD, 0, 0);
+ cooked2();
+ echo2();
+ nl2();
+ tabs();
+ if (dumbterm > 2) ttymode(0, ECHO | CRMOD, 0, 0);
X # else /* !USESGTTY */
- if (isnl) ttymode((ISIG|ICANON|IEXTEN) | (ECHO|ECHOE|ECHOCTL|ECHOKE),
- PENDIN | ECHONL,
- (BRKINT|IXON) | ICRNL, (IGNBRK|ISTRIP),
- 0, (OCRNL|ONOCR|ONLRET) | TAB3,
- VAL_VMIN, VAL_VTIME);
- else ttymode((ISIG|ICANON|IEXTEN) | (ECHO|ECHOE|ECHOCTL|ECHOKE),
- PENDIN | ECHONL,
- (BRKINT|IXON) | ICRNL, (IGNBRK|ISTRIP),
- OPOST | ONLCR, (OCRNL|ONOCR|ONLRET) | TAB3,
- VAL_VMIN, VAL_VTIME);
- if (dumbterm > 2)
- ttymode(0, ECHO, 0, ICRNL, 0, ONLCR, VAL_VMIN, VAL_VTIME);
+ if (isnl) ttymode(TIO_LCOOKED | TIO_LECHO, PENDIN | ECHONL,
+ TIO_ICOOKED | ICRNL, ~TIO_INOCOOKED,
+ 0, ~TIO_ONONL | TAB3, VAL_VMIN, VAL_VTIME);
+ else ttymode(TIO_LCOOKED | TIO_LECHO, PENDIN | ECHONL,
+ TIO_ICOOKED | ICRNL, ~TIO_INOCOOKED,
+ TIO_ONL, ~TIO_ONONL | TAB3, VAL_VMIN, VAL_VTIME);
+ if (dumbterm > 2)
+ ttymode(0, ECHO,
+ 0, ICRNL, 0, ONLCR, VAL_VMIN, VAL_VTIME);
X # endif /* !USESGTTY */
X #endif /* !MSDOS */
+ }
X if (!dumbterm) {
X putterm(T_NOKEYPAD);
X tflush();
@@ -1336,7 +1333,7 @@
X int getxy(xp, yp)
X int *xp, *yp;
X {
- char *format, buf[sizeof(SIZEFMT) + 6];
+ char *format, buf[sizeof(SIZEFMT) + (MAXLONGWIDTH - 2) * 2];
X int i, j, tmp, count, *val[2];
X
X format = SIZEFMT;
@@ -3171,10 +3168,10 @@
X int n;
X
X VA_START(args, fmt);
-
X n = vasprintf2(&buf, fmt, args);
X va_end(args);
X if (n < 0) err2("malloc()");
+
X cputs2(buf);
X free(buf);
X
diff -urNP ../FD-2.07b/term.h ./term.h
--- ../FD-2.07b/term.h Wed Sep 14 00:00:00 2005
+++ ./term.h Tue Dec 13 00:00:00 2005
@@ -19,6 +19,9 @@
X char *str;
X } keyseq_t;
X
+#define GETSIZE "\033[6n"
+#define SIZEFMT "\033[%d;%dR"
+
X #define K_CR '\r'
X #define K_ESC '\033'
X
diff -urNP ../FD-2.07b/termemu.c ./termemu.c
--- ../FD-2.07b/termemu.c Wed Sep 14 00:00:00 2005
+++ ./termemu.c Tue Dec 13 00:00:00 2005
@@ -37,8 +37,8 @@
X # define FD_SET(n, p) (((p) -> fds_bits[0]) |= ((u_int)1 << (n)))
X #endif /* !FD_SET */
X
-extern int hideclock;
X extern int internal_status;
+extern int hideclock;
X
X int ptymode = 0;
X char *ptyterm = NULL;
@@ -238,17 +238,25 @@
X return(0);
X }
X
-VOID syncptyout(VOID_A)
+VOID syncptyout(fd, cmd)
+int fd, cmd;
X {
X char *tty;
+ u_char uc;
X
X if (parentfd < 0) return;
X
X savetermio(ttyio, &tty, NULL);
X keyflush();
X noecho2();
- tputs2("\033[99n", 1);
- tflush();
+ if (fd < 0) {
+ tputs2("\033[99n", 1);
+ tflush();
+ }
+ else {
+ uc = cmd;
+ sendbuf(fd, &uc, sizeof(uc));
+ }
X VOID_C getch2();
X keyflush();
X loadtermio(ttyio, tty, NULL);
@@ -448,6 +456,7 @@
X #endif
X
X fd = parentfd;
+ syncptyout(fd, TE_LOCKFRONT);
X uc = cmd;
X sendbuf(fd, &uc, sizeof(uc));
X
@@ -604,6 +613,7 @@
X break;
X }
X va_end(args);
+ syncptyout(fd, TE_UNLOCKFRONT);
X }
X
X static VOID NEAR awakechild(command, arg, flags)
@@ -705,7 +715,7 @@
X int flags;
X {
X p_id_t pid;
- char *tty, *ws, path[MAXPATHLEN];
+ char *tty, *ws, path[MAXPATHLEN], buf[TIO_BUFSIZ + TIO_WINSIZ];
X u_char uc;
X int i, n, fd, fds[2];
X
@@ -716,6 +726,18 @@
X return(frontend());
X }
X
+ savetermio(ttyio, &tty, &ws);
+ if (tty) {
+ memcpy(buf, tty, TIO_BUFSIZ);
+ free(tty);
+ tty = buf;
+ }
+ if (ws) {
+ memcpy(&(buf[TIO_BUFSIZ]), ws, TIO_WINSIZ);
+ free(ws);
+ ws = &(buf[TIO_BUFSIZ]);
+ }
+
X if (genbackend() < 0 || pipe(fds) < 0)
X return(callmacro(command, arg, flags));
X VOID_C fcntl(fds[0], F_SETFL, O_NONBLOCK);
@@ -724,7 +746,7 @@
X if (ptytmpfile) fd = -1;
X else if ((fd = mktmpfile(path)) >= 0) {
X ptytmpfile = strdup2(path);
- Xclose(fd);
+ VOID_C Xclose(fd);
X }
X
X n = sigvecset(0);
@@ -744,10 +766,7 @@
X #ifndef _NOORIGSHELL
X mypid = getpid();
X #endif
- savetermio(ttyio, &tty, &ws);
X if (Xlogin_tty(ptylist[win].path, tty, ws) < 0) _exit(1);
- if (tty) free(tty);
- if (ws) free(ws);
X n_line = FILEPERROW;
X VOID_C setwsize(STDIN_FILENO, n_column, n_line);
X
@@ -781,11 +800,9 @@
X sendbuf(parentfd, &uc, sizeof(uc));
X
X for (;;) {
- syncptyout();
+ syncptyout(-1, -1);
X setlinecol();
- n = callmacro(command, arg, flags);
- n = (n < 0) ? 1 :
- ((internal_status < -1) ? 4 : internal_status);
+ n = evalstatus(callmacro(command, arg, flags));
X #if defined (_NOORIGSHELL) || defined (NOJOB)
X break;
X #else /* !_NOORIGSHELL && !NOJOB */
diff -urNP ../FD-2.07b/termemu.h ./termemu.h
--- ../FD-2.07b/termemu.h Wed Sep 14 00:00:00 2005
+++ ./termemu.h Tue Dec 13 00:00:00 2005
@@ -27,7 +27,9 @@
X #define TE_CHANGEWSIZE (K_MAX + 11)
X #define TE_INSERTWIN (K_MAX + 12)
X #define TE_DELETEWIN (K_MAX + 13)
-#define TE_CHANGEKCODE (K_MAX + 14)
+#define TE_LOCKBACK (K_MAX + 14)
+#define TE_UNLOCKBACK (K_MAX + 15)
+#define TE_CHANGEKCODE (K_MAX + 16)
X #define TE_AWAKECHILD (K_MAX + 99)
X
X #define TE_SETVAR 1
@@ -54,4 +56,6 @@
X #define TE_DELETEARCH 22
X #define TE_INSERTDRV 23
X #define TE_DELETEDRV 24
+#define TE_LOCKFRONT 25
+#define TE_UNLOCKFRONT 26
X #define TE_CHANGESTATUS 99
diff -urNP ../FD-2.07b/termio.c ./termio.c
--- ../FD-2.07b/termio.c Wed Sep 14 00:00:00 2005
+++ ./termio.c Tue Dec 13 00:00:00 2005
@@ -401,11 +401,11 @@
X if (ttyp) do {
X *ttyp = NULL;
X # ifndef DJGPP
- if (!(tty = (char *)malloc(sizeof(reg.h.dl)))) break;
+ if (!(tty = (char *)malloc(TIO_BUFSIZ))) break;
X
X reg.x.ax = 0x3300;
X int86(0x21, ®, ®);
- memcpy((char *)tty, (char *)&(reg.h.dl), sizeof(reg.h.dl));
+ memcpy((char *)tty, (char *)&(reg.h.dl), TIO_BUFSIZ);
X *ttyp = tty;
X # endif /* !DJGPP */
X } while (0);
@@ -542,11 +542,7 @@
X
X if (ttyp) do {
X *ttyp = NULL;
- size = sizeof(termioctl_t);
-# ifdef USESGTTY
- size += sizeof(int) + sizeof(struct tchars);
-# endif
- if (!(tty = (char *)malloc(size))) break;
+ if (!(tty = (char *)malloc(TIO_BUFSIZ))) break;
X
X size = (ALLOC_T)0;
X if (tioctl(fd, REQGETP, (termioctl_t *)&(tty[size])) < 0) {
@@ -571,7 +567,7 @@
X if (wsp) do {
X *wsp = NULL;
X # ifndef NOTERMWSIZE
- if (!(ws = (char *)malloc(sizeof(termwsize_t)))) break;
+ if (!(ws = (char *)malloc(TIO_WINSIZ))) break;
X
X if (Xioctl(fd, REQGETWS, (termwsize_t *)ws) < 0) {
X free(ws);
diff -urNP ../FD-2.07b/termio.h ./termio.h
--- ../FD-2.07b/termio.h Wed Sep 14 00:00:00 2005
+++ ./termio.h Tue Dec 13 00:00:00 2005
@@ -114,6 +114,36 @@
X #define TAB3 OXTABS
X #endif
X
+#define TIO_LCBREAK (ISIG | IEXTEN)
+#define TIO_LCOOKED (TIO_LCBREAK | ICANON)
+#define TIO_LECHO (ECHO | ECHOE | ECHOCTL | ECHOKE)
+#define TIO_LNOECHO ~(ECHO | ECHOE | ECHOK | ECHONL)
+#define TIO_ICOOKED (BRKINT | IXON)
+#define TIO_INOCOOKED ~(IGNBRK | ISTRIP)
+#define TIO_ONL (OPOST | ONLCR)
+#define TIO_ONONL ~(OCRNL | ONOCR | ONLRET)
+
+#if MSDOS
+# ifdef DJGPP
+# define TIO_BUFSIZ (ALLOC_T)0
+# else
+# define TIO_BUFSIZ sizeof(u_char)
+# endif
+# define TIO_WINSIZ (ALLOC_T)0
+#else /* !MSDOS */
+# ifdef USESGTTY
+# define TIO_BUFSIZ (sizeof(termioctl_t) \
+ + sizeof(int) + sizeof(struct tchars));
+# else
+# define TIO_BUFSIZ sizeof(termioctl_t)
+# endif
+# ifdef NOTERMWSIZE
+# define TIO_WINSIZ (ALLOC_T)0
+# else
+# define TIO_WINSIZ sizeof(termwsize_t)
+# endif
+#endif /* !MSDOS */
+
X #if defined (USETERMIOS) || defined (USETERMIO)
X #if (VEOF == VMIN) || (VEOL == VTIME)
X #define VAL_VMIN '\004'
diff -urNP ../FD-2.07b/tree.c ./tree.c
--- ../FD-2.07b/tree.c Wed Sep 14 00:00:00 2005
+++ ./tree.c Tue Dec 13 00:00:00 2005
@@ -684,7 +684,7 @@
X } while (&(tr_cur -> sub[tr_no]) != old);
X break;
X case 'l':
- if (!(cwd = inputstr(LOGD_K, 0, -1, NULL, 1))
+ if (!(cwd = inputstr(LOGD_K, 0, -1, NULL, HST_PATH))
X || !*(cwd = evalpath(cwd, 0)))
X break;
X if (chdir2(cwd) >= 0) {
diff -urNP ../FD-2.07b/types.h ./types.h
--- ../FD-2.07b/types.h Wed Sep 14 00:00:00 2005
+++ ./types.h Tue Dec 13 00:00:00 2005
@@ -60,6 +60,9 @@
X #define S_IWOTH 00002
X #define S_IXOTH 00001
X #endif /* NOFILEMODE */
+#define S_IREAD_ALL (S_IRUSR | S_IRGRP | S_IROTH)
+#define S_IWRITE_ALL (S_IWUSR | S_IWGRP | S_IWOTH)
+#define S_IEXEC_ALL (S_IXUSR | S_IXGRP | S_IXOTH)
X
X #if !MSDOS && defined (UF_SETTABLE) && defined (SF_SETTABLE)
X #define HAVEFLAGS
@@ -110,17 +113,16 @@
X u_char tmpflags;
X } namelist;
X
-#define F_ISEXE 0001
-#define F_ISWRI 0002
-#define F_ISRED 0004
-#define F_ISDIR 0010
-#define F_ISLNK 0020
-#define F_ISDEV 0040
-#define F_ISMRK 0001
-#define F_WSMRK 0002
-#define F_ISARG 0004
-#define F_STAT 0010
-
+#define F_ISEXE 0001
+#define F_ISWRI 0002
+#define F_ISRED 0004
+#define F_ISDIR 0010
+#define F_ISLNK 0020
+#define F_ISDEV 0040
+#define F_ISMRK 0001
+#define F_WSMRK 0002
+#define F_ISARG 0004
+#define F_STAT 0010
X #define isdir(file) ((file) -> flags & F_ISDIR)
X #define islink(file) ((file) -> flags & F_ISLNK)
X #define isdev(file) ((file) -> flags & F_ISDEV)
@@ -160,20 +162,21 @@
X u_char status;
X } functable;
X
-#define REWRITE 0001
-#define RELIST 0002
-#define REWIN 0003
-#define REWRITEMODE 0003
-#define RESCRN 0004
-#define KILLSTK 0010
-#define ARCH 0020
-#define NO_FILE 0040
-#define RESTRICT 0100
-#define NEEDSTAT 0200
+#define FN_REWRITE 0001
+#define FN_RELIST 0002
+#define FN_REWIN 0003
+#define FN_REWRITEMODE 0003
+#define FN_RESCREEN 0004
+#define FN_KILLSTACK 0010
+#define FN_ARCHIVE 0020
+#define FN_NOFILE 0040
+#define FN_RESTRICT 0100
+#define FN_NEEDSTATUS 0200
+#define rewritemode(n) ((n) & FN_REWRITEMODE)
X
X #ifndef _NOARCHIVE
-#define MAXLAUNCHFIELD 9
-#define MAXLAUNCHSEP 3
+#define MAXLAUNCHFIELD 9
+#define MAXLAUNCHSEP 3
X typedef struct _launchtable {
X char *ext;
X char *comm;
@@ -194,20 +197,20 @@
X u_char flags;
X } launchtable;
X
-#define F_MODE 0
-#define F_UID 1
-#define F_GID 2
-#define F_SIZE 3
-#define F_YEAR 4
-#define F_MON 5
-#define F_DAY 6
-#define F_TIME 7
-#define F_NAME 8
-#define LF_IGNORECASE 0001
-#define LF_DIRLOOP 0002
-#define LF_DIRNOPREP 0004
-#define LF_FILELOOP 0010
-#define LF_FILENOPREP 0020
+#define F_MODE 0
+#define F_UID 1
+#define F_GID 2
+#define F_SIZE 3
+#define F_YEAR 4
+#define F_MON 5
+#define F_DAY 6
+#define F_TIME 7
+#define F_NAME 8
+#define LF_IGNORECASE 0001
+#define LF_DIRLOOP 0002
+#define LF_DIRNOPREP 0004
+#define LF_FILELOOP 0010
+#define LF_FILENOPREP 0020
X
X typedef struct _archivetable {
X char *ext;
@@ -216,7 +219,7 @@
X u_char flags;
X } archivetable;
X
-#define AF_IGNORECASE 0001 /* must be the same as LF_IGNORECASE */
+#define AF_IGNORECASE 0001 /* must be the same as LF_IGNORECASE */
X #endif /* !_NOARCHIVE */
X
X #ifndef _NOTREE
@@ -265,19 +268,19 @@
X
X extern winvartable winvar[];
X #ifdef _NOSPLITWIN
-#define win 0
-#define windows 1
+#define win 0
+#define windows 1
X #else
X extern int windows;
X extern int win;
X #endif
X #ifndef _NOARCHIVE
-#define archduplp (winvar[win].v_archduplp)
-#define archivefile (winvar[win].v_archivefile)
-#define archtmpdir (winvar[win].v_archtmpdir)
-#define launchp (winvar[win].v_launchp)
-#define arcflist (winvar[win].v_arcflist)
-#define maxarcf (winvar[win].v_maxarcf)
+#define archduplp (winvar[win].v_archduplp)
+#define archivefile (winvar[win].v_archivefile)
+#define archtmpdir (winvar[win].v_archtmpdir)
+#define launchp (winvar[win].v_launchp)
+#define arcflist (winvar[win].v_arcflist)
+#define maxarcf (winvar[win].v_maxarcf)
X # if (!MSDOS || !defined (_NOUSELFN)) && !defined (_NODOSDRIVE)
X # define archdrive (winvar[win].v_archdrive)
X # endif
@@ -287,16 +290,16 @@
X # endif
X #endif /* !_NOARCHIVE */
X #ifndef _NOTREE
-#define treepath (winvar[win].v_treepath)
+#define treepath (winvar[win].v_treepath)
X #endif
-#define findpattern (winvar[win].v_findpattern)
-#define filelist (winvar[win].v_filelist)
-#define maxfile (winvar[win].v_maxfile)
-#define maxent (winvar[win].v_maxent)
-#define filepos (winvar[win].v_filepos)
-#define sorton (winvar[win].v_sorton)
-#define dispmode (winvar[win].v_dispmode)
-#define FILEPERROW (winvar[win].v_fileperrow)
+#define findpattern (winvar[win].v_findpattern)
+#define filelist (winvar[win].v_filelist)
+#define maxfile (winvar[win].v_maxfile)
+#define maxent (winvar[win].v_maxent)
+#define filepos (winvar[win].v_filepos)
+#define sorton (winvar[win].v_sorton)
+#define dispmode (winvar[win].v_dispmode)
+#define FILEPERROW (winvar[win].v_fileperrow)
X
X typedef struct _macrostat {
X short addopt;
@@ -305,22 +308,22 @@
X u_short flags;
X } macrostat;
X
-#define F_NOCONFIRM 0000001
-#define F_ARGSET 0000002
-#define F_REMAIN 0000004
-#define F_NOEXT 0000010
-#define F_TOSFN 0000020
-#define F_ISARCH 0000040
-#define F_BURST 0000100
-#define F_MARK 0000200
-#define F_NOADDOPT 0000400
-#define F_IGNORELIST 0001000
-#define F_NOCOMLINE 0002000
-#define F_NOKANJICONV 0004000
-#define F_TTYIOMODE 0010000
-#define F_TTYNL 0020000
-#define F_EVALMACRO 0040000
-#define F_DOSYSTEM 0100000
+#define F_NOCONFIRM 0000001
+#define F_ARGSET 0000002
+#define F_REMAIN 0000004
+#define F_NOEXT 0000010
+#define F_TOSFN 0000020
+#define F_ISARCH 0000040
+#define F_BURST 0000100
+#define F_MARK 0000200
+#define F_NOADDOPT 0000400
+#define F_IGNORELIST 0001000
+#define F_NOCOMLINE 0002000
+#define F_NOKANJICONV 0004000
+#define F_TTYIOMODE 0010000
+#define F_TTYNL 0020000
+#define F_EVALMACRO 0040000
+#define F_DOSYSTEM 0100000
X
X #ifdef _NOORIGSHELL
X typedef struct _aliastable {
@@ -339,10 +342,10 @@
X char *ident;
X } builtintable;
X
-#define F_SYMLINK 001
-#define F_FILETYPE 002
-#define F_DOTFILE 004
-#define F_FILEFLAG 010
+#define F_SYMLINK 001
+#define F_FILETYPE 002
+#define F_DOTFILE 004
+#define F_FILEFLAG 010
X
X #define isdisptyp(n) ((n) & F_FILETYPE)
X #define ishidedot(n) ((n) & F_DOTFILE)
@@ -354,10 +357,48 @@
X #define isfileflg(n) (!archivefile && ((n) & F_FILEFLAG))
X #endif
X
-#define FSID_UFS 1
-#define FSID_EFS 2
-#define FSID_SYSV 3
-#define FSID_FAT 4
-#define FSID_LFN 5
-#define FSID_LINUX 6
-#define FSID_DOSDRIVE 7
+#define FNC_NONE 0
+#define FNC_CANCEL 1
+#define FNC_UPDATE 2
+#define FNC_HELPSPOT 3
+#define FNC_EFFECT 4
+#define FNC_CHDIR 5
+#define FNC_QUIT (-1)
+#define FNC_FAIL (-2)
+
+#define FSID_UFS 1
+#define FSID_EFS 2
+#define FSID_SYSV 3
+#define FSID_FAT 4
+#define FSID_LFN 5
+#define FSID_LINUX 6
+#define FSID_DOSDRIVE 7
+
+#define LCK_READ 0
+#define LCK_WRITE 1
+#define LCK_UNLOCK 2
+
+#define TCH_MODE 00001
+#define TCH_UID 00002
+#define TCH_GID 00004
+#define TCH_ATIME 00010
+#define TCH_MTIME 00020
+#define TCH_FLAGS 00040
+#define TCH_CHANGE 00100
+
+#define ATR_EXCLUSIVE 3
+#define ATR_MODEONLY 1
+#define ATR_TIMEONLY 2
+#define ATR_MULTIPLE 4
+
+#define ORD_NODIR 0
+#define ORD_NORMAL 1
+#define ORD_LOWER 2
+#define ORD_NOPREDIR 3
+
+#define HST_COM 0
+#define HST_PATH 1
+#define HST_USER 2
+#define HST_GROUP 3
+#define nohist(n) ((n) != HST_COM && (n) != HST_PATH)
+#define completable(n) ((n) >= 0)
diff -urNP ../FD-2.07b/unixdisk.c ./unixdisk.c
--- ../FD-2.07b/unixdisk.c Wed Sep 14 00:00:00 2005
+++ ./unixdisk.c Tue Dec 13 00:00:00 2005
@@ -293,7 +293,10 @@
X int isdotdir(s)
X char *s;
X {
- if (s[0] == '.' && (!s[1] || (s[1] == '.' && !s[2]))) return(1);
+ if (s[0] != '.') /*EMPTY*/;
+ else if (!s[1]) return(2);
+ else if (s[1] != '.') /*EMPTY*/;
+ else if (!s[2]) return(1);
X
X return(0);
X }
diff -urNP ../FD-2.07b/unixdisk.h ./unixdisk.h
--- ../FD-2.07b/unixdisk.h Wed Sep 14 00:00:00 2005
+++ ./unixdisk.h Tue Dec 13 00:00:00 2005
@@ -278,15 +278,15 @@
X extern struct dirent *unixreaddir __P_((DIR *));
X extern int unixrewinddir __P_((DIR *));
X #ifdef _NOUSELFN
-#define unixunlink unlink
-#define unixrename rename
+#define unixunlink(p) ((unlink(p)) ? -1 : 0)
+#define unixrename(f, t) ((rename(f, t)) ? -1 : 0)
X # ifdef DJGPP
-# define unixmkdir(p, m) (mkdir(p, m) ? -1 : 0)
+# define unixmkdir(p, m) ((mkdir(p, m)) ? -1 : 0)
X # else
X extern int unixmkdir __P_((char *, int));
X # endif
-#define unixrmdir rmdir
-#define unixchdir chdir
+#define unixrmdir(p) ((rmdir(p)) ? -1 : 0)
+#define unixchdir(p) ((chdir(p)) ? -1 : 0)
X #else
X extern int unixunlink __P_((char *));
X extern int unixrename __P_((char *, char *));
@@ -299,8 +299,8 @@
X extern int unixstat __P_((char *, struct stat *));
X extern int unixchmod __P_((char *, int));
X #ifdef _NOUSELFN
-#define unixutime utime
-#define unixutimes utimes
+#define unixutime(p, t) ((utime(p, t)) ? -1 : 0)
+#define unixutimes(p, t) ((utimes(p, t)) ? -1 : 0)
X #else /* !_NOUSELFN */
X # ifdef USEUTIME
X extern int unixutime __P_((char *, struct utimbuf *));
diff -urNP ../FD-2.07b/unixemu.c ./unixemu.c
--- ../FD-2.07b/unixemu.c Wed Sep 14 00:00:00 2005
+++ ./unixemu.c Tue Dec 13 00:00:00 2005
@@ -171,7 +171,7 @@
X {
X #ifdef _NOROCKRIDGE
X return(unixreaddir(dirp));
-#else
+#else /* !_NOROCKRIDGE */
X static struct dirent buf;
X struct dirent *dp;
X char *src, *dest, path[MAXPATHLEN], conv[MAXPATHLEN];
@@ -224,33 +224,35 @@
X int drive, dd;
X #endif
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
X #ifdef _NODOSDRIVE
- return(rawchdir(path));
-#else
+ n = rawchdir(path);
+#else /* !_NODOSDRIVE */
X if (!(drive = dospath3(path))) {
- if (rawchdir(path) < 0) return(-1);
- if (lastdrv >= 0) shutdrv(lastdrv);
- lastdrv = -1;
- return(0);
+ if ((n = rawchdir(path)) >= 0) {
+ if (lastdrv >= 0) shutdrv(lastdrv);
+ lastdrv = -1;
+ }
X }
-
- if ((dd = preparedrv(drive)) < 0) return(-1);
- if (setcurdrv(drive, 1) < 0
+ else if ((dd = preparedrv(drive)) < 0) n = -1;
+ else if (setcurdrv(drive, 1) < 0
X || (checkpath(path, buf) ? doschdir(buf) : unixchdir(path)) < 0) {
X shutdrv(dd);
- return(-1);
+ n = -1;
X }
- if (lastdrv >= 0) {
- if ((lastdrv % DOSNOFILE) != (dd % DOSNOFILE))
- shutdrv(lastdrv);
- else dd = lastdrv;
+ else {
+ if (lastdrv >= 0) {
+ if ((lastdrv % DOSNOFILE) != (dd % DOSNOFILE))
+ shutdrv(lastdrv);
+ else dd = lastdrv;
+ }
+ lastdrv = dd;
X }
- lastdrv = dd;
-
- return(0);
X #endif /* !_NODOSDRIVE */
+
+ return(n);
X }
X
X char *Xgetwd(path)
@@ -295,10 +297,12 @@
X struct stat *stp;
X {
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
+ n = statcommon(path, stp);
X
- return(statcommon(path, stp));
+ return(n);
X }
X
X int Xlstat(path, stp)
@@ -309,18 +313,19 @@
X char rpath[MAXPATHLEN];
X #endif
X char conv[MAXPATHLEN];
+ int n;
X
X #ifdef _NOROCKRIDGE
X path = convput(conv, path, 1, 0, NULL, NULL);
X #else
X path = convput(conv, path, 1, 0, rpath, NULL);
X #endif
- if (statcommon(path, stp) < 0) return(-1);
+ n = statcommon(path, stp);
X #ifndef _NOROCKRIDGE
- if (*rpath) rrlstat(rpath, stp);
+ if (n >= 0 && *rpath) rrlstat(rpath, stp);
X #endif
X
- return(0);
+ return(n);
X }
X
X int Xaccess(path, mode)
@@ -332,23 +337,25 @@
X #endif
X char *cp, conv[MAXPATHLEN];
X struct stat st;
+ int n;
X
X cp = convput(conv, path, 1, 1, NULL, NULL);
X #ifndef _NOUSELFN
X # ifndef _NODOSDRIVE
- if (checkpath(cp, buf)) return(dosaccess(buf, mode));
+ if (checkpath(cp, buf)) n = dosaccess(buf, mode);
+ else
X # endif
- if (!(cp = preparefile(cp, buf))) return(-1);
+ if (!(cp = preparefile(cp, buf))) n = -1;
+ else
X #endif
- if (access(cp, mode) != 0) return(-1);
-
- if (!(mode & X_OK)) return(0);
- if (Xstat(path, &st) < 0 || !(st.st_mode & S_IEXEC)) {
+ if ((n = (access(cp, mode)) ? -1 : 0) < 0) /*EMPTY*/;
+ else if (!(mode & X_OK)) /*EMPTY*/;
+ else if (Xstat(path, &st) < 0 || !(st.st_mode & S_IEXEC)) {
X errno = EACCES;
- return(-1);
+ n = -1;
X }
X
- return(0);
+ return(n);
X }
X
X /*ARGSUSED*/
@@ -367,15 +374,18 @@
X {
X #ifndef _NOROCKRIDGE
X char conv[MAXPATHLEN], lbuf[MAXPATHLEN];
- int len;
+#endif
+ int n;
X
+ n = -1;
+#ifndef _NOROCKRIDGE
X path = convput(conv, path, 1, 0, lbuf, NULL);
- if (*lbuf && (len = rrreadlink(lbuf, buf, bufsiz)) >= 0)
- return(len);
+ if (*lbuf && (n = rrreadlink(lbuf, buf, bufsiz)) >= 0) /*EMPTY*/;
+ else
X #endif
X errno = EINVAL;
X
- return(-1);
+ return(n);
X }
X
X int Xchmod(path, mode)
@@ -383,10 +393,12 @@
X int mode;
X {
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
+ n = unixchmod(path, mode);
X
- return(unixchmod(path, mode));
+ return(n);
X }
X
X #ifdef USEUTIME
@@ -395,10 +407,12 @@
X struct utimbuf *times;
X {
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
+ n = unixutime(path, times);
X
- return(unixutime(path, times));
+ return(n);
X }
X #else /* !USEUTIME */
X int Xutimes(path, tvp)
@@ -406,42 +420,71 @@
X struct timeval tvp[2];
X {
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
+ n = unixutimes(path, tvp);
X
- return(unixutimes(path, tvp));
+ return(n);
X }
X #endif /* !USEUTIME */
X
+#ifdef HAVEFLAGS
+/*ARGSUSED*/
+int Xchflags(path, flags)
+char *path;
+u_long flags;
+{
+ errno = EACCESS;
+
+ return(-1);
+}
+#endif /* !HAVEFLAGS */
+
+#ifndef NOUID
+/*ARGSUSED*/
+int Xchown(path, uid, gid)
+char *path;
+uid_t uid;
+gid_t gid;
+{
+ errno = EACCESS;
+
+ return(-1);
+}
+#endif /* !NOUID */
+
X int Xunlink(path)
X char *path;
X {
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
- if (unixunlink(path) != 0) {
- if (errno != EACCES
- || unixchmod(path, (S_IREAD | S_IWRITE | S_ISVTX)) < 0
- || unixunlink(path) != 0)
- return(-1);
+ if ((n = unixunlink(path)) < 0) {
+ if (errno == EACCES
+ && unixchmod(path, (S_IREAD | S_IWRITE | S_ISVTX)) >= 0)
+ n = unixunlink(path);
X }
X
- return(0);
+ return(n);
X }
X
X int Xrename(from, to)
X char *from, *to;
X {
X char conv1[MAXPATHLEN], conv2[MAXPATHLEN];
+ int n;
X
X from = convput(conv1, from, 1, 0, NULL, NULL);
X to = convput(conv2, to, 1, 0, NULL, NULL);
X if (dospath(from, NULL) != dospath(to, NULL)) {
X errno = EXDEV;
- return(-1);
+ n = -1;
X }
+ else n = unixrename(from, to);
X
- return(unixrename(from, to) ? -1 : 0);
+ return(n);
X }
X
X int Xopen(path, flags, mode)
@@ -452,26 +495,33 @@
X char buf[MAXPATHLEN];
X #endif
X char conv[MAXPATHLEN];
+ int fd;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
X #ifndef _NOUSELFN
X # ifndef _NODOSDRIVE
- if (checkpath(path, buf)) return(dosopen(buf, flags, mode));
+ if (checkpath(path, buf)) fd = dosopen(buf, flags, mode);
+ else
X # endif
- if (flags & O_CREAT) return(unixopen(path, flags, mode));
- else if (!(path = preparefile(path, buf))) return(-1);
-#endif
+ if (flags & O_CREAT) fd = unixopen(path, flags, mode);
+ else if (!(path = preparefile(path, buf))) fd = -1;
+ else
+#endif /* !_NOUSELFN */
+ fd = open(path, flags, mode);
X
- return(open(path, flags, mode));
+ return(fd);
X }
X
X #ifndef _NODOSDRIVE
X int Xclose(fd)
X int fd;
X {
- if ((fd >= DOSFDOFFSET)) return(dosclose(fd));
+ int n;
X
- return((close(fd) != 0) ? -1 : 0);
+ if (fd >= DOSFDOFFSET) n = dosclose(fd);
+ else n = (close(fd)) ? -1 : 0;
+
+ return(n);
X }
X
X int Xread(fd, buf, nbytes)
@@ -479,9 +529,12 @@
X char *buf;
X int nbytes;
X {
- if ((fd >= DOSFDOFFSET)) return(dosread(fd, buf, nbytes));
+ int n;
+
+ if (fd >= DOSFDOFFSET) n = dosread(fd, buf, nbytes);
+ else n = read(fd, buf, nbytes);
X
- return(read(fd, buf, nbytes));
+ return(n);
X }
X
X int Xwrite(fd, buf, nbytes)
@@ -489,9 +542,12 @@
X char *buf;
X int nbytes;
X {
- if ((fd >= DOSFDOFFSET)) return(doswrite(fd, buf, nbytes));
+ int n;
X
- return(write(fd, buf, nbytes));
+ if (fd >= DOSFDOFFSET) n = doswrite(fd, buf, nbytes);
+ else n = write(fd, buf, nbytes);
+
+ return(n);
X }
X
X off_t Xlseek(fd, offset, whence)
@@ -499,32 +555,41 @@
X off_t offset;
X int whence;
X {
- if ((fd >= DOSFDOFFSET)) return(doslseek(fd, offset, whence));
+ off_t ofs;
+
+ if (fd >= DOSFDOFFSET) ofs = doslseek(fd, offset, whence);
+ else ofs = lseek(fd, offset, whence);
X
- return(lseek(fd, offset, whence));
+ return(ofs);
X }
X
X int Xdup(oldd)
X int oldd;
X {
- if ((oldd >= DOSFDOFFSET)) {
+ int fd;
+
+ if (oldd >= DOSFDOFFSET) {
X errno = EBADF;
- return(-1);
+ fd = -1;
X }
+ else fd = safe_dup(oldd);
X
- return(safe_dup(oldd));
+ return(fd);
X }
X
X int Xdup2(oldd, newd)
X int oldd, newd;
X {
- if (oldd == newd) return(newd);
- if ((oldd >= DOSFDOFFSET || newd >= DOSFDOFFSET)) {
+ int fd;
+
+ if (oldd == newd) fd = newd;
+ else if (oldd >= DOSFDOFFSET || newd >= DOSFDOFFSET) {
X errno = EBADF;
- return(-1);
+ fd = -1;
X }
+ else fd = safe_dup2(oldd, newd);
X
- return(safe_dup2(oldd, newd));
+ return(fd);
X }
X #endif /* !_NODOSDRIVE */
X
@@ -536,26 +601,33 @@
X struct stat st;
X #endif
X char conv[MAXPATHLEN];
+ int n;
X
X #if defined (_NOUSELFN) && !defined (DJGPP)
X if (Xstat(path, &st) >= 0) {
X errno = EEXIST;
- return(-1);
+ n = -1;
X }
+ else
X #endif
- path = convput(conv, path, 1, 1, NULL, NULL);
+ {
+ path = convput(conv, path, 1, 1, NULL, NULL);
+ n = unixmkdir(path, mode);
+ }
X
- return(unixmkdir(path, mode) ? -1 : 0);
+ return(n);
X }
X
X int Xrmdir(path)
X char *path;
X {
X char conv[MAXPATHLEN];
+ int n;
X
X path = convput(conv, path, 1, 1, NULL, NULL);
+ n = unixrmdir(path);
X
- return(unixrmdir(path) ? -1 : 0);
+ return(n);
X }
X
X FILE *Xfopen(path, type)
@@ -564,18 +636,22 @@
X #ifndef _NOUSELFN
X char buf[MAXPATHLEN];
X #endif
+ FILE *fp;
X char conv[MAXPATHLEN];
X
X path = convput(conv, path, 1, 1, NULL, NULL);
X #ifndef _NOUSELFN
X # ifndef _NODOSDRIVE
- if (checkpath(path, buf)) return(dosfopen(buf, type));
+ if (checkpath(path, buf)) fp = dosfopen(buf, type);
+ else
X # endif
- if (*type != 'r' || *(type + 1) == '+') return(unixfopen(path, type));
- else if (!(path = preparefile(path, buf))) return(NULL);
+ if (*type != 'r' || *(type + 1) == '+') fp = unixfopen(path, type);
+ else if (!(path = preparefile(path, buf))) fp = NULL;
+ else
X #endif
+ fp = fopen(path, type);
X
- return(fopen(path, type));
+ return(fp);
X }
X
X #ifndef _NODOSDRIVE
@@ -583,25 +659,45 @@
X int fd;
X char *type;
X {
- if ((fd >= DOSFDOFFSET)) return(dosfdopen(fd, type));
+ FILE *fp;
X
- return(fdopen(fd, type));
+ if (fd >= DOSFDOFFSET) fp = dosfdopen(fd, type);
+ else fp = fdopen(fd, type);
+
+ return(fp);
X }
X
X int Xfclose(stream)
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfclose(stream));
+ int n;
+
+ if (dosfileno(stream) >= 0) n = dosfclose(stream);
+ else n = fclose(stream);
X
- return(fclose(stream));
+ return(n);
+}
+
+int Xfileno(stream)
+FILE *stream;
+{
+ int fd;
+
+ if ((fd = dosfileno(stream)) >= 0) fd += DOSFDOFFSET;
+ else fd = fileno(stream);
+
+ return(fd);
X }
X
X int Xfeof(stream)
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfeof(stream));
+ int n;
X
- return(feof(stream));
+ if (dosfileno(stream) >= 0) n = dosfeof(stream);
+ else n = feof(stream);
+
+ return(n);
X }
X
X int Xfread(buf, size, nitems, stream)
@@ -609,10 +705,12 @@
X int size, nitems;
X FILE *stream;
X {
- if (dosfileno(stream) > 0)
- return(dosfread(buf, size, nitems, stream));
+ int n;
+
+ if (dosfileno(stream) >= 0) n = dosfread(buf, size, nitems, stream);
+ else n = fread(buf, size, nitems, stream);
X
- return(fread(buf, size, nitems, stream));
+ return(n);
X }
X
X int Xfwrite(buf, size, nitems, stream)
@@ -620,35 +718,46 @@
X int size, nitems;
X FILE *stream;
X {
- if (dosfileno(stream) > 0)
- return(dosfwrite(buf, size, nitems, stream));
+ int n;
X
- return(fwrite(buf, size, nitems, stream));
+ if (dosfileno(stream) >= 0) n = dosfwrite(buf, size, nitems, stream);
+ else n = fwrite(buf, size, nitems, stream);
+
+ return(n);
X }
X
X int Xfflush(stream)
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfflush(stream));
+ int n;
+
+ if (dosfileno(stream) >= 0) n = dosfflush(stream);
+ else n = fflush(stream);
X
- return(fflush(stream));
+ return(n);
X }
X
X int Xfgetc(stream)
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfgetc(stream));
+ int c;
X
- return(fgetc(stream));
+ if (dosfileno(stream) >= 0) c = dosfgetc(stream);
+ else c = fgetc(stream);
+
+ return(c);
X }
X
X int Xfputc(c, stream)
X int c;
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfputc(c, stream));
+ int n;
+
+ if (dosfileno(stream) >= 0) n = dosfputc(c, stream);
+ else n = fputc(c, stream);
X
- return(fputc(c, stream));
+ return(n);
X }
X
X char *Xfgets(s, n, stream)
@@ -656,18 +765,24 @@
X int n;
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfgets(s, n, stream));
+ char *cp;
+
+ if (dosfileno(stream) >= 0) cp = dosfgets(s, n, stream);
+ else cp = fgets(s, n, stream);
X
- return(fgets(s, n, stream));
+ return(cp);
X }
X
X int Xfputs(s, stream)
X char *s;
X FILE *stream;
X {
- if (dosfileno(stream) > 0) return(dosfputs(s, stream));
+ int n;
+
+ if (dosfileno(stream) >= 0) n = dosfputs(s, stream);
+ else n = fputs(s, stream);
X
- return(fputs(s, stream));
+ return(n);
X }
X #endif /* !_NODOSDRIVE */
X
@@ -714,7 +829,7 @@
X int no;
X
X no = 0;
- if (fclose(fp) != 0) no = errno;
+ if (fclose(fp)) no = errno;
X if (!deftmpdir || !*deftmpdir || !tmpfilename || !*tmpfilename) {
X errno = ENOENT;
X return(-1);
diff -urNP ../FD-2.07b/version.h ./version.h
--- ../FD-2.07b/version.h Wed Sep 14 00:00:00 2005
+++ ./version.h Tue Dec 13 00:00:00 2005
@@ -5,4 +5,4 @@
X */
X
X char *distributor = NULL;
-static char version[] = "@(#)fd.c 2.07b 09/14/05";
+static char version[] = "@(#)fd.c 2.07c 12/13/05";
SHAR_EOF
$echo 'File' 'FD-2.07c.patch' 'is complete' &&
$shar_touch -am 12110212105 'FD-2.07c.patch' &&
chmod 0644 'FD-2.07c.patch' ||
$echo 'restore of' 'FD-2.07c.patch' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'FD-2.07c.patch:' 'MD5 check failed'
006cb55b39d236ca5b264d01abf5de30 FD-2.07c.patch
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'FD-2.07c.patch'`"
test 189823 -eq "$shar_count" ||
$echo 'FD-2.07c.patch:' 'original size' '189823,' 'current size' "$shar_count!"
fi
fi
$echo 'You have unpacked the last part'
rm -fr _sh00578
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