SCCS-vsn: usr.bin/window/ww.h 3.41
SCCS-vsn: usr.bin/window/wwenviron.c 3.17
SCCS-vsn: usr.bin/window/wwinit.c 3.27
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 */
-static char sccsid[] = "@(#)wwenviron.c 3.16 %G%";
+static char sccsid[] = "@(#)wwenviron.c 3.17 %G%";
{
register i;
int pgrp = getpid();
{
register i;
int pgrp = getpid();
if ((i = open("/dev/tty", 0)) < 0)
goto bad;
if ((i = open("/dev/tty", 0)) < 0)
goto bad;
/* SIGPIPE is the only one we ignore */
(void) signal(SIGPIPE, SIG_DFL);
(void) sigsetmask(0);
/* SIGPIPE is the only one we ignore */
(void) signal(SIGPIPE, SIG_DFL);
(void) sigsetmask(0);
- (void) sprintf(wwwintermcap, "TERMCAP=%sco#%d:li#%d:%s%s%s%s%s%s%s",
+ /*
+ * Two conditions that make destructive setenv ok:
+ * 1. setenv() copies the string,
+ * 2. we've already called tgetent which copies the termcap entry.
+ */
+ (void) sprintf(buf, "%sco#%d:li#%d:%s%s%s%s%s%s%s",
WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr,
wwavailmodes & WWM_REV ? WWT_REV : "",
wwavailmodes & WWM_BLK ? WWT_BLK : "",
WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr,
wwavailmodes & WWM_REV ? WWT_REV : "",
wwavailmodes & WWM_BLK ? WWT_BLK : "",
wwavailmodes & WWM_DIM ? WWT_DIM : "",
wwavailmodes & WWM_USR ? WWT_USR : "",
wwkeys);
wwavailmodes & WWM_DIM ? WWT_DIM : "",
wwavailmodes & WWM_USR ? WWT_USR : "",
wwkeys);
+ (void) setenv("TERMCAP", buf, 1);
+ (void) sprintf(buf, "%d", wp->ww_id + 1);
+ (void) setenv("WINDOW_ID", buf, 1);
return 0;
bad:
wwerrno = WWE_SYS;
return 0;
bad:
wwerrno = WWE_SYS;
-static char sccsid[] = "@(#)wwinit.c 3.26 %G%";
+static char sccsid[] = "@(#)wwinit.c 3.27 %G%";
{
register i, j;
char *kp;
{
register i, j;
char *kp;
- register char **p, **q;
- char **env, **termcap = 0;
- extern char **environ;
int s;
wwdtablesize = getdtablesize();
int s;
wwdtablesize = getdtablesize();
- 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;
+ /*
+ * It's ok to do this here even if setenv() is destructive
+ * since tt_init() has already made its own copy of it and
+ * wwterm now points to the copy.
+ */
+ (void) setenv("TERM", "window", 1);
(void) signal(SIGPIPE, SIG_IGN);
(void) sigsetmask(s);
(void) signal(SIGPIPE, SIG_IGN);
(void) sigsetmask(s);