we don't flush typeahead any more
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 21 Nov 1984 15:40:29 +0000 (07:40 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 21 Nov 1984 15:40:29 +0000 (07:40 -0800)
SCCS-vsn: usr.bin/window/main.c 3.27
SCCS-vsn: usr.bin/window/wwend.c 3.6
SCCS-vsn: usr.bin/window/wwinit.c 3.22
SCCS-vsn: usr.bin/window/wwopen.c 3.18
SCCS-vsn: usr.bin/window/wwtty.c 3.8
SCCS-vsn: usr.bin/window/lcmd1.c 3.27
SCCS-vsn: usr.bin/window/mloop.c 3.6
SCCS-vsn: usr.bin/window/wwsuspend.c 3.6

usr/src/usr.bin/window/lcmd1.c
usr/src/usr.bin/window/main.c
usr/src/usr.bin/window/mloop.c
usr/src/usr.bin/window/wwend.c
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwopen.c
usr/src/usr.bin/window/wwsuspend.c
usr/src/usr.bin/window/wwtty.c

index 38addc6..2e034ef 100644 (file)
@@ -18,7 +18,7 @@ struct lcmd_arg arg_window[] = {
        { "pty",        1,      ARG_ANY },
        { "frame",      1,      ARG_ANY },
        { "mapnl",      1,      ARG_ANY },
        { "pty",        1,      ARG_ANY },
        { "frame",      1,      ARG_ANY },
        { "mapnl",      1,      ARG_ANY },
-       { "shell",      1,      ARG_ANY|ARG_LIST },
+       { "shell",      1,      ARG_STR|ARG_LIST },
        0
 };
 
        0
 };
 
@@ -55,13 +55,8 @@ register struct value *a;
                return;
        if ((++a)->v_type != V_ERR) {
                for (pp = argv; a->v_type != V_ERR &&
                return;
        if ((++a)->v_type != V_ERR) {
                for (pp = argv; a->v_type != V_ERR &&
-                    pp < &argv[sizeof argv/sizeof *argv-1]; pp++, a++) {
-                       if (a->v_type == V_NUM && p_convstr(a->v_num) < 0) {
-                               p_memerror();
-                               return;
-                       }
+                    pp < &argv[sizeof argv/sizeof *argv-1]; pp++, a++)
                        *pp = a->v_str;
                        *pp = a->v_str;
-               }
                *pp = 0;
                shf = *(sh = argv);
                if (*sh = rindex(shf, '/'))
                *pp = 0;
                shf = *(sh = argv);
                if (*sh = rindex(shf, '/'))
@@ -355,27 +350,3 @@ char def, err;
        }
        /*NOTREACHED*/
 }
        }
        /*NOTREACHED*/
 }
-
-mkargv(p, argv, n)
-register char *p;
-register char **argv;
-register n;
-{
-       while (--n > 0) {
-               for (; *p && (*p == ' ' || *p == '\t'); p++)
-                       ;
-               if (!*p)
-                       break;
-               *argv++ = p;
-               for (; *p && *p != ' ' && *p != '\t'; p++)
-                       ;
-               if (*p)
-                       *p++ = 0;
-       }
-       if (n == 0) {
-               error("Too many shell arguments.");
-               return -1;
-       }
-       *argv = 0;
-       return 0;
-}
index 8815b5d..707c699 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)main.c     3.26 %G%";
+static char sccsid[] = "@(#)main.c     3.27 %G%";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -86,7 +86,7 @@ char **argv;
                wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc;
        }
        if (debug || xflag)
                wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc;
        }
        if (debug || xflag)
-               (void) wwsettty(0, &wwnewtty);
+               (void) wwsettty(0, &wwnewtty, &wwoldtty);
 
        if ((cmdwin = wwopen(WWO_REVERSE, 1, wwncol, 0, 0, 0)) == 0) {
                (void) wwflush();
 
        if ((cmdwin = wwopen(WWO_REVERSE, 1, wwncol, 0, 0, 0)) == 0) {
                (void) wwflush();
index 1e2886e..b466b1f 100644 (file)
@@ -1,11 +1,12 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mloop.c    3.5 %G%";
+static char sccsid[] = "@(#)mloop.c    3.6 %G%";
 #endif
 
 #include "defs.h"
 
 mloop()
 {
 #endif
 
 #include "defs.h"
 
 mloop()
 {
+       wwrint();               /* catch typeahead before we set ASYNC */
        while (!quit) {
                if (incmd) {
                        docmd();
        while (!quit) {
                if (incmd) {
                        docmd();
index 4534aec..5b75128 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwend.c    3.5 %G%";
+static char sccsid[] = "@(#)wwend.c    3.6 %G%";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -10,5 +10,5 @@ wwend()
        (*tt.tt_move)(tt.tt_nrow - 1, 0);
        (*tt.tt_end)();
        ttflush();
        (*tt.tt_move)(tt.tt_nrow - 1, 0);
        (*tt.tt_end)();
        ttflush();
-       (void) wwsettty(0, &wwoldtty);
+       (void) wwsettty(0, &wwoldtty, &wwnewtty);
 }
 }
index 87edae1..454e863 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwinit.c   3.21 %G%";
+static char sccsid[] = "@(#)wwinit.c   3.22 %G%";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -49,8 +49,7 @@ wwinit()
        wwnewtty.ww_lmode = wwoldtty.ww_lmode | LLITOUT;
        wwnewtty.ww_ldisc = wwoldtty.ww_ldisc;
        wwnewtty.ww_fflags = wwoldtty.ww_fflags | FASYNC;
        wwnewtty.ww_lmode = wwoldtty.ww_lmode | LLITOUT;
        wwnewtty.ww_ldisc = wwoldtty.ww_ldisc;
        wwnewtty.ww_fflags = wwoldtty.ww_fflags | FASYNC;
-
-       if (wwsettty(0, &wwnewtty) < 0)
+       if (wwsettty(0, &wwnewtty, &wwoldtty) < 0)
                goto bad;
 
        if ((wwterm = getenv("TERM")) == 0) {
                goto bad;
 
        if ((wwterm = getenv("TERM")) == 0) {
@@ -158,7 +157,7 @@ bad:
         * Don't bother to free storage.  We're supposed
         * to exit when wwinit fails anyway.
         */
         * Don't bother to free storage.  We're supposed
         * to exit when wwinit fails anyway.
         */
-       (void) wwsettty(0, &wwoldtty);
+       (void) wwsettty(0, &wwoldtty, &wwnewtty);
        (void) signal(SIGIO, SIG_DFL);
        (void) sigsetmask(s);
        return -1;
        (void) signal(SIGIO, SIG_DFL);
        (void) sigsetmask(s);
        return -1;
index c97caaa..6b6ac1a 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwopen.c   3.17 %G%";
+static char sccsid[] = "@(#)wwopen.c   3.18 %G%";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -60,7 +60,7 @@ wwopen(flags, nrow, ncol, row, col, nline)
        if (flags & WWO_PTY) {
                if (wwgetpty(w) < 0)
                        goto bad;
        if (flags & WWO_PTY) {
                if (wwgetpty(w) < 0)
                        goto bad;
-               if (wwsettty(w->ww_pty, &wwwintty) < 0)
+               if (wwsettty(w->ww_pty, &wwwintty, (struct ww_tty *)0) < 0)
                        goto bad;
                w->ww_ispty = 1;
        } else if (flags & WWO_SOCKET) {
                        goto bad;
                w->ww_ispty = 1;
        } else if (flags & WWO_SOCKET) {
index 4c7d2b3..20da838 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwsuspend.c        3.5 %G%";
+static char sccsid[] = "@(#)wwsuspend.c        3.6 %G%";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -15,7 +15,7 @@ wwsuspend()
        (void) signal(SIGTSTP, SIG_DFL);
        (void) kill(0, SIGTSTP);
        (void) signal(SIGTSTP, SIG_IGN);
        (void) signal(SIGTSTP, SIG_DFL);
        (void) kill(0, SIGTSTP);
        (void) signal(SIGTSTP, SIG_IGN);
-       (void) wwsettty(0, &wwnewtty);
+       (void) wwsettty(0, &wwnewtty, &wwoldtty);
        (*tt.tt_init)();
        wwredraw();
        (void) signal(SIGTSTP, oldsig);
        (*tt.tt_init)();
        wwredraw();
        (void) signal(SIGTSTP, oldsig);
index dd60361..0887596 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwtty.c    3.7 %G%";
+static char sccsid[] = "@(#)wwtty.c    3.8 %G%";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -26,8 +26,13 @@ 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)
                goto bad;
 {
        if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0)
                goto bad;
@@ -37,7 +42,8 @@ register struct ww_tty *t;
                goto bad;
        if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
                goto bad;
                goto bad;
        if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
                goto bad;
-       if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
+       if ((o == 0 || t->ww_ldisc != o->ww_ldisc) &&
+           ioctl(d, (int)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;