$NetBSD: patch-ac,v 1.3 2003/11/11 10:42:32 wiz Exp $ --- fep_com.c.orig Wed May 29 07:31:09 1991 +++ fep_com.c @@ -6,7 +6,17 @@ static char rcsid[]= #endif lint #include +#include +#ifdef TERMIOS +#include +#ifdef __linux__ +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE '\0' +#endif +#endif +#else #include +#endif #include #include #include @@ -31,7 +41,7 @@ executeBuiltInFunction (comline, more) char *comline, **more; { register FunctionTableEnt *ftp; - char linebuf[MAXCOMLEN], *line; + char linebuf[MAXCMDLEN], *line; char *search_string(); int argc; @@ -93,7 +103,7 @@ is_same_command (a, b) 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 @@ unalias (comline) set (comline) char *comline; { - char line[MAXCOMLEN]; + char line[MAXCMDLEN]; char *cp, *index(); char *argv[MAXARGS]; int argc; @@ -352,8 +362,13 @@ unset(comline) 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 @@ toggle_through() { int r; int slave_fd; +#ifdef TERMIOS + struct termios s; +#else struct sgttyb s; +#endif if (Through == OFF) { @@ -378,15 +397,26 @@ toggle_through() 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 @@ toggle_through() (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 @@ toggle_through() fix_transparency() { int r; +#ifdef TERMIOS + struct termios s; +#else struct sgttyb s; +#endif if (Through) return; @@ -418,11 +456,17 @@ fix_transparency() 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 @@ fix_transparency() * 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 @@ fix_transparency() } 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 @@ char *line; 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 @@ fep_echo (comline) 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 @@ fep_command (comline) int argc; int i; char **argp; - char *buf[256]; + char buf[256]; argc = mkargv (comline, argv, MAXARGS);