compile with -R
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 24 Mar 1984 10:17:33 +0000 (02:17 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 24 Mar 1984 10:17:33 +0000 (02:17 -0800)
SCCS-vsn: usr.bin/window/main.c 3.16
SCCS-vsn: usr.bin/window/wwinit.c 3.16
SCCS-vsn: usr.bin/window/ww.h 3.27
SCCS-vsn: usr.bin/window/wwprintf.c 3.3
SCCS-vsn: usr.bin/window/ttinit.c 3.9
SCCS-vsn: usr.bin/window/lcmd.c 3.12
SCCS-vsn: usr.bin/window/lcmd1.c 3.15
SCCS-vsn: usr.bin/window/wwdata.c 3.10
SCCS-vsn: usr.bin/window/wwenviron.c 3.9
SCCS-vsn: usr.bin/window/string.c 3.5
SCCS-vsn: usr.bin/window/parser2.c 3.3
SCCS-vsn: usr.bin/window/lcmd.h 3.2

12 files changed:
usr/src/usr.bin/window/lcmd.c
usr/src/usr.bin/window/lcmd.h
usr/src/usr.bin/window/lcmd1.c
usr/src/usr.bin/window/main.c
usr/src/usr.bin/window/parser2.c
usr/src/usr.bin/window/string.c
usr/src/usr.bin/window/ttinit.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwdata.c
usr/src/usr.bin/window/wwenviron.c
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwprintf.c

index e50406e..d87354f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)lcmd.c      3.11 84/01/13";
+static char *sccsid = "@(#)lcmd.c      3.12 84/03/23";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
index 5def279..e28adc5 100644 (file)
@@ -1,7 +1,9 @@
 /*
 /*
- *     @(#)lcmd.h      3.1 83/11/22
+ *     @(#)lcmd.h      3.2 84/03/23
  */
 
  */
 
+#define LCMD_NARG 20                   /* maximum number of arguments */
+
 struct lcmd_tab {
        char *lc_name;
        int lc_minlen;
 struct lcmd_tab {
        char *lc_name;
        int lc_minlen;
@@ -13,11 +15,7 @@ struct lcmd_arg {
        char *arg_name;
        int arg_minlen;
        char arg_type;
        char *arg_name;
        int arg_minlen;
        char arg_type;
-       struct value arg_val;
 };
 };
-#define arg_num arg_val.v_num
-#define arg_str arg_val.v_str
-#define arg_vtype arg_val.v_type
 
 #define ARG_ANY 0
 #define ARG_NUM 1
 
 #define ARG_ANY 0
 #define ARG_NUM 1
index 0029338..864d380 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)lcmd1.c     3.14 84/01/13";
+static char *sccsid = "@(#)lcmd1.c     3.15 84/03/23";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -14,24 +14,23 @@ struct lcmd_arg arg_window[] = {
        { "ncols",      2,      ARG_ANY },
        { "nlines",     2,      ARG_NUM },
        { "label",      1,      ARG_STR },
        { "ncols",      2,      ARG_ANY },
        { "nlines",     2,      ARG_NUM },
        { "label",      1,      ARG_STR },
-       { 0,            0,      0 }
+       0
 };
 
 };
 
-l_window(v)
-register struct value *v;
+l_window(v, a)
+register struct value *v, *a;
 {
 {
-       register struct lcmd_arg *a = arg_window;
        int col, row, ncol, nrow, id, nline;
        char *label;
 
        if ((id = findid()) < 0)
                return;
        int col, row, ncol, nrow, id, nline;
        char *label;
 
        if ((id = findid()) < 0)
                return;
-       row = a->arg_vtype != V_NUM ? 1 : a->arg_num;
-       col = (++a)->arg_vtype != V_NUM ? 0 : a->arg_num;
-       nrow = (++a)->arg_vtype != V_NUM ? wwnrow - row : a->arg_num;
-       ncol = (++a)->arg_vtype != V_NUM ? wwncol - col : a->arg_num;
-       nline = (++a)->arg_vtype == V_ERR ? nbufline : a->arg_num;
-       label =  (++a)->arg_vtype == V_ERR ? 0 : a->arg_str;
+       row = a->v_type != V_NUM ? 1 : a->v_num;
+       col = (++a)->v_type != V_NUM ? 0 : a->v_num;
+       nrow = (++a)->v_type != V_NUM ? wwnrow - row : a->v_num;
+       ncol = (++a)->v_type != V_NUM ? wwncol - col : a->v_num;
+       nline = (++a)->v_type == V_ERR ? nbufline : a->v_num;
+       label =  (++a)->v_type == V_ERR ? 0 : a->v_str;
        if (openwin(id, row, col, nrow, ncol, nline, label) == 0)
                return;
        v->v_type = V_NUM;
        if (openwin(id, row, col, nrow, ncol, nline, label) == 0)
                return;
        v->v_type = V_NUM;
@@ -40,33 +39,33 @@ register struct value *v;
 
 struct lcmd_arg arg_buffer[] = {
        { "nlines",     1,      ARG_NUM },
 
 struct lcmd_arg arg_buffer[] = {
        { "nlines",     1,      ARG_NUM },
-       { 0,            0,      0 }
+       0
 };
 
 };
 
-l_buffer(v)
-struct value *v;
+l_buffer(v, a)
+register struct value *v, *a;
 {
        v->v_num = nbufline;
        v->v_type = V_NUM;
 {
        v->v_num = nbufline;
        v->v_type = V_NUM;
-       if (arg_buffer[0].arg_vtype != V_ERR)
-               nbufline = arg_buffer[0].arg_num;
+       if (a->v_type != V_ERR)
+               nbufline = a->v_num;
 }
 
 struct lcmd_arg arg_select[] = {
        { "window",     1,      ARG_NUM },
 }
 
 struct lcmd_arg arg_select[] = {
        { "window",     1,      ARG_NUM },
-       { 0,            0,      0 }
+       0
 };
 
 };
 
-l_select(v)
-struct value *v;
+l_select(v, a)
+register struct value *v, *a;
 {
        struct ww *w;
 
        v->v_type = V_NUM;
        v->v_num = selwin ? selwin->ww_id + 1 : -1;
 {
        struct ww *w;
 
        v->v_type = V_NUM;
        v->v_num = selwin ? selwin->ww_id + 1 : -1;
-       if (arg_select[0].arg_vtype == V_ERR)
+       if (a->v_type == V_ERR)
                return;
                return;
-       if ((w = vtowin(&arg_select[0].arg_val)) == 0)
+       if ((w = vtowin(a)) == 0)
                return;
        setselwin(w);
 }
                return;
        setselwin(w);
 }
@@ -76,62 +75,61 @@ struct lcmd_arg arg_debug[] = {
        { 0,            0,      0 }
 };
 
        { 0,            0,      0 }
 };
 
-l_debug(v)
-struct value *v;
+l_debug(v, a)
+register struct value *v, *a;
 {
        v->v_type = V_NUM;
        v->v_num = debug;
 {
        v->v_type = V_NUM;
        v->v_num = debug;
-       debug = vtobool(&arg_debug[0].arg_val, 1, debug);
+       debug = vtobool(a, 1, debug);
 }
 
 struct lcmd_arg arg_escape[] = {
 }
 
 struct lcmd_arg arg_escape[] = {
-       { "escapec",    1,      ARG_NUM },
-       { 0,            0,      0 }
+       { "escapec",    1,      ARG_STR },
+       0
 };
 
 };
 
-l_escape(v)
-struct value *v;
+l_escape(v, a)
+register struct value *v, *a;
 {
        if ((v->v_str = str_cpy(unctrl(escapec))) == 0) {
                error("Out of memory.");
                return;
        }
        v->v_type = V_STR;
 {
        if ((v->v_str = str_cpy(unctrl(escapec))) == 0) {
                error("Out of memory.");
                return;
        }
        v->v_type = V_STR;
-       if (arg_escape[0].arg_type != V_ERR)
-               setescape(arg_escape[0].arg_str);
+       if (a->v_type != V_ERR)
+               setescape(a->v_str);
 }
 
 struct lcmd_arg arg_label[] = {
        { "window",     1,      ARG_NUM },
        { "label",      1,      ARG_STR },
 }
 
 struct lcmd_arg arg_label[] = {
        { "window",     1,      ARG_NUM },
        { "label",      1,      ARG_STR },
-       { 0,            0,      0 }
+       0
 };
 
 /*ARGSUSED*/
 };
 
 /*ARGSUSED*/
-l_label(v)
-struct value *v;
+l_label(v, a)
+register struct value *v, *a;
 {
        struct ww *w;
 {
        struct ww *w;
-       register struct lcmd_arg *a = arg_label;
 
 
-       if ((w = vtowin(&a->arg_val)) == 0)
+       if ((w = vtowin(a)) == 0)
                return;
                return;
-       if ((++a)->arg_vtype != V_ERR && setlabel(w, a->arg_str) < 0)
+       if ((++a)->v_type != V_ERR && setlabel(w, a->v_str) < 0)
                error("Out of memory.");
        reframe();
 }
 
 struct lcmd_arg arg_terse[] = {
        { "flag",       1,      ARG_ANY },
                error("Out of memory.");
        reframe();
 }
 
 struct lcmd_arg arg_terse[] = {
        { "flag",       1,      ARG_ANY },
-       { 0,            0,      0 }
+       0
 };
 
 };
 
-l_terse(v)
-struct value *v;
+l_terse(v, a)
+register struct value *v, *a;
 {
        v->v_type = V_NUM;
        v->v_num = terse;
 {
        v->v_type = V_NUM;
        v->v_num = terse;
-       terse = vtobool(&arg_terse[0].arg_val, 1, terse);
+       terse = vtobool(a, 1, terse);
        if (!terse && v->v_num)
                wwadd(cmdwin, &wwhead);
        else if (!v->v_num && terse)
        if (!terse && v->v_num)
                wwadd(cmdwin, &wwhead);
        else if (!v->v_num && terse)
@@ -141,100 +139,94 @@ struct value *v;
 
 struct lcmd_arg arg_source[] = {
        { "filename",   1,      ARG_STR },
 
 struct lcmd_arg arg_source[] = {
        { "filename",   1,      ARG_STR },
-       { 0,            0,      0 }
+       0
 };
 
 /*ARGSUSED*/
 };
 
 /*ARGSUSED*/
-l_source(v)
-struct value *v;
+l_source(v, a)
+register struct value *v, *a;
 {
 {
-       if (arg_source[0].arg_vtype != V_ERR
-           && dosource(arg_source[0].arg_str) < 0) {
-               error("Can't open %s.", arg_source[0].arg_str);
+       v->v_type = V_NUM;
+       if (a->v_type != V_ERR && dosource(a->v_str) < 0) {
+               error("Can't open %s.", a->v_str);
                v->v_num = -1;
        } else
                v->v_num = 0;
                v->v_num = -1;
        } else
                v->v_num = 0;
-       v->v_type = V_NUM;
 }
 
 struct lcmd_arg arg_write[] = {
        { "window",     1,      ARG_NUM },
        { "string",     1,      ARG_STR },
 }
 
 struct lcmd_arg arg_write[] = {
        { "window",     1,      ARG_NUM },
        { "string",     1,      ARG_STR },
-       { 0,            0,      0 }
+       0
 };
 
 /*ARGSUSED*/
 };
 
 /*ARGSUSED*/
-l_write(v)
-struct value *v;
+l_write(v, a)
+register struct value *v, *a;
 {
 {
-       register struct lcmd_arg *a = arg_write;
        struct ww *w;
 
        struct ww *w;
 
-       if ((w = vtowin(&a->arg_val)) == 0)
+       if ((w = vtowin(a)) == 0)
                return;
        a++;
                return;
        a++;
-       (void) write(w->ww_pty, a->arg_str, strlen(a->arg_str));
+       (void) write(w->ww_pty, a->v_str, strlen(a->v_str));
 }
 
 struct lcmd_arg arg_close[] = {
        { "window",     1,      ARG_NUM },
 }
 
 struct lcmd_arg arg_close[] = {
        { "window",     1,      ARG_NUM },
-       { 0,            0,      0 }
+       0
 };
 
 /*ARGSUSED*/
 };
 
 /*ARGSUSED*/
-l_close(v)
-struct value *v;
+l_close(v, a)
+register struct value *v, *a;
 {
 {
-       register struct lcmd_arg *a = arg_close;
        struct ww *w;
 
        struct ww *w;
 
-       if (a->arg_vtype == V_ERR)
+       if (a->v_type == V_ERR)
                c_close((struct ww *)0);
                c_close((struct ww *)0);
-       else if ((w = vtowin(&a->arg_val)) != 0)
+       else if ((w = vtowin(a)) != 0)
                c_close(w);
 }
 
 struct lcmd_arg arg_cursormodes[] = {
        { "modes",      1,      ARG_NUM },
                c_close(w);
 }
 
 struct lcmd_arg arg_cursormodes[] = {
        { "modes",      1,      ARG_NUM },
-       { 0,            0,      0 }
+       0
 };
 
 };
 
-l_cursormodes(v)
-register struct value *v;
+l_cursormodes(v, a)
+register struct value *v, *a;
 {
 {
-       register struct lcmd_arg *a = arg_cursormodes;
 
        v->v_type = V_NUM;
        v->v_num = wwcursormodes;
 
        v->v_type = V_NUM;
        v->v_num = wwcursormodes;
-       if (a->arg_vtype != V_ERR)
-               wwsetcursormodes(a->arg_num);
+       if (a->v_type != V_ERR)
+               wwsetcursormodes(a->v_num);
 }
 
 struct lcmd_arg arg_unset[] = {
        { "variable",   1,      ARG_ANY },
 }
 
 struct lcmd_arg arg_unset[] = {
        { "variable",   1,      ARG_ANY },
-       { 0,            0,      0 }
+       0
 };
 
 };
 
-l_unset(v)
-register struct value *v;
+l_unset(v, a)
+register struct value *v, *a;
 {
 {
-       register struct lcmd_arg *a = arg_unset;
-
        v->v_type = V_NUM;
        v->v_type = V_NUM;
-       switch (a->arg_vtype) {
+       switch (a->v_type) {
        case V_ERR:
                v->v_num = -1;
                return;
        case V_NUM:
        case V_ERR:
                v->v_num = -1;
                return;
        case V_NUM:
-               if ((a->arg_str = str_itoa(a->arg_num)) == 0) {
+               if ((a->v_str = str_itoa(a->v_num)) == 0) {
                        error("Out of memory.");
                        v->v_num = -1;
                        return;
                }
                        error("Out of memory.");
                        v->v_num = -1;
                        return;
                }
-               a->arg_vtype = V_STR;
+               a->v_type = V_STR;
                break;
        }
                break;
        }
-       v->v_num = var_unset(a->arg_str);
+       v->v_num = var_unset(a->v_str);
 }
 
 struct ww *
 }
 
 struct ww *
index 9690ba5..d9cd975 100644 (file)
@@ -1,14 +1,11 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)main.c      3.15 84/03/03";
+static char *sccsid = "@(#)main.c      3.16 84/03/23";
 #endif
 
 #include "defs.h"
 #include <sys/signal.h>
 #include <stdio.h>
 
 #endif
 
 #include "defs.h"
 #include <sys/signal.h>
 #include <stdio.h>
 
-int nbufline = 48;                     /* compatible */
-char escapec = CTRL(p);        
-
 #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
 /*ARGSUSED*/
 #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
 /*ARGSUSED*/
@@ -52,6 +49,8 @@ char **argv;
                } else
                        (void) usage();
        }
                } else
                        (void) usage();
        }
+       nbufline = 48;                          /* compatible */
+       escapec = CTRL(p);      
        if ((shell = getenv("SHELL")) == 0)
                shell = "/bin/csh";
        if (shellname = rindex(shell, '/'))
        if ((shell = getenv("SHELL")) == 0)
                shell = "/bin/csh";
        if (shellname = rindex(shell, '/'))
index 0ce5a35..929b93d 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)parser2.c   3.2 84/01/13";
+static char *sccsid = "@(#)parser2.c   3.3 84/03/23";
 #endif
 
 #include "parser.h"
 #endif
 
 #include "parser.h"
@@ -18,6 +18,8 @@ register struct value *v;
        register struct lcmd_tab *c;
        register struct lcmd_arg *ap;
        register i;
        register struct lcmd_tab *c;
        register struct lcmd_arg *ap;
        register i;
+       struct value av[LCMD_NARG];
+       register struct value *vp;
 
        if (name != 0) {
                if ((c = lcmd_lookup(name)) == 0) {
 
        if (name != 0) {
                if ((c = lcmd_lookup(name)) == 0) {
@@ -28,8 +30,8 @@ register struct value *v;
                c = 0;
 
        if (c != 0)
                c = 0;
 
        if (c != 0)
-               for (ap = c->lc_arg; ap->arg_name != 0; ap++)
-                       ap->arg_val.v_type = V_ERR;
+               for (vp = av; vp < &av[LCMD_NARG]; vp++)
+                       vp->v_type = V_ERR;
 
        for (i = 0;;) {
                ap = 0;
 
        for (i = 0;;) {
                ap = 0;
@@ -49,6 +51,7 @@ register struct value *v;
                if (token != T_ASSIGN) {
                        if (c != 0) {
                                ap = &c->lc_arg[i];
                if (token != T_ASSIGN) {
                        if (c != 0) {
                                ap = &c->lc_arg[i];
+                               vp = &av[i];
                                if (ap->arg_name == 0) {
                                        p_error("%s: Too many arguments.",
                                                c->lc_name);
                                if (ap->arg_name == 0) {
                                        p_error("%s: Too many arguments.",
                                                c->lc_name);
@@ -85,7 +88,8 @@ register struct value *v;
                                flag = 0;
                        if (tmp) {
                                /* we know c != 0 */
                                flag = 0;
                        if (tmp) {
                                /* we know c != 0 */
-                               for (ap = c->lc_arg; ap->arg_name != 0; ap++)
+                               for (ap = c->lc_arg, vp = av;
+                                    ap->arg_name != 0; ap++, vp++)
                                        if (str_match(tmp, ap->arg_name,
                                                        ap->arg_minlen))
                                                break;
                                        if (str_match(tmp, ap->arg_name,
                                                        ap->arg_minlen))
                                                break;
@@ -100,7 +104,7 @@ register struct value *v;
                        }
                }
                if (ap != 0) {
                        }
                }
                if (ap != 0) {
-                       if (ap->arg_val.v_type != V_ERR) {
+                       if (vp->v_type != V_ERR) {
                                p_error("%s: Argument %d (%s) duplicated.",
                                        c->lc_name, ap - c->lc_arg + 1,
                                        ap->arg_name);
                                p_error("%s: Argument %d (%s) duplicated.",
                                        c->lc_name, ap - c->lc_arg + 1,
                                        ap->arg_name);
@@ -116,7 +120,7 @@ register struct value *v;
                                val_free(t);
                                flag = 0;
                        } else
                                val_free(t);
                                flag = 0;
                        } else
-                               ap->arg_val = t;
+                               *vp = t;
                }
                if (token == T_COMMA)
                        (void) s_gettok();
                }
                if (token == T_COMMA)
                        (void) s_gettok();
@@ -128,15 +132,15 @@ register struct value *v;
                flag = 0;               /* look ahead a bit */
        v->v_type = V_ERR;
        if (flag)
                flag = 0;               /* look ahead a bit */
        v->v_type = V_ERR;
        if (flag)
-               (*c->lc_func)(v);
+               (*c->lc_func)(v, av);
        if (c != 0)
        if (c != 0)
-               for (ap = c->lc_arg; ap->arg_name != 0; ap++)
-                       val_free(ap->arg_val);
+               for (vp = av; vp < &av[LCMD_NARG]; vp++)
+                       val_free(*vp);
        return 0;
 abort:
        if (c != 0)
        return 0;
 abort:
        if (c != 0)
-               for (ap = c->lc_arg; ap->arg_name != 0; ap++)
-                       val_free(ap->arg_val);
+               for (vp = av; vp < &av[LCMD_NARG]; vp++)
+                       val_free(*vp);
        return -1;
 }
 
        return -1;
 }
 
index 6ea2a46..2b82f5e 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)string.c    3.4 84/01/09";
+static char *sccsid = "@(#)string.c    3.5 84/03/23";
 #endif
 
 #include "string.h"
 #endif
 
 #include "string.h"
@@ -63,10 +63,6 @@ register min;
 }
 
 #ifdef STR_DEBUG
 }
 
 #ifdef STR_DEBUG
-struct string str_head = {
-       &str_head, &str_head
-};
-
 char *
 str_alloc(l)
 int l;
 char *
 str_alloc(l)
 int l;
@@ -76,6 +72,8 @@ int l;
        s = (struct string *) malloc((unsigned)l + str_offset);
        if (s == 0)
                return 0;
        s = (struct string *) malloc((unsigned)l + str_offset);
        if (s == 0)
                return 0;
+       if (str_head.s_forw == 0)
+               str_head.s_forw = str_head.s_back = &str_head;
        s->s_forw = str_head.s_forw;
        s->s_back = &str_head;
        str_head.s_forw = s;
        s->s_forw = str_head.s_forw;
        s->s_back = &str_head;
        str_head.s_forw = s;
index c08e01e..819f9f6 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttinit.c    3.8 84/03/03";
+static char *sccsid = "@(#)ttinit.c    3.9 84/03/23";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -11,6 +11,8 @@ ttinit()
        register char *p, *q;
        register char *t;
 
        register char *p, *q;
        register char *t;
 
+       tt_strp = tt_strings;
+
        /*
         * Set output buffer size to about 1 second of output time.
         */
        /*
         * Set output buffer size to about 1 second of output time.
         */
index dc02cad..9b81b69 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)ww.h        3.26 84/03/03   
+ *     @(#)ww.h        3.27 84/03/23   
  */
 
 #include <sgtty.h>
  */
 
 #include <sgtty.h>
@@ -151,6 +151,7 @@ struct ww_tty wwwintty;             /* the terminal settings for windows */
 char *wwterm;                  /* the terminal name */
 char wwtermcap[1024];          /* place for the termcap */
 char wwkeys[512];              /* termcap fields for the function keys */
 char *wwterm;                  /* the terminal name */
 char wwtermcap[1024];          /* place for the termcap */
 char wwkeys[512];              /* termcap fields for the function keys */
+char wwwintermcap[1024];       /* termcap for windows */
 
        /* generally useful variables */
 int wwnrow, wwncol;            /* the screen size */
 
        /* generally useful variables */
 int wwnrow, wwncol;            /* the screen size */
index 345a967..2530878 100644 (file)
@@ -1,21 +1,10 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdata.c    3.9 84/03/03";
+static char *sccsid = "@(#)wwdata.c    3.10 84/03/23";
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
-struct ww wwhead = {
-       &wwhead, &wwhead
-};
-
-struct ww_tty wwnewtty = {
-       { 0, 0, -1, -1, 0 },
-       { -1, -1, -1, -1, -1, -1 },
-       { -1, -1, -1, -1, -1, -1 },
-       0, 0, 0
-};
-
 int tt_h19();
 int tt_f100();
 int tt_generic();
 int tt_h19();
 int tt_f100();
 int tt_generic();
@@ -25,7 +14,6 @@ struct tt_tab tt_tab[] = {
        { "generic",    0, tt_generic },
        0
 };
        { "generic",    0, tt_generic },
        0
 };
-char *tt_strp = tt_strings;
 
 int wwbaudmap[] = {
        0,
 
 int wwbaudmap[] = {
        0,
index 51120b4..6e1217a 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwenviron.c 3.8 84/01/13";
+static char *sccsid = "@(#)wwenviron.c 3.9 84/03/23";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -13,8 +13,6 @@ static        char *sccsid = "@(#)wwenviron.c 3.8 84/01/13";
 wwenviron(wp)
 register struct ww *wp;
 {
 wwenviron(wp)
 register struct ww *wp;
 {
-       static char **termcap = 0;
-       static char *tbuf;
        register i;
        int pgrp = getpid();
 
        register i;
        int pgrp = getpid();
 
@@ -35,35 +33,7 @@ register struct ww *wp;
                return;
        (void) setpgrp(pgrp, pgrp);
 
                return;
        (void) setpgrp(pgrp, pgrp);
 
-       /*
-        * Do this only once if vfork().
-        */
-       if (termcap == 0) {
-               extern char **environ;
-               static char **env;
-               register char **p, **q;
-
-               for (i = 0, p = environ; *p; p++, i++)
-                       ;
-               env = (char **)malloc((unsigned)(i + 3) * sizeof (char *));
-               if (env == 0)
-                       return;
-               if ((tbuf = malloc((unsigned) 1024)) == 0)
-                       return;
-               for (p = environ, q = env; *p; p++, q++) {
-                       if (strncmp(*p, "TERM=", 5) == 0)
-                               *q = WWT_TERM;
-                       else if (strncmp(*p, "TERMCAP=", 8) == 0)
-                               termcap = q;
-                       else
-                               *q = *p;
-               }
-               if (termcap == 0)
-                       termcap = q++;
-               *q = 0;
-               environ = env;
-       }
-       *termcap = sprintf(tbuf, "TERMCAP=%sco#%d:li#%d:%s%s%s%s",
+       (void) sprintf(wwwintermcap, "TERMCAP=%sco#%d:li#%d:%s%s%s%s",
                WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr,
                wwavailmodes & WWM_REV ? WWT_REV : "",
                wwavailmodes & WWM_UL ? WWT_UL : "",
                WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr,
                wwavailmodes & WWM_REV ? WWT_REV : "",
                wwavailmodes & WWM_UL ? WWT_UL : "",
index 28526a4..83d8b76 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinit.c    3.15 84/03/03";
+static char *sccsid = "@(#)wwinit.c    3.16 84/03/23";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -7,12 +7,13 @@ static        char *sccsid = "@(#)wwinit.c    3.15 84/03/03";
 #include <sys/signal.h>
 #include <fcntl.h>
 
 #include <sys/signal.h>
 #include <fcntl.h>
 
-static char *kp = wwkeys;
-
 wwinit()
 {
        register i, j;
 wwinit()
 {
        register i, j;
-       int kn;
+       char *kp;
+       register char **p, **q;
+       char **env, **termcap;
+       extern char **environ;
 
 #ifndef O_4_1A
        wwdtablesize = getdtablesize();
 
 #ifndef O_4_1A
        wwdtablesize = getdtablesize();
@@ -20,6 +21,8 @@ wwinit()
 #include <sys/param.h>
        wwdtablesize = NOFILE;
 #endif
 #include <sys/param.h>
        wwdtablesize = NOFILE;
 #endif
+       wwhead.ww_forw = &wwhead;
+       wwhead.ww_back = &wwhead;
 
        if (signal(SIGIO, wwrint) == BADSIG)
                return -1;
 
        if (signal(SIGIO, wwrint) == BADSIG)
                return -1;
@@ -29,15 +32,27 @@ wwinit()
                return -1;
        wwwintty = wwoldtty;
        wwwintty.ww_sgttyb.sg_flags &= ~XTABS;
                return -1;
        wwwintty = wwoldtty;
        wwwintty.ww_sgttyb.sg_flags &= ~XTABS;
-       wwnewtty.ww_sgttyb.sg_flags = wwoldtty.ww_sgttyb.sg_flags;
-       wwnewtty.ww_sgttyb.sg_ispeed = wwoldtty.ww_sgttyb.sg_ispeed;
-       wwnewtty.ww_sgttyb.sg_ospeed = wwoldtty.ww_sgttyb.sg_ospeed;
-       wwnewtty.ww_lmode = wwoldtty.ww_lmode;
-       wwnewtty.ww_ldisc = wwoldtty.ww_ldisc;
+       wwnewtty.ww_sgttyb = wwoldtty.ww_sgttyb;
+       wwnewtty.ww_sgttyb.sg_erase = -1;
+       wwnewtty.ww_sgttyb.sg_kill = -1;
        wwnewtty.ww_sgttyb.sg_flags |= CBREAK;
        wwnewtty.ww_sgttyb.sg_flags &= ~(ECHO|CRMOD);
        wwnewtty.ww_sgttyb.sg_flags |= CBREAK;
        wwnewtty.ww_sgttyb.sg_flags &= ~(ECHO|CRMOD);
-       wwnewtty.ww_lmode |= LLITOUT;
-       wwnewtty.ww_fflags |= FASYNC;
+       wwnewtty.ww_tchars.t_intrc = -1;
+       wwnewtty.ww_tchars.t_quitc = -1;
+       wwnewtty.ww_tchars.t_startc = -1;
+       wwnewtty.ww_tchars.t_stopc = -1;
+       wwnewtty.ww_tchars.t_eofc = -1;
+       wwnewtty.ww_tchars.t_brkc = -1;
+       wwnewtty.ww_ltchars.t_suspc = -1;
+       wwnewtty.ww_ltchars.t_dsuspc = -1;
+       wwnewtty.ww_ltchars.t_rprntc = -1;
+       wwnewtty.ww_ltchars.t_flushc = -1;
+       wwnewtty.ww_ltchars.t_werasc = -1;
+       wwnewtty.ww_ltchars.t_lnextc = -1;
+       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)
                goto bad;
 
        if (wwsettty(0, &wwnewtty) < 0)
                goto bad;
 
@@ -101,26 +116,43 @@ wwinit()
        wwindex[WWX_NOBODY] = &wwnobody;
        wwnobody.ww_order = NWW;
 
        wwindex[WWX_NOBODY] = &wwnobody;
        wwnobody.ww_order = NWW;
 
-       addcap("kb");
-       addcap("ku");
-       addcap("kd");
-       addcap("kl");
-       addcap("kr");
-       addcap("kh");
-       if ((kn = tgetnum("kn")) >= 0) {
-               char cap[5];
+       kp = wwkeys;
+       addcap("kb", &kp);
+       addcap("ku", &kp);
+       addcap("kd", &kp);
+       addcap("kl", &kp);
+       addcap("kr", &kp);
+       addcap("kh", &kp);
+       if ((j = tgetnum("kn")) >= 0) {
+               char cap[32];
                int i;
 
                int i;
 
-               (void) sprintf(kp, "kn#%d:", kn);
+               (void) sprintf(kp, "kn#%d:", j);
                for (; *kp; kp++)
                        ;
                for (; *kp; kp++)
                        ;
-               for (i = 1; i <= kn; i++) {
+               for (i = 1; i <= j; i++) {
                        (void) sprintf(cap, "k%d", i);
                        (void) sprintf(cap, "k%d", i);
-                       addcap(cap);
+                       addcap(cap, &kp);
                        cap[0] = 'l';
                        cap[0] = 'l';
-                       addcap(cap);
+                       addcap(cap, &kp);
                }
        }
                }
        }
+       for (i = 0, p = environ; *p++; i++)
+               ;
+       if ((env = (char **)malloc((unsigned)(i + 3) * sizeof (char *))) == 0)
+               goto bad;
+       for (p = environ, q = env; *p; p++, q++) {
+               if (strncmp(*p, "TERM=", 5) == 0)
+                       *q = WWT_TERM;
+               else if (strncmp(*p, "TERMCAP=", 8) == 0)
+                       termcap = q;
+               else
+                       *q = *p;
+       }
+       *(termcap ? termcap : q++) = wwwintermcap;
+       *q = 0;
+       environ = env;
+
        (void) sigrelse(SIGIO);
        return 0;
 bad:
        (void) sigrelse(SIGIO);
        return 0;
 bad:
@@ -135,23 +167,24 @@ bad:
 }
 
 static
 }
 
 static
-addcap(cap)
+addcap(cap, kp)
 register char *cap;
 register char *cap;
+register char **kp;
 {
        char tbuf[512];
        char *tp = tbuf;
        register char *str, *p;
 
        if ((str = tgetstr(cap, &tp)) != 0) {
 {
        char tbuf[512];
        char *tp = tbuf;
        register char *str, *p;
 
        if ((str = tgetstr(cap, &tp)) != 0) {
-               while (*kp++ = *cap++)
+               while (*(*kp)++ = *cap++)
                        ;
                        ;
-               kp[-1] = '=';
+               (*kp)[-1] = '=';
                while (*str) {
                while (*str) {
-                       for (p = unctrl(*str++); *kp++ = *p++;)
+                       for (p = unctrl(*str++); *(*kp)++ = *p++;)
                                ;
                                ;
-                       kp--;
+                       (*kp)--;
                }
                }
-               *kp++ = ':';
-               *kp = 0;
+               *(*kp)++ = ':';
+               **kp = 0;
        }
 }
        }
 }
index 11ca407..5bb76bb 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwprintf.c  3.2 84/03/03";
+static char *sccsid = "@(#)wwprintf.c  3.3 84/03/23";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -11,7 +11,7 @@ char *fmt;
 {
 #include <stdio.h>
        struct _iobuf _wwbuf;
 {
 #include <stdio.h>
        struct _iobuf _wwbuf;
-       static char buf[1024];
+       char buf[1024];
 
        /*
         * A danger is that when buf overflows, _flsbuf() will be
 
        /*
         * A danger is that when buf overflows, _flsbuf() will be