diff options
-rw-r--r-- | lib/libocurses/pathnames.h | 5 | ||||
-rw-r--r-- | lib/libocurses/termcap.c | 63 |
2 files changed, 34 insertions, 34 deletions
diff --git a/lib/libocurses/pathnames.h b/lib/libocurses/pathnames.h index a10b561095e..26153535eee 100644 --- a/lib/libocurses/pathnames.h +++ b/lib/libocurses/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.1 1998/07/23 21:10:26 millert Exp $ */ +/* $OpenBSD: pathnames.h,v 1.2 1998/11/19 17:07:14 millert Exp $ */ /* $NetBSD: pathnames.h,v 1.3 1995/02/27 10:18:43 cgd Exp $ */ /* @@ -36,4 +36,5 @@ * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 */ -#define _PATH_DEF ".termcap /usr/share/misc/termcap" +#define _PATH_TERMCAP "/usr/share/misc/termcap" +#define _PATH_DEF __CONCAT(".termcap",_PATH_TERMCAP) diff --git a/lib/libocurses/termcap.c b/lib/libocurses/termcap.c index 0f55e14ba75..004efe7ed53 100644 --- a/lib/libocurses/termcap.c +++ b/lib/libocurses/termcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: termcap.c,v 1.3 1998/11/04 21:21:24 millert Exp $ */ +/* $OpenBSD: termcap.c,v 1.4 1998/11/19 17:07:14 millert Exp $ */ /* $NetBSD: termcap.c,v 1.7 1995/06/05 19:45:52 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$OpenBSD: termcap.c,v 1.3 1998/11/04 21:21:24 millert Exp $"; +static char rcsid[] = "$OpenBSD: termcap.c,v 1.4 1998/11/19 17:07:14 millert Exp $"; #endif #endif /* not lint */ @@ -92,39 +92,38 @@ tgetent(bp, name) pvec = pathvec; tbuf = bp; - if (!issetugid()) { - cp = getenv("TERMCAP"); - /* - * TERMCAP can have one of two things in it. It can be the name - * of a file to use instead of /usr/share/misc/termcap. In this - * case it better start with a "/". Or it can be an entry to - * use so we don't have to read the file. In this case it - * has to already have the newlines crunched out. If TERMCAP - * does not hold a file name then a path of names is searched - * instead. The path is found in the TERMPATH variable, or - * becomes "$HOME/.termcap /usr/share/misc/termcap" if no - * TERMPATH exists. - */ - if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */ - if ((termpath = getenv("TERMPATH")) != NULL) - strlcpy(pathbuf, termpath, sizeof(pathbuf)); - else { - if ((home = getenv("HOME")) != NULL && - strlen(home) + sizeof(_PATH_DEF) < - sizeof(pathbuf)) { - sprintf(pathbuf, "%s/%s", home, - _PATH_DEF); - } else { - strlcpy(pathbuf, _PATH_DEF, - sizeof(pathbuf)); - } + cp = getenv("TERMCAP"); + /* + * TERMCAP can have one of two things in it. It can be the name + * of a file to use instead of /usr/share/misc/termcap. In this + * case it better start with a "/". Or it can be an entry to use + * so we don't have to read the file. In this case it has to + * already have the newlines crunched out. If TERMCAP does not + * hold a file name then a path of names is searched instead. + * The path is found in the TERMPATH variable, or becomes + * "$HOME/.termcap /usr/share/misc/termcap" if no TERMPATH exists. + */ + if (issetugid()) { + strlcpy(pathbuf, _PATH_TERMCAP, sizeof(pathbuf)); + } else if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */ + if ((termpath = getenv("TERMPATH")) != NULL) + strlcpy(pathbuf, termpath, sizeof(pathbuf)); + else { + if ((home = getenv("HOME")) != NULL && + strlen(home) + sizeof(_PATH_DEF) < + sizeof(pathbuf)) { + sprintf(pathbuf, "%s/%s", home, + _PATH_DEF); + } else { + strlcpy(pathbuf, _PATH_DEF, + sizeof(pathbuf)); } - } else { /* user-defined path in TERMCAP */ - /* still can be tokenized */ - strlcpy(pathbuf, cp, sizeof(pathbuf)); } - *fname++ = pathbuf; /* tokenize path into vector of names */ + } else { /* user-defined path in TERMCAP */ + /* still can be tokenized */ + strlcpy(pathbuf, cp, sizeof(pathbuf)); } + *fname++ = pathbuf; /* tokenize path into vector of names */ /* split pathbuf into a vector of paths */ p = pathbuf; |