summaryrefslogtreecommitdiff
path: root/misc/fep
diff options
context:
space:
mode:
authorchristos <christos@pkgsrc.org>2000-02-07 03:18:08 +0000
committerchristos <christos@pkgsrc.org>2000-02-07 03:18:08 +0000
commit51d52004ea588488cdd5e1fa0e1587aa68958701 (patch)
tree5172e2829c6076b5eb661b29c8988befb3d20b01 /misc/fep
parentb9aac960113b01f9e971a519bf5b7de108e52f0d (diff)
downloadpkgsrc-51d52004ea588488cdd5e1fa0e1587aa68958701.tar.gz
- fix slews of bugs
- modernize - use termios
Diffstat (limited to 'misc/fep')
-rw-r--r--misc/fep/patches/patch-aa17
-rw-r--r--misc/fep/patches/patch-ab22
-rw-r--r--misc/fep/patches/patch-ac210
-rw-r--r--misc/fep/patches/patch-ad13
-rw-r--r--misc/fep/patches/patch-ae139
-rw-r--r--misc/fep/patches/patch-af30
-rw-r--r--misc/fep/patches/patch-ag13
-rw-r--r--misc/fep/patches/patch-ah16
-rw-r--r--misc/fep/patches/patch-ai65
-rw-r--r--misc/fep/patches/patch-aj348
-rw-r--r--misc/fep/patches/patch-ak79
11 files changed, 945 insertions, 7 deletions
diff --git a/misc/fep/patches/patch-aa b/misc/fep/patches/patch-aa
index 0237d03f6d7..68a9037244c 100644
--- a/misc/fep/patches/patch-aa
+++ b/misc/fep/patches/patch-aa
@@ -1,8 +1,8 @@
-$NetBSD: patch-aa,v 1.3 1998/08/07 11:10:18 agc Exp $
+$NetBSD: patch-aa,v 1.4 2000/02/07 03:18:08 christos Exp $
---- Makefile.orig Thu Jun 10 04:51:22 1993
-+++ Makefile Thu Oct 23 22:50:09 1997
-@@ -15,17 +15,17 @@
+--- Makefile.orig Wed Jun 9 22:51:22 1993
++++ Makefile Sun Feb 6 21:48:47 2000
+@@ -15,17 +15,21 @@
DISTRIBUTION\
= Makefile fep.1 $(HEADER) $(SRC) feprc.sample README
@@ -12,20 +12,23 @@ $NetBSD: patch-aa,v 1.3 1998/08/07 11:10:18 agc Exp $
#STAT = -DSTAT# Delete # for statistic info
#KANJI = -DKANJI# Delete # for KANJI handling
-CONFIG = $(STAT) $(KANJI)
-+CONFIG = $(STAT) $(KANJI) -D_cnt=_r
++CONFIG = $(STAT) $(KANJI) -DTERMIOS
#DEBUG = -g
-DEBUG = -O
+#DEBUG = -O
-CFLAGS = $(DEBUG) $(CONFIG)
--LDFLAGS = -ltermcap
+CFLAGS += $(DEBUG) $(CONFIG)
++.if exists(/usr/lib/libcompat.a)
+LDFLAGS = -ltermcap -lcompat
++.else
+ LDFLAGS = -ltermcap
++.endif
all: $(TARGET)
-@@ -37,7 +37,7 @@
+@@ -37,7 +41,7 @@
install: $(TARGET)
install -s $(TARGET) $(INSTDIR)
diff --git a/misc/fep/patches/patch-ab b/misc/fep/patches/patch-ab
new file mode 100644
index 00000000000..6bee6c49775
--- /dev/null
+++ b/misc/fep/patches/patch-ab
@@ -0,0 +1,22 @@
+$NetBSD: patch-ab,v 1.1 2000/02/07 03:18:10 christos Exp $
+
+--- fep_alias.c.orig Sun Nov 13 01:50:58 1988
++++ fep_alias.c Sun Feb 6 21:07:44 2000
+@@ -18,7 +18,7 @@
+
+ ALIAS alias_top = {"top", "top", (ALIAS *)0};
+ ALIAS *alias_list = &alias_top;
+-CHAR aliased_line[MAXCOMLEN+1];
++CHAR aliased_line[MAXCMDLEN+1];
+
+ /*
+ * Functions
+@@ -44,7 +44,7 @@
+
+ while (isspace (*comline))
+ ++comline;
+- if (*comline == NULL)
++ if (*comline == '\0')
+ return ((CHAR *)0);
+
+ argc = mkargv (comline, argv, MAXARGS);
diff --git a/misc/fep/patches/patch-ac b/misc/fep/patches/patch-ac
new file mode 100644
index 00000000000..f2e2a3307fe
--- /dev/null
+++ b/misc/fep/patches/patch-ac
@@ -0,0 +1,210 @@
+$NetBSD: patch-ac,v 1.1 2000/02/07 03:18:10 christos Exp $
+
+--- fep_com.c.orig Wed May 29 01:31:09 1991
++++ fep_com.c Sun Feb 6 21:47:53 2000
+@@ -6,7 +6,17 @@
+ #endif lint
+
+ #include <stdio.h>
++#include <sys/ioctl.h>
++#ifdef TERMIOS
++#include <termios.h>
++#ifdef __linux__
++#ifndef _POSIX_VDISABLE
++#define _POSIX_VDISABLE '\0'
++#endif
++#endif
++#else
+ #include <sgtty.h>
++#endif
+ #include <ctype.h>
+ #include <sys/param.h>
+ #include <sys/file.h>
+@@ -31,7 +41,7 @@
+ char *comline, **more;
+ {
+ register FunctionTableEnt *ftp;
+- char linebuf[MAXCOMLEN], *line;
++ char linebuf[MAXCMDLEN], *line;
+ char *search_string();
+ int argc;
+
+@@ -93,7 +103,7 @@
+
+ while (*a && *b && *a == *b)
+ ++a, ++b;
+- if ((*a == NULL || isspace (*a)) && (*b == NULL || isspace (*b)))
++ if ((*a == '\0' || isspace ((unsigned char)*a)) && (*b == '\0' || isspace ((unsigned char)*b)))
+ return 1;
+ else
+ return 0;
+@@ -295,7 +305,7 @@
+ set (comline)
+ char *comline;
+ {
+- char line[MAXCOMLEN];
++ char line[MAXCMDLEN];
+ char *cp, *index();
+ char *argv[MAXARGS];
+ int argc;
+@@ -352,8 +362,13 @@
+
+ extern int Transparency;
+ extern int Through;
+-extern struct sgttyb slave_ttymode;
+-extern struct sgttyb master_ttymode;
++#ifdef TERMIOS
++#define ttystruct termios
++#elif defined(TIOCSETN)
++#define ttystruct sgttyb
++#endif
++struct ttystruct master_ttymode; /* master tty mode */
++struct ttystruct slave_ttymode; /* slave tty mode */
+ extern int master, slave;
+ extern char slave_tty[];
+
+@@ -368,7 +383,11 @@
+ {
+ int r;
+ int slave_fd;
++#ifdef TERMIOS
++ struct termios s;
++#else
+ struct sgttyb s;
++#endif
+
+ if (Through == OFF) {
+
+@@ -378,15 +397,26 @@
+ return;
+ }
+
++#ifdef TERMIOS
++ r = tcgetattr(slave_fd, &s);
++#else
+ r = ioctl (slave_fd, TIOCGETP, (char *) &s);
++#endif
+ if (r < 0) {
+ perror (slave_tty);
+ (void) close (slave_fd);
+ return;
+ }
+
++#ifdef TERMIOS
++ s.c_lflag &= ~(ICANON);
++ s.c_cc[VMIN] = 1;
++ s.c_cc[VTIME] = 0;
++ r = tcsetattr(0, TCSANOW, &s);
++#else
+ s.sg_flags |= CBREAK;
+ r = ioctl (0, TIOCSETN, (char *) & s);
++#endif
+ if (r < 0) {
+ perror (slave_tty);
+ (void) close (slave_fd);
+@@ -394,7 +424,11 @@
+ (void) close (slave_fd);
+ }
+ else
++#ifdef TERMIOS
++ r = tcsetattr(0, TCSANOW, & master_ttymode);
++#else
+ r = ioctl (0, TIOCSETN, (char *) & master_ttymode);
++#endif
+
+ if (r < 0) {
+ printf ("Can't change pty mode.\n");
+@@ -410,7 +444,11 @@
+ fix_transparency()
+ {
+ int r;
++#ifdef TERMIOS
++ struct termios s;
++#else
+ struct sgttyb s;
++#endif
+
+ if (Through)
+ return;
+@@ -418,11 +456,17 @@
+ if (slave < 0)
+ return;
+
++#ifdef TERMIOS
++ r = tcgetattr(slave, &s);
++ s.c_iflag |= ICRNL;
++ s.c_oflag |= ONLCR;
++#else
+ r = ioctl (slave, TIOCGETP, (char *) &s);
+ /*
+ * slave CRMOD is off, but master should be.
+ */
+ s.sg_flags |= CRMOD;
++#endif
+ if (r < 0) {
+ perror (slave_tty);
+ return;
+@@ -432,9 +476,19 @@
+ * If find slave tty mode is cbreak or raw, fix tty mode of stdout to
+ * same mode as slave and set Transparency ON.
+ */
+- if (s.sg_flags & (CBREAK|RAW)) {
++
++#ifdef TERMIOS
++ if ((s.c_lflag & ICANON) == 0)
++#else
++ if (s.sg_flags & (CBREAK|RAW))
++#endif
++ {
+ if (Transparency == OFF) {
++#ifdef TERMIOS
++ r = tcsetattr(0, TCSANOW, & s);
++#else
+ r = ioctl (0, TIOCSETN, (char *) & s);
++#endif
+ if (r < 0) {
+ perror ("stdout");
+ return;
+@@ -445,7 +499,11 @@
+ }
+ else {
+ if (Transparency == ON) {
+- r = ioctl (0, TIOCSETN, (char *) &master_ttymode);
++#ifdef TERMIOS
++ r = tcsetattr(0, TCSANOW, & master_ttymode);
++#else
++ r = ioctl (0, TIOCSETN, (char *) & master_ttymode);
++#endif
+ if (r < 0) {
+ perror ("stdout");
+ return;
+@@ -738,9 +796,9 @@
+ fep_pwd (line)
+ char *line;
+ {
+- char cwd[MAXPATHLEN], *getwd();
++ char cwd[MAXPATHLEN];
+
+- (void) getwd (cwd);
++ (void) getcwd (cwd, sizeof(cwd));
+ printf ("%s\n", cwd);
+ }
+
+@@ -755,7 +813,7 @@
+ argc = mkargv (comline, argv, MAXARGS);
+
+ argp = &argv[1];
+- if (*argp && strcmp (*argp, "-n") == NULL) {
++ if (*argp && strcmp (*argp, "-n") == 0) {
+ putnewline = 0;
+ ++argp;
+ }
+@@ -791,7 +849,7 @@
+ int argc;
+ int i;
+ char **argp;
+- char *buf[256];
++ char buf[256];
+
+ argc = mkargv (comline, argv, MAXARGS);
+
diff --git a/misc/fep/patches/patch-ad b/misc/fep/patches/patch-ad
new file mode 100644
index 00000000000..4aa9229a8c1
--- /dev/null
+++ b/misc/fep/patches/patch-ad
@@ -0,0 +1,13 @@
+$NetBSD: patch-ad,v 1.1 2000/02/07 03:18:11 christos Exp $
+
+--- fep_defs.h.orig Mon May 10 01:23:33 1993
++++ fep_defs.h Sun Feb 6 21:07:33 2000
+@@ -5,7 +5,7 @@
+ "$Header: /cvsroot/pkgsrc/misc/fep/patches/patch-ad,v 1.1 2000/02/07 03:18:11 christos Exp $ (SRA)"
+ #endif lint
+
+-#define MAXCOMLEN 512 /* maximum command length */
++#define MAXCMDLEN 512 /* maximum command length */
+ #define MAXARGS 64 /* maximum number of arguments */
+ #define ON 1 /* on switch */
+ #define OFF 0 /* off switch */
diff --git a/misc/fep/patches/patch-ae b/misc/fep/patches/patch-ae
new file mode 100644
index 00000000000..3075c3a5a0e
--- /dev/null
+++ b/misc/fep/patches/patch-ae
@@ -0,0 +1,139 @@
+$NetBSD: patch-ae,v 1.1 2000/02/07 03:18:11 christos Exp $
+
+--- fep_edit.c.orig Fri Jan 20 03:16:37 1995
++++ fep_edit.c Sun Feb 6 21:46:22 2000
+@@ -8,7 +8,17 @@
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
++#include <sys/ioctl.h>
++#ifdef TERMIOS
++#include <termios.h>
++#ifdef __linux__
++#ifndef _POSIX_VDISABLE
++#define _POSIX_VDISABLE '\0'
++#endif
++#endif
++#else
+ #include <sgtty.h>
++#endif
+ #include <sys/time.h>
+ #include <ctype.h>
+ #include <sys/dir.h>
+@@ -25,7 +35,7 @@
+ EDITMODE editmode = NOTYET; /* edtimode EMACS, VI */
+ EDITSTATUS editstatus = NOTEDITING;/* EDITING, NOTEDITING */
+
+-int maxline = MAXCOMLEN; /* maximum length of command line */
++int maxline = MAXCMDLEN; /* maximum length of command line */
+ int NeedNewLine; /* add new line flag */
+ int NeedSave; /* need to save to history */
+ int Transparency = OFF; /* transparent flag */
+@@ -86,7 +96,7 @@
+ /* ^X-^V */ {"\\^X\\^V", view_buffer},
+ /* ^X-^K */ {"\\^X\\^K", kill_to_top_of_line},
+ /* ^X-^L */ {"\\^X\\^L", fep_repaint},
+- /* ^X-^C */ {"\\^X\\^C", terminate},
++ /* ^X-^C */ {"\\^X\\^C", (FUNC)terminate},
+ /* ^X-^D */ {"\\^X\\^D", send_eof},
+ /* ^X-( */ {"\\^X(", fep_start_script},
+ /* ^X-) */ {"\\^X)", fep_end_script},
+@@ -192,6 +202,30 @@
+
+ #define import(table,key,fn) if((int)key>0)table[(int)key]=fn
+
++#ifdef TERMIOS
++ /* Now, using cbreak mode
++ import (cft, initial_ttymode.c_cc[VSTART], ignore);
++ import (cft, initial_ttymode.c_cc[VSTOP], ignore);
++ */
++ import (cft, initial_ttymode.c_cc[VINTR], insert_and_flush);
++ import (cft, initial_ttymode.c_cc[VQUIT], insert_and_flush);
++ /* Now, EOF will be sent on empty line.
++ import (cft, initial_ttymode.c_cc[VEOF], send_eof);
++ */
++#ifdef VSWTC
++ import (cft, initial_ttymode.c_cc[VSWTC], insert_and_flush);
++#endif
++ import (cft, initial_ttymode.c_cc[VSUSP], insert_and_flush);
++ /* ^Y is used for yank-from-kill-buffer
++ import (cft, initial_ttymode.c_cc[VDSUSP], self_insert);
++ */
++ import (cft, initial_ttymode.c_cc[VREPRINT], reprint);
++ import (cft, initial_ttymode.c_cc[VDISCARD], self_insert);
++ import (cft, initial_ttymode.c_cc[VWERASE], delete_previous_word);
++ import (cft, initial_ttymode.c_cc[VLNEXT], literal_next);
++ import (cft, initial_ttymode.c_cc[VERASE], delete_previous_character);
++ import (cft, initial_ttymode.c_cc[VKILL], delete_line);
++#else
+ /* Now, using cbreak mode
+ import (cft, tchars_buf.t_startc, ignore);
+ import (cft, tchars_buf.t_stopc, ignore);
+@@ -212,6 +246,7 @@
+ import (cft, ltchars_buf.t_lnextc, literal_next);
+ import (cft, initial_ttymode.sg_erase, delete_previous_character);
+ import (cft, initial_ttymode.sg_kill, delete_line);
++#endif
+
+ #undef import
+
+@@ -257,7 +292,7 @@
+ */
+ swallow_output();
+
+- if (fgets (CommandLine, MAXCOMLEN, redirect_fp)) {
++ if (fgets (CommandLine, MAXCMDLEN, redirect_fp)) {
+ ++redirect_line;
+ execute_command = CommandLine;
+ goto RETURN;
+@@ -301,7 +336,11 @@
+ * call send_eof
+ */
+ if (
++#ifdef TERMIOS
++ c == initial_ttymode.c_cc[VEOF]
++#else
+ c == tchars_buf.t_eofc
++#endif
+ && curFuncTab[c] != send_eof
+ && ! look_var ("ignore-eof")
+ && CommandLine [0] == '\0'
+@@ -1481,7 +1520,11 @@
+ */
+ send_eof()
+ {
++#ifdef TERMIOS
++ char c = initial_ttymode.c_cc[VEOF];
++#else
+ char c = tchars_buf.t_eofc;
++#endif
+
+ (void) self_insert (c);
+ if (isctlchar (c))
+@@ -1754,7 +1797,7 @@
+ fileList [i] = (char *) 0;
+
+ if (*start_expand == '~' && look_var ("expand-tilde")) {
+- char *buf [256], *p;
++ char buf [256], *p;
+
+ strcpy (buf, start_expand);
+ p = x_dirname (buf);
+@@ -2032,7 +2075,7 @@
+ {
+ char tmps[16];
+
+- if (s[0] == '\\' && s[1] == '^' && s[2] != NULL) {
++ if (s[0] == '\\' && s[1] == '^' && s[2] != '\0') {
+ tmps[0] = toctrl (s[2]);
+ strcpy (&tmps[1], &s[3]);
+ s = tmps;
+@@ -2042,7 +2085,7 @@
+ * If the string contain only one character, put the function to
+ * appropriate position in the table.
+ */
+- if (*(s+1) == NULL) {
++ if (*(s+1) == '\0') {
+ if (isIndirect (ft[(int) *s]))
+ free (maskIndirect (ft[(int) *s]));
+
diff --git a/misc/fep/patches/patch-af b/misc/fep/patches/patch-af
new file mode 100644
index 00000000000..b4a58e79f31
--- /dev/null
+++ b/misc/fep/patches/patch-af
@@ -0,0 +1,30 @@
+$NetBSD: patch-af,v 1.1 2000/02/07 03:18:12 christos Exp $
+
+--- fep_funcs.c.orig Wed May 29 01:31:18 1991
++++ fep_funcs.c Sun Feb 6 22:14:13 2000
+@@ -6,6 +6,7 @@
+ #endif lint
+
+ #include <stdio.h>
++#include "fep_defs.h"
+ #include "fep_funcs.h"
+
+ /*
+@@ -94,7 +95,7 @@
+ "Expand file name"},
+ {list_file_name, "list-file-name",
+ "List file name"},
+- {terminate, "terminate",
++ {(FUNC)terminate, "terminate",
+ "Terminate fep"},
+ {suspend, "suspend",
+ "Suspend fep"},
+@@ -193,7 +194,7 @@
+ "Operation \"else\""},
+ {fep_endif, "fep-endif",
+ "Operation \"endif\""},
+- {terminate, "fep-exit",
++ {(FUNC)terminate, "fep-exit",
+ "Terminate fep"},
+ {suspend, "fep-suspend",
+ "Suspend fep"},
diff --git a/misc/fep/patches/patch-ag b/misc/fep/patches/patch-ag
new file mode 100644
index 00000000000..6e509dc14a2
--- /dev/null
+++ b/misc/fep/patches/patch-ag
@@ -0,0 +1,13 @@
+$NetBSD: patch-ag,v 1.1 2000/02/07 03:18:12 christos Exp $
+
+--- fep_funcs.h.orig Wed May 29 01:31:20 1991
++++ fep_funcs.h Sun Jan 23 20:05:24 2000
+@@ -22,7 +22,7 @@
+ int delete_previous_word();
+ int delete_previous_Word();
+ int delete_to_kill_buffer();
+-int terminate();
++void terminate __P((int));
+ int end_of_line();
+ int expand_file_name();
+ int forward_character();
diff --git a/misc/fep/patches/patch-ah b/misc/fep/patches/patch-ah
new file mode 100644
index 00000000000..8a83bc16852
--- /dev/null
+++ b/misc/fep/patches/patch-ah
@@ -0,0 +1,16 @@
+$NetBSD: patch-ah,v 1.1 2000/02/07 03:18:12 christos Exp $
+
+--- fep_glob.h.orig Sun Aug 28 01:36:43 1988
++++ fep_glob.h Sun Feb 6 21:01:37 2000
+@@ -29,6 +29,11 @@
+ * tty control caracters.
+ * defined in fep_main.c
+ */
++#ifdef TERMIOS
++extern struct termios initial_ttymode;
++#elif defined(TIOCSETN)
+ extern struct tchars tchars_buf;
+ extern struct ltchars ltchars_buf;
+ extern struct sgttyb initial_ttymode;
++#endif
++
diff --git a/misc/fep/patches/patch-ai b/misc/fep/patches/patch-ai
new file mode 100644
index 00000000000..f2f538c5baf
--- /dev/null
+++ b/misc/fep/patches/patch-ai
@@ -0,0 +1,65 @@
+$NetBSD: patch-ai,v 1.1 2000/02/07 03:18:13 christos Exp $
+
+--- fep_hist.c.orig Fri Nov 25 06:45:42 1988
++++ fep_hist.c Sun Feb 6 21:08:02 2000
+@@ -6,6 +6,8 @@
+ #endif lint
+
+ #include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
+ #include <ctype.h>
+ #include "fep_defs.h"
+ #include "fep_glob.h"
+@@ -255,7 +257,7 @@
+
+ default:
+ {
+- char *buf[64];
++ char buf[64];
+
+ strcpy (buf, "^");
+ strncat (buf, string, 64);
+@@ -267,6 +269,7 @@
+
+ char *
+ search_reverse_history (string)
++ char *string;
+ {
+ register int i;
+ char *re_comp();
+@@ -291,6 +294,7 @@
+
+ char *
+ search_forward_history (string)
++ char *string;
+ {
+ register int i;
+ char *re_comp();
+@@ -412,7 +416,7 @@
+ mk_home_relative (cp)
+ char *cp;
+ {
+- char buf[256];
++ static char buf[256];
+
+ /*
+ * If variable "history-file" is not absolute path name,
+@@ -540,7 +544,7 @@
+ char *file;
+ {
+ FILE *fp;
+- char line [MAXCOMLEN];
++ char line [MAXCMDLEN];
+ register int i;
+
+ if ((fp = fopen (file, "r")) == NULL) {
+@@ -550,7 +554,7 @@
+ return;
+ }
+
+- while (fgets (line, MAXCOMLEN, fp)) {
++ while (fgets (line, MAXCMDLEN, fp)) {
+ i = strlen (line) - 1;
+ if (line [i] == '\n')
+ line [i] = '\0';
diff --git a/misc/fep/patches/patch-aj b/misc/fep/patches/patch-aj
new file mode 100644
index 00000000000..caaafaa43a4
--- /dev/null
+++ b/misc/fep/patches/patch-aj
@@ -0,0 +1,348 @@
+$NetBSD: patch-aj,v 1.1 2000/02/07 03:18:13 christos Exp $
+
+--- fep_main.c.orig Wed Jun 9 22:53:06 1993
++++ fep_main.c Sun Feb 6 22:00:22 2000
+@@ -10,8 +10,17 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/ioctl.h>
+-#include <sys/file.h>
++#ifdef TERMIOS
++#include <termios.h>
++#ifdef __linux__
++#ifndef _POSIX_VDISABLE
++#define _POSIX_VDISABLE '\0'
++#endif
++#endif
++#else
+ #include <sgtty.h>
++#endif
++#include <sys/file.h>
+ #include <sys/time.h>
+ #include <sys/resource.h>
+ #include <sys/errno.h>
+@@ -38,9 +47,9 @@
+ /* delimiter characters */
+ int master; /* file discriptor for pty master */
+ int slave; /* file discriptor for pty slave */
+-int mastermask; /* 1<<master */
+-int stdinmask; /* 1<<fileno(stdin) */
+-int selectmask; /* stdinmask | mastermask */
++fd_set mastermask; /* 1<<master */
++fd_set stdinmask; /* 1<<fileno(stdin) */
++fd_set selectmask; /* stdinmask | mastermask */
+ int selectnfds; /* max (fileno(stdin), master) + 1*/
+ int child_pid; /* child pid */
+ int ptyflag = ON; /* flag to use pty or not */
+@@ -48,21 +57,28 @@
+ int debug = OFF; /* debug switch */
+ int auto_tty_fix = ON; /* fix tty mode automaticaly */
+ FILE *script_fp = NULL; /* script file pointer */
+-int catchsig(); /* function take care SIGCHILD */
++void catchsig __P((int)); /* function take care SIGCHILD */
+
+-struct sgttyb initial_ttymode; /* initial tty mode */
+-struct sgttyb master_ttymode; /* master tty mode */
+-struct sgttyb slave_ttymode; /* slave tty mode */
++#ifdef TERMIOS
++#define ttystruct termios
++#elif defined(TIOCSETN)
++#define ttystruct sgttyb
++#endif
++struct ttystruct initial_ttymode; /* initial tty mode */
++struct ttystruct master_ttymode; /* master tty mode */
++struct ttystruct slave_ttymode; /* slave tty mode */
+
+ int lines; /* terminal line size */
+ int columns; /* terminal coulumn size */
+ char *term_clear; /* terminal clear code */
+
+-void (*sighup)(), (*sigchld)(), (*sigtstp)();
++void (*sighup) __P((int)), (*sigchld) __P((int)), (*sigtstp) __P((int));
+ /* function buffer for signal */
+
++#ifdef TIOCSETN
+ struct tchars tchars_buf; /* tty characters */
+ struct ltchars ltchars_buf; /* tty characters */
++#endif
+ int lmode_buf; /* local mode */
+ int line_desc; /* line descipline */
+ #ifdef KANJI
+@@ -112,6 +128,10 @@
+
+ myself = argv[0];
+
++ setvbuf(stdin, NULL, _IONBF, 0);
++ setvbuf(stdout, NULL, _IONBF, 0);
++ setvbuf(stderr, NULL, _IONBF, 0);
++
+ /*
+ * Initialize binding table
+ */
+@@ -276,7 +296,7 @@
+ fix_signal ()
+ {
+ #ifdef SIGWINCH
+- int sigwinch();
++ void sigwinch __P((int));
+ #endif
+
+ sighup = signal (SIGHUP, terminate);
+@@ -336,7 +356,7 @@
+ if (Through == OFF && Transparency == OFF && script_fp)
+ fwrite (inputline, sizeof(CHAR), strlen (inputline), script_fp);
+ }
+- terminate ();
++ terminate (0);
+ }
+
+ #define INPUT_BUFFER_SIZE 1024
+@@ -384,7 +404,8 @@
+ {
+ char c;
+ int n;
+- int nfound, readfd, writefd = 0, execptfd = 0;
++ int nfound;
++ fd_set readfd, writefd, exceptfd;
+ #ifdef USE_TIMEOUT
+ struct timeval **timeout = auto_tty_fix ? timeout_list : notimeout;
+ #else
+@@ -396,9 +417,8 @@
+ /*
+ * Sorry, this cording depends to an implementation of getc().
+ */
+-# define CHAR_IN_BUFFER (stdin->_cnt)
+- if (CHAR_IN_BUFFER)
+- goto RETURNCHAR;
++ FD_ZERO(&writefd);
++ FD_ZERO(&exceptfd);
+
+ RETRY:
+ readfd = selectmask;
+@@ -409,13 +429,13 @@
+ while ((nfound = select (selectnfds, &readfd, 0, 0, *timeout)) < 0)
+ if (errno != EINTR) {
+ perror ("select");
+- terminate();
++ terminate(0);
+ }
+
+ /*
+ * Found output from pty.
+ */
+- if (readfd & mastermask) {
++ if (FD_ISSET(master, &readfd)) {
+ int nbyte;
+
+ /*
+@@ -451,7 +471,7 @@
+ /*
+ * Found input from terminal
+ */
+- if (CHAR_IN_BUFFER || readfd & stdinmask) {
++ if (FD_ISSET(fileno(stdin), &readfd)) {
+
+ #ifndef USE_TIMEOUT
+ /*
+@@ -468,7 +488,7 @@
+ if ((c = getc (stdin)) == EOF) {
+ if (debug)
+ printf ("EOF chatched\n");
+- terminate ();
++ terminate (0);
+ }
+ else
+ return (c & CHARMASK);
+@@ -596,7 +616,7 @@
+
+ swallow_output()
+ {
+- int readfd = mastermask;
++ fd_set readfd = mastermask;
+ int r;
+ int nbyte;
+ int ncount = 10;
+@@ -604,7 +624,7 @@
+ while (
+ ncount-- &&
+ select (selectnfds, &readfd, 0, 0, TIMEOUT_NOBLOCK) > 0 &&
+- readfd & mastermask
++ FD_ISSET(master, &mastermask)
+ ) {
+ nbyte = buf_read (master, output_buffer);
+ if (nbyte > 0) {
+@@ -636,9 +656,11 @@
+ #include <sys/m_wait.h>
+ #endif
+
+-catchsig()
++void
++catchsig(n)
++ int n;
+ {
+- union wait status;
++ int status;
+ struct rusage ru;
+
+ if (wait3 (&status, WNOHANG | WUNTRACED, &ru) != child_pid)
+@@ -650,7 +672,7 @@
+ suspend ();
+ return;
+ }
+- terminate ();
++ terminate (0);
+ }
+
+ exec_to_command(argv)
+@@ -675,13 +697,37 @@
+ dup2 (slave, 2);
+ (void) close (slave);
+
++#ifdef TERMIOS
++ tcsetattr(0, TCSANOW, &slave_ttymode);
++#elif defined(TIOCSETN)
+ ioctl (0, TIOCSETN, (char *) & slave_ttymode);
+-
++#endif
+ execvp (*argv, argv, 0);
+ perror (*argv);
+ exit (1);
+ }
+
++#ifdef TERMIOS
++fix_tty()
++{
++ int i;
++ master_ttymode = initial_ttymode;
++ slave_ttymode = initial_ttymode;
++ master_ttymode.c_lflag &= ~(ECHO|ECHOE|ECHOK|ICANON);
++
++ for (i = 0; i < NCCS; i++)
++ master_ttymode.c_cc[i] = _POSIX_VDISABLE;
++
++ master_ttymode.c_cc[VMIN] = 1;
++ master_ttymode.c_cc[VTIME] = 0;
++ slave_ttymode.c_lflag &= ~(ECHO|ECHOE|ECHOK);
++ slave_ttymode.c_iflag &= ~(ICRNL);
++ slave_ttymode.c_oflag &= ~(ONLCR);
++ tcsetattr(0, TCSANOW, &master_ttymode);
++}
++
++#elif defined(TIOCSETN)
++
+ fix_tty()
+ {
+ struct tchars tcbuf;
+@@ -719,6 +765,7 @@
+ ioctl (0, TIOCSETC, (char *) & tcbuf);
+ ioctl (0, TIOCSLTC, (char *) & lcbuf);
+ }
++#endif
+
+ kill_process()
+ {
+@@ -727,7 +774,9 @@
+ (void) killpg (child_pid, SIGTERM);
+ }
+
+-terminate()
++void
++terminate(n)
++ int n;
+ {
+ extern int errno;
+
+@@ -759,9 +808,13 @@
+ if (killpg (child_pid, SIGKILL) < 0)
+ perror ("kill");
+
++#ifdef TERMIOS
++ tcsetattr(0, TCSANOW, &initial_ttymode);
++#elif defined(TIOCSETN)
+ ioctl (0, TIOCSETN, (char *) & initial_ttymode);
+ ioctl (0, TIOCSETC, (char *) & tchars_buf);
+ ioctl (0, TIOCSLTC, (char *) & ltchars_buf);
++#endif
+ exit (0);
+ }
+
+@@ -796,11 +849,15 @@
+ }
+
+ FOUND:
++#ifdef TERMIOS
++ tcgetattr(0, &initial_ttymode);
++#elif defined(TIOCSETN)
+ ioctl (0, TIOCGETP, (char *) &initial_ttymode);
+ ioctl (0, TIOCGETC, (char *) &tchars_buf);
+ ioctl (0, TIOCGETD, (char *) &line_desc);
+ ioctl (0, TIOCGLTC, (char *) &ltchars_buf);
+ ioctl (0, TIOCLGET, (char *) &lmode_buf);
++#endif
+
+ #ifdef TIOCGWINSZ
+ {
+@@ -822,9 +879,13 @@
+ # endif
+ #endif KANJI
+
+- stdinmask = 1 << fileno (stdin);
+- mastermask = 1 << master;
+- selectmask = stdinmask | mastermask;
++ FD_ZERO(&stdinmask);
++ FD_ZERO(&mastermask);
++ FD_ZERO(&selectmask);
++ FD_SET(fileno(stdin), &stdinmask);
++ FD_SET(master, &mastermask);
++ FD_SET(fileno(stdin), &selectmask);
++ FD_SET(master, &selectmask);
+ selectnfds = max (fileno(stdin), master) + 1;
+
+ return;
+@@ -838,11 +899,15 @@
+ perror (slave_tty);
+ exit (1);
+ }
++#ifdef TERMIOS
++ tcsetattr(slave, TCSANOW, &initial_ttymode);
++#elif defined(TIOCSETN)
+ ioctl (slave, TIOCSETN, (char *) &initial_ttymode);
+ ioctl (slave, TIOCSETC, (char *) &tchars_buf);
+ ioctl (slave, TIOCSLTC, (char *) &ltchars_buf);
+ ioctl (slave, TIOCLSET, (char *) &lmode_buf);
+ ioctl (slave, TIOCSETD, (char *) &line_desc);
++#endif
+
+ #ifdef KANJI
+ # if defined(TIOCKGET) && defined(TIOCKSET)
+@@ -866,16 +931,19 @@
+
+ recover_tty()
+ {
+-
++#ifdef TERMIOS
++ tcsetattr(0, TCSANOW, &initial_ttymode);
++#elif defined(TIOCSETN)
+ ioctl (0, TIOCSETN, (char *) & initial_ttymode);
+ ioctl (0, TIOCSETC, (char *) & tchars_buf);
+ ioctl (0, TIOCSLTC, (char *) & ltchars_buf);
++#endif
+ }
+
+ suspend()
+ {
+ long pid;
+- void (*func) ();
++ void (*func) __P((int));
+ int omask;
+ extern int errno;
+
+@@ -890,7 +958,7 @@
+
+ if (kill (child_pid, SIGCONT) < 0 && errno == ESRCH) {
+ printf ("Where my child has gone?!\n");
+- terminate ();
++ terminate (0);
+ }
+ killpg (child_pid, SIGCONT);
+ kill (0, SIGCONT);
diff --git a/misc/fep/patches/patch-ak b/misc/fep/patches/patch-ak
new file mode 100644
index 00000000000..1884491777d
--- /dev/null
+++ b/misc/fep/patches/patch-ak
@@ -0,0 +1,79 @@
+$NetBSD: patch-ak,v 1.1 2000/02/07 03:18:14 christos Exp $
+
+--- fep_vi.c.orig Wed May 29 01:31:27 1991
++++ fep_vi.c Sun Feb 6 21:46:29 2000
+@@ -6,7 +6,17 @@
+ #endif lint
+
+ #include <stdio.h>
++#include <sys/ioctl.h>
++#ifdef TERMIOS
++#include <termios.h>
++#ifdef __linux__
++#ifndef _POSIX_VDISABLE
++#define _POSIX_VDISABLE '\0'
++#endif
++#endif
++#else
+ #include <sgtty.h>
++#endif
+ #include <ctype.h>
+ #include "fep_defs.h"
+ #include "fep_glob.h"
+@@ -107,7 +117,7 @@
+ /* ^X-^V */ {"\\^X\\^V", view_buffer},
+ /* ^X-^X */ {"\\^X\\^X", expand_file_name},
+ /* ^X-? */ {"\\^X?", show_bindings},
+- /* ^X-^C */ {"\\^X\\^C", terminate},
++ /* ^X-^C */ {"\\^X\\^C", (FUNC)terminate},
+ /* ^X-^D */ {"\\^X\\^D", send_eof},
+ /* ^X-( */ {"\\^X(", fep_start_script},
+ /* ^X-) */ {"\\^X)", fep_end_script},
+@@ -138,7 +148,7 @@
+ /* ^X-^L */ {"\\^X\\^L", fep_repaint},
+ /* ^X-^X */ {"\\^X\\^X", expand_file_name},
+ /* ^X-? */ {"\\^X?", show_bindings},
+- /* ^X-^C */ {"\\^X\\^C", terminate},
++ /* ^X-^C */ {"\\^X\\^C", (FUNC)terminate},
+ /* ^X-^D */ {"\\^X\\^D", send_eof},
+ /* ^X-^V */ {"\\^X\\^V", view_buffer},
+ /* ^X-( */ {"\\^X(", fep_start_script},
+@@ -161,7 +171,29 @@
+ cft[i] = self_insert;
+
+ #define import(table,key,fn) if((int)key>0)table[(int)key]=fn
+-
++#ifdef TERMIOS
++ /* Now, using cbreak mode
++ import (cft, initial_ttymode.c_cc[VSTART], ignore);
++ import (cft, initial_ttymode.c_cc[VSTOP], ignore);
++ */
++ import (cft, initial_ttymode.c_cc[VINTR], insert_and_flush);
++ import (aft, initial_ttymode.c_cc[VINTR], insert_and_flush);
++ import (cft, initial_ttymode.c_cc[VQUIT], insert_and_flush);
++ import (cft, initial_ttymode.c_cc[VEOF], send_eof);
++#ifdef VSWTC
++ import (cft, initial_ttymode.c_cc[VSWTC], insert_and_flush);
++#endif
++ import (cft, initial_ttymode.c_cc[VSUSP], insert_and_flush);
++#ifdef VDSUSP
++ import (cft, initial_ttymode.c_cc[VDSUSP], self_insert);
++#endif
++ import (cft, initial_ttymode.c_cc[VREPRINT], reprint);
++ import (cft, initial_ttymode.c_cc[VDISCARD], self_insert);
++ import (cft, initial_ttymode.c_cc[VWERASE], delete_previous_word);
++ import (cft, initial_ttymode.c_cc[VLNEXT], literal_next);
++ import (cft, initial_ttymode.c_cc[VERASE], delete_previous_character);
++ import (cft, initial_ttymode.c_cc[VKILL], delete_line);
++#else
+ /* Now, using cbreak mode
+ import (cft, tchars_buf.t_startx, ignore);
+ import (cft, tchars_buf.t_stopc, ignore);
+@@ -179,6 +211,7 @@
+ import (cft, ltchars_buf.t_lnextc, literal_next);
+ import (cft, initial_ttymode.sg_erase, delete_previous_character);
+ import (cft, initial_ttymode.sg_kill, delete_line);
++#endif
+
+ #undef import
+