rip out SHELL_ESCAPE define
[unix-history] / usr / src / usr.bin / window / wwtty.c
index d51e848..c71789c 100644 (file)
@@ -1,6 +1,23 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwtty.c     3.6 84/03/03";
-#endif
+static char sccsid[] = "@(#)wwtty.c    3.12 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "ww.h"
 #include <fcntl.h>
 
 #include "ww.h"
 #include <fcntl.h>
@@ -8,15 +25,15 @@ static       char *sccsid = "@(#)wwtty.c     3.6 84/03/03";
 wwgettty(d, t)
 register struct ww_tty *t;
 {
 wwgettty(d, t)
 register struct ww_tty *t;
 {
-       if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0)
+       if (ioctl(d, TIOCGETP, (char *)&t->ww_sgttyb) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0)
+       if (ioctl(d, TIOCGETC, (char *)&t->ww_tchars) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0)
+       if (ioctl(d, TIOCGLTC, (char *)&t->ww_ltchars) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0)
+       if (ioctl(d, TIOCLGET, (char *)&t->ww_lmode) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
+       if (ioctl(d, TIOCGETD, (char *)&t->ww_ldisc) < 0)
                goto bad;
        if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0)
                goto bad;
                goto bad;
        if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0)
                goto bad;
@@ -26,18 +43,24 @@ bad:
        return -1;
 }
 
        return -1;
 }
 
-wwsettty(d, t)
-register struct ww_tty *t;
+/*
+ * Set the modes of tty 'd' to 't'
+ * 'o' is the current modes.  We set the line discipline only if
+ * it changes, to avoid unnecessary flushing of typeahead.
+ */
+wwsettty(d, t, o)
+register struct ww_tty *t, *o;
 {
 {
-       if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0)
+       if (ioctl(d, TIOCSETN, (char *)&t->ww_sgttyb) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0)
+       if (ioctl(d, TIOCSETC, (char *)&t->ww_tchars) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0)
+       if (ioctl(d, TIOCSLTC, (char *)&t->ww_ltchars) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
+       if (ioctl(d, TIOCLSET, (char *)&t->ww_lmode) < 0)
                goto bad;
                goto bad;
-       if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
+       if ((o == 0 || t->ww_ldisc != o->ww_ldisc) &&
+           ioctl(d, TIOCSETD, (char *)&t->ww_ldisc) < 0)
                goto bad;
        if (fcntl(d, F_SETFL, t->ww_fflags) < 0)
                goto bad;
                goto bad;
        if (fcntl(d, F_SETFL, t->ww_fflags) < 0)
                goto bad;