error reporting
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 27 Aug 1983 07:26:36 +0000 (23:26 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 27 Aug 1983 07:26:36 +0000 (23:26 -0800)
SCCS-vsn: usr.bin/window/wwiomux.c 3.2
SCCS-vsn: usr.bin/window/wwspawn.c 3.3
SCCS-vsn: usr.bin/window/wwinit.c 3.9
SCCS-vsn: usr.bin/window/wwopen.c 3.8
SCCS-vsn: usr.bin/window/ww.h 3.11
SCCS-vsn: usr.bin/window/cmd.c 3.8
SCCS-vsn: usr.bin/window/cmd1.c 3.9
SCCS-vsn: usr.bin/window/wwtty.c 3.4
SCCS-vsn: usr.bin/window/wwwrite.c 3.9
SCCS-vsn: usr.bin/window/cmd2.c 3.10
SCCS-vsn: usr.bin/window/wwlabel.c 3.6
SCCS-vsn: usr.bin/window/startup.c 3.5
SCCS-vsn: usr.bin/window/ttinit.c 3.6
SCCS-vsn: usr.bin/window/lcmd1.c 3.6
SCCS-vsn: usr.bin/window/wwalloc.c 3.4
SCCS-vsn: usr.bin/window/wwpty.c 3.3

16 files changed:
usr/src/usr.bin/window/cmd.c
usr/src/usr.bin/window/cmd1.c
usr/src/usr.bin/window/cmd2.c
usr/src/usr.bin/window/lcmd1.c
usr/src/usr.bin/window/startup.c
usr/src/usr.bin/window/ttinit.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwalloc.c
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwiomux.c
usr/src/usr.bin/window/wwlabel.c
usr/src/usr.bin/window/wwopen.c
usr/src/usr.bin/window/wwpty.c
usr/src/usr.bin/window/wwspawn.c
usr/src/usr.bin/window/wwtty.c
usr/src/usr.bin/window/wwwrite.c

index 833c8e2..d57fe46 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd.c       3.7 83/08/26";
+static char *sccsid = "@(#)cmd.c       3.8 83/08/26";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -260,7 +260,7 @@ register struct ww *w;
 
                buf[0] = w->ww_id + '1';
                buf[1] = 0;
 
                buf[0] = w->ww_id + '1';
                buf[1] = 0;
-               (void) wwlabel(w, framewin, 1, buf, mode);
+               wwlabel(w, framewin, 1, buf, mode);
        }
        if (w->ww_label) {
                int col;
        }
        if (w->ww_label) {
                int col;
@@ -270,6 +270,6 @@ register struct ww *w;
                        col = MAX(3, col);
                } else
                        col = 3;
                        col = MAX(3, col);
                } else
                        col = 3;
-               (void) wwlabel(w, framewin, col, w->ww_label, mode);
+               wwlabel(w, framewin, col, w->ww_label, mode);
        }
 }
        }
 }
index b39c3cc..84d8595 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd1.c      3.8 83/08/26";
+static char *sccsid = "@(#)cmd1.c      3.9 83/08/26";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -9,10 +9,8 @@ c_window()
        int col, row, xcol, xrow;
        int id;
 
        int col, row, xcol, xrow;
        int id;
 
-       if ((id = findid()) < 0) {
-               error("Too many windows.");
+       if ((id = findid()) < 0)
                return;
                return;
-       }
        if (!terse)
                (void) wwputs("Upper left corner: ", cmdwin);
        col = 0;
        if (!terse)
                (void) wwputs("Upper left corner: ", cmdwin);
        col = 0;
@@ -69,8 +67,7 @@ c_window()
        if (!terse)
                (void) wwputs("\r\n", cmdwin);
        wwcurtowin(cmdwin);
        if (!terse)
                (void) wwputs("\r\n", cmdwin);
        wwcurtowin(cmdwin);
-       if (openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline) == 0)
-               error("Can't open window.");
+       (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline);
 }
 
 findid()
 }
 
 findid()
@@ -79,7 +76,11 @@ findid()
 
        for (i = 0; i < NWINDOW && window[i] != 0; i++)
                ;
 
        for (i = 0; i < NWINDOW && window[i] != 0; i++)
                ;
-       return i < NWINDOW ? i : -1;
+       if (i >= NWINDOW) {
+               error("Too many windows.");
+               return -1;
+       }
+       return i;
 }
 
 getpos(row, col, minrow, mincol)
 }
 
 getpos(row, col, minrow, mincol)
@@ -146,12 +147,16 @@ int id, nrow, ncol, row, col;
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
-       if (row <= 0)
-               return 0;
        if (id < 0 && (id = findid()) < 0)
                return 0;
        if (id < 0 && (id = findid()) < 0)
                return 0;
-       if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, nline)) == 0)
+       if (row <= 0) {
+               error("Bad row number.");
+               return 0;
+       }
+       if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, nline)) == 0) {
+               error("%s.", wwerror());
                return 0;
                return 0;
+       }
        w->ww_id = id;
        window[id] = w;
        w->ww_hasframe = 1;
        w->ww_id = id;
        window[id] = w;
        w->ww_hasframe = 1;
@@ -164,6 +169,7 @@ int id, nrow, ncol, row, col;
        switch (wwfork(w)) {
        case -1:
                c_close(w);
        switch (wwfork(w)) {
        case -1:
                c_close(w);
+               error("%s.", wwerror());
                return 0;
        case 0:
                execl(shell, shellname, 0);
                return 0;
        case 0:
                execl(shell, shellname, 0);
index ab9fbcd..d0b462d 100644 (file)
@@ -1,17 +1,15 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd2.c      3.9 83/08/26";
+static char *sccsid = "@(#)cmd2.c      3.10 83/08/26";
 #endif
 
 #include "defs.h"
 
 #endif
 
 #include "defs.h"
 
-struct ww *openiwin();
-
 c_help()
 {
        register struct ww *w;
 
        if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
 c_help()
 {
        register struct ww *w;
 
        if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
-               error("Can't open help window.");
+               error("Can't open help window: %s.", wwerror());
                return;
        }
        (void) wwprintf(w, "The escape character is %s, which gets you into command mode.\n\n",
                return;
        }
        (void) wwprintf(w, "The escape character is %s, which gets you into command mode.\n\n",
@@ -59,7 +57,7 @@ c_time(flag)
        struct timezone timezone;
 
        if ((w = openiwin(6, "Timing and Resource Usage")) == 0) {
        struct timezone timezone;
 
        if ((w = openiwin(6, "Timing and Resource Usage")) == 0) {
-               error("Can't open time window.");
+               error("Can't open time window: %s.", wwerror());
                return;
        }
 
                return;
        }
 
@@ -123,7 +121,7 @@ c_stat()
        register struct ww *w;
 
        if ((w = openiwin(4, "IO Statics")) == 0) {
        register struct ww *w;
 
        if ((w = openiwin(4, "IO Statics")) == 0) {
-               error("Can't open statistics window.");
+               error("Can't open statistics window: %s.", wwerror());
                return;
        }
        (void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\tnupdate\tntouchd\tnmiss\n");
                return;
        }
        (void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\tnupdate\tntouchd\tnmiss\n");
@@ -144,7 +142,7 @@ c_list()
                if (window[i] != 0)
                        n++;
        if ((w = openiwin(MAX(n, 1) + 2, "Active Windows")) == 0) {
                if (window[i] != 0)
                        n++;
        if ((w = openiwin(MAX(n, 1) + 2, "Active Windows")) == 0) {
-               error("Can't open listing window.");
+               error("Can't open listing window: %s.", wwerror());
                return;
        }
        if (n == 0) {
                return;
        }
        if (n == 0) {
index b710af5..c1e052f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)lcmd1.c     3.5 83/08/25";
+static char *sccsid = "@(#)lcmd1.c     3.6 83/08/26";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -7,22 +7,16 @@ static        char *sccsid = "@(#)lcmd1.c     3.5 83/08/25";
 l_window()
 {
        register char **pp = argv;
 l_window()
 {
        register char **pp = argv;
-       register struct ww *w;
        int col, row, ncol, nrow, id, nline;
 
        int col, row, ncol, nrow, id, nline;
 
-       if ((id = findid()) < 0) {
-               error("Too many windows.");
+       if ((id = findid()) < 0)
                return;
                return;
-       }
        row = **++pp == '*' ? 1 : atoi(*pp);
        col = **++pp == '*' ? 0 : atoi(*pp);
        nrow = **++pp == '*' ? wwnrow - row : atoi(*pp);
        ncol = **++pp == '*' ? wwncol - col : atoi(*pp);
        nline = *++pp == 0 ? nbufline : atoi(*pp);
        row = **++pp == '*' ? 1 : atoi(*pp);
        col = **++pp == '*' ? 0 : atoi(*pp);
        nrow = **++pp == '*' ? wwnrow - row : atoi(*pp);
        ncol = **++pp == '*' ? wwncol - col : atoi(*pp);
        nline = *++pp == 0 ? nbufline : atoi(*pp);
-       w = openwin(id, row, col, nrow, ncol, nline);
-       if (w == 0)
-               error("Can't open window: row %d col %d, %d rows %d cols %d lines.",
-                       row, col, nrow, ncol, nline);
+       (void) openwin(id, row, col, nrow, ncol, nline);
 }
 
 l_buffer()
 }
 
 l_buffer()
index f42fbcd..ef08a4f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)startup.c   3.4 83/08/25";
+static char *sccsid = "@(#)startup.c   3.5 83/08/26";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -31,5 +31,5 @@ dodefault()
        setselwin(w);
        return;
 bad:
        setselwin(w);
        return;
 bad:
-       (void) wwputs("Can't open default windows.  ", cmdwin);
+       (void) wwputs("\nCan't open default windows.  ", cmdwin);
 }
 }
index d492450..04fd663 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttinit.c    3.5 83/08/15";
+static char *sccsid = "@(#)ttinit.c    3.6 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -30,7 +30,13 @@ ttinit()
        for (tp = tt_tab; tp->tt_name != 0; tp++)
                if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
                        break;
        for (tp = tt_tab; tp->tt_name != 0; tp++)
                if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
                        break;
-       if (tp->tt_name == 0)
+       if (tp->tt_name == 0) {
+               wwerrno = WWE_BADTERM;
                return -1;
                return -1;
-       return (*tp->tt_func)();
+       }
+       if ((*tp->tt_func)() < 0) {
+               wwerrno = WWE_CANTDO;
+               return -1;
+       }
+       return 0;
 }
 }
index 3338205..e90e8ae 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)ww.h        3.10 83/08/19   
+ *     @(#)ww.h        3.11 83/08/26   
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -106,6 +106,15 @@ union ww_char {
        /* special ww_index value */
 #define WWX_NOBODY     NWW
 
        /* special ww_index value */
 #define WWX_NOBODY     NWW
 
+#define WWE_NOERR      0
+#define WWE_SYS                1               /* system error */
+#define WWE_NOMEM      2               /* out of memory */
+#define WWE_TOOMANY    3               /* too many windows */
+#define WWE_NOPTY      4               /* no more ptys */
+#define WWE_SIZE       5               /* bad window size */
+#define WWE_BADTERM    6               /* bad terminal type */
+#define WWE_CANTDO     7               /* dumb terminal */
+
 struct ww wwhead;
 struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
 struct ww wwnobody;
 struct ww wwhead;
 struct ww *wwindex[NWW + 1];           /* last location is for wwnobody */
 struct ww wwnobody;
@@ -129,6 +138,7 @@ char *wwtouched;            /* wwns changed flags */
 int wwbaudmap[];               /* maps stty() baud rate code into number */
 int wwbaud;                    /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
 int wwcursorrow, wwcursorcol;  /* where we want the cursor to be */
 int wwbaudmap[];               /* maps stty() baud rate code into number */
 int wwbaud;                    /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
 int wwcursorrow, wwcursorcol;  /* where we want the cursor to be */
+int wwerrno;                   /* error number */
 
        /* statistics */
 int wwnwrite, wwnwritec;
 
        /* statistics */
 int wwnwrite, wwnwritec;
@@ -159,6 +169,7 @@ int wwchild();
 int wwsuspend();
 char *unctrl();
 char **wwalloc();
 int wwsuspend();
 char *unctrl();
 char **wwalloc();
+char *wwerror();
 
        /* c library functions */
 char *malloc();
 
        /* c library functions */
 char *malloc();
index 98a9fba..f51ffc7 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwalloc.c   3.3 83/08/19";
+static char *sccsid = "@(#)wwalloc.c   3.4 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -14,8 +14,10 @@ int nrow, ncol, size;
        /* fast, call malloc only once */
        pp = (char **)
                malloc((unsigned) sizeof (char **) * nrow + size * nrow * ncol);
        /* fast, call malloc only once */
        pp = (char **)
                malloc((unsigned) sizeof (char **) * nrow + size * nrow * ncol);
-       if (pp == 0)
+       if (pp == 0) {
+               wwerrno = WWE_NOMEM;
                return 0;
                return 0;
+       }
        p = (char *)&pp[nrow];
        size /= sizeof (char);          /* paranoid */
        size *= ncol;
        p = (char *)&pp[nrow];
        size /= sizeof (char);          /* paranoid */
        size *= ncol;
index 45137f3..410bbe9 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinit.c    3.8 83/08/19";
+static char *sccsid = "@(#)wwinit.c    3.9 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -31,10 +31,14 @@ wwinit()
        if (wwsettty(0, &wwnewtty) < 0)
                goto bad;
 
        if (wwsettty(0, &wwnewtty) < 0)
                goto bad;
 
-       if ((wwterm = getenv("TERM")) == 0)
+       if ((wwterm = getenv("TERM")) == 0) {
+               wwerrno = WWE_BADTERM;
                goto bad;
                goto bad;
-       if (tgetent(wwtermcap, wwterm) != 1)
+       }
+       if (tgetent(wwtermcap, wwterm) != 1) {
+               wwerrno = WWE_BADTERM;
                goto bad;
                goto bad;
+       }
        wwbaud = wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed];
 
        if (ttinit() < 0)
        wwbaud = wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed];
 
        if (ttinit() < 0)
@@ -72,8 +76,10 @@ wwinit()
                        wwns[i][j].c_w = ' ';
 
        wwtouched = malloc((unsigned) wwnrow);
                        wwns[i][j].c_w = ' ';
 
        wwtouched = malloc((unsigned) wwnrow);
-       if (wwtouched == 0)
+       if (wwtouched == 0) {
+               wwerrno = WWE_NOMEM;
                goto bad;
                goto bad;
+       }
        for (i = 0; i < wwnrow; i++)
                wwtouched[i] = 0;
 
        for (i = 0; i < wwnrow; i++)
                wwtouched[i] = 0;
 
index dd2517c..258333e 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwiomux.c   3.1 83/08/11";
+static char *sccsid = "@(#)wwiomux.c   3.2 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -16,8 +16,10 @@ register int *imask;
                        *imask |= 1 << (*w)->ww_pty;
        n = select(wwdtablesize, imask, (int *)0, (int *)0,
                (struct timeval *)0);
                        *imask |= 1 << (*w)->ww_pty;
        n = select(wwdtablesize, imask, (int *)0, (int *)0,
                (struct timeval *)0);
-       if (n <= 0)
+       if (n <= 0) {
+               wwerrno = WWE_SYS;
                return -1;
                return -1;
+       }
        for (w = wwindex; w < &wwindex[NWW]; w++)
                if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
                    && *imask & 1 << (*w)->ww_pty) {
        for (w = wwindex; w < &wwindex[NWW]; w++)
                if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
                    && *imask & 1 << (*w)->ww_pty) {
index 4c51cbc..edbf234 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwlabel.c   3.5 83/08/19";
+static char *sccsid = "@(#)wwlabel.c   3.6 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -24,11 +24,11 @@ char *l;
        char *touched;
 
        if (f->ww_fmap == 0)
        char *touched;
 
        if (f->ww_fmap == 0)
-               return -1;
+               return;
 
        i = w->ww_w.t - 1 - f->ww_w.t;
        if (i < 0)
 
        i = w->ww_w.t - 1 - f->ww_w.t;
        if (i < 0)
-               return -1;
+               return;
        j = w->ww_w.l + where - f->ww_w.l;
        if (j < 0)
                j = 0;
        j = w->ww_w.l + where - f->ww_w.l;
        if (j < 0)
                j = 0;
@@ -64,6 +64,4 @@ char *l;
                                *fmap++ |= WWF_LABEL;
                        }
                }
                                *fmap++ |= WWF_LABEL;
                        }
                }
-
-       return 0;
 }
 }
index 0f87391..9115a17 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwopen.c    3.7 83/08/23";
+static char *sccsid = "@(#)wwopen.c    3.8 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -13,27 +13,28 @@ wwopen(flags, nrow, ncol, row, col, nline)
        short nvis;
 
        w = (struct ww *)calloc(sizeof (struct ww), 1);
        short nvis;
 
        w = (struct ww *)calloc(sizeof (struct ww), 1);
-       if (w == 0)
+       if (w == 0) {
+               wwerrno = WWE_NOMEM;
                goto bad;
                goto bad;
+       }
 
        for (i = 0; i < NWW && wwindex[i] != 0; i++)
                ;
 
        for (i = 0; i < NWW && wwindex[i] != 0; i++)
                ;
-       if (i >= NWW)
+       if (i >= NWW) {
+               wwerrno = WWE_TOOMANY;
                goto bad;
                goto bad;
+       }
        w->ww_index = i;
 
        w->ww_index = i;
 
-       if (nrow <= 0 || ncol <= 0)
-               goto bad;
-       if ((w->ww_w.l = col) < 0)
-               goto bad;
-       if ((w->ww_w.r = col + ncol) > wwncol)
-               goto bad;
-       if ((w->ww_w.t = row) < 0)
+       if ((w->ww_w.nr = nrow) <= 0
+           || (w->ww_w.nc = ncol) <= 0
+           || (w->ww_w.l = col) < 0
+           || (w->ww_w.r = col + ncol) > wwncol
+           || (w->ww_w.t = row) < 0
+           || (w->ww_w.b = row + nrow) > wwnrow) {
+               wwerrno = WWE_SIZE;
                goto bad;
                goto bad;
-       if ((w->ww_w.b = row + nrow) > wwnrow)
-               goto bad;
-       w->ww_w.nc = ncol;
-       w->ww_w.nr = nrow;
+       }
        w->ww_nline = MAX(nline, w->ww_w.nr);
 
        w->ww_pty = w->ww_tty = -1;     /* closing by mistake is still safe */
        w->ww_nline = MAX(nline, w->ww_w.nr);
 
        w->ww_pty = w->ww_tty = -1;     /* closing by mistake is still safe */
@@ -67,7 +68,7 @@ wwopen(flags, nrow, ncol, row, col, nline)
        if (flags & WWO_FRAME) {
                w->ww_fmap = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char));
                if (w->ww_fmap == 0)
        if (flags & WWO_FRAME) {
                w->ww_fmap = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char));
                if (w->ww_fmap == 0)
-                       goto bad;
+                       wwerrno = WWE_NOMEM;
                for (i = 0; i < wwnrow; i++)
                        for (j = 0; j < wwncol; j++)
                                w->ww_fmap[i][j] = 0;
                for (i = 0; i < wwnrow; i++)
                        for (j = 0; j < wwncol; j++)
                                w->ww_fmap[i][j] = 0;
@@ -82,8 +83,10 @@ wwopen(flags, nrow, ncol, row, col, nline)
                        w->ww_buf[i][j].c_w = ' ';
 
        w->ww_nvis = (short *)malloc((unsigned) w->ww_w.nr * sizeof (short));
                        w->ww_buf[i][j].c_w = ' ';
 
        w->ww_nvis = (short *)malloc((unsigned) w->ww_w.nr * sizeof (short));
-       if (w->ww_nvis == 0)
+       if (w->ww_nvis == 0) {
+               wwerrno = WWE_NOMEM;
                goto bad;
                goto bad;
+       }
        nvis = m ? 0 : w->ww_w.nc;
        for (i = 0; i < w->ww_w.nr; i++)
                w->ww_nvis[i] = nvis;
        nvis = m ? 0 : w->ww_w.nc;
        for (i = 0; i < w->ww_w.nr; i++)
                w->ww_nvis[i] = nvis;
index bc71ce0..c40d584 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwpty.c     3.2 83/08/11";
+static char *sccsid = "@(#)wwpty.c     3.3 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -32,6 +32,7 @@ wwgetpty(w)
                        }
                }
        }
                        }
                }
        }
+       wwerrno = WWE_NOPTY;
        return -1;
 good:
        (void) strcpy(w->ww_ttyname, line);
        return -1;
 good:
        (void) strcpy(w->ww_ttyname, line);
index 3a87bc1..914c1b1 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwspawn.c   3.2 83/08/17";
+static char *sccsid = "@(#)wwspawn.c   3.3 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -9,6 +9,7 @@ register struct ww *wp;
 {
        switch (wp->ww_pid = fork()) {
        case -1:
 {
        switch (wp->ww_pid = fork()) {
        case -1:
+               wwerrno = WWE_SYS;
                return -1;
        case 0:
                moncontrol(0);
                return -1;
        case 0:
                moncontrol(0);
index dc71230..31134ec 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwtty.c     3.3 83/08/23";
+static char *sccsid = "@(#)wwtty.c     3.4 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -8,34 +8,40 @@ wwgettty(d, t)
 register struct ww_tty *t;
 {
        if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0)
 register struct ww_tty *t;
 {
        if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0)
        if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0)
        if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0)
        if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
        if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCGPGRP, (char *)&t->ww_pgrp) < 0)
        if (ioctl(d, (int)TIOCGPGRP, (char *)&t->ww_pgrp) < 0)
-               return -1;
+               goto bad;
        return 0;
        return 0;
+bad:
+       wwerrno = WWE_SYS;
+       return -1;
 }
 
 wwsettty(d, t)
 register struct ww_tty *t;
 {
        if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0)
 }
 
 wwsettty(d, t)
 register struct ww_tty *t;
 {
        if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0)
        if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0)
        if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
        if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
        if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
-               return -1;
+               goto bad;
        if (ioctl(d, (int)TIOCSPGRP, (char *)&t->ww_pgrp) < 0)
        if (ioctl(d, (int)TIOCSPGRP, (char *)&t->ww_pgrp) < 0)
-               return -1;
+               goto bad;
        return 0;
        return 0;
+bad:
+       wwerrno = WWE_SYS;
+       return -1;
 }
 }
index 93cc629..1e44f48 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwwrite.c   3.8 83/08/23";
+static char *sccsid = "@(#)wwwrite.c   3.9 83/08/26";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -10,11 +10,8 @@ register char *p;
 int n;
 {
        char c;
 int n;
 {
        char c;
-       int oldn = n;
        char hascursor = 0;
 
        char hascursor = 0;
 
-       if (w == 0)
-               return -1;
        wwnwrite++;
        wwnwritec += n;
        if (hascursor = w->ww_hascursor)
        wwnwrite++;
        wwnwritec += n;
        if (hascursor = w->ww_hascursor)
@@ -189,5 +186,5 @@ int n;
        }
        if (hascursor)
                wwcursor(w, 1);
        }
        if (hascursor)
                wwcursor(w, 1);
-       return oldn - n;
+       return 0;
 }
 }