diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-16 18:58:47 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-16 18:58:47 +0000 |
commit | dcd50ca4b94f59d4bfad7f4b0fef181cffb407f8 (patch) | |
tree | 1bc64023d666854677630e4864ed36c496a21977 /usr.bin/man/man.c | |
parent | b01194e474010bc2193cc65af982ccbd2c6d2172 (diff) |
Support MANPAGER environment variable plus some KNF I had in my tree.
Closes PR 3563
Diffstat (limited to 'usr.bin/man/man.c')
-rw-r--r-- | usr.bin/man/man.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index 847dbf12338..9fec70f73df 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.26 2003/06/10 22:20:48 deraadt Exp $ */ +/* $OpenBSD: man.c,v 1.27 2003/12/16 18:58:46 millert Exp $ */ /* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -static char rcsid[] = "$OpenBSD: man.c,v 1.26 2003/06/10 22:20:48 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: man.c,v 1.27 2003/12/16 18:58:46 millert Exp $"; #endif #endif /* not lint */ @@ -159,6 +159,9 @@ main(int argc, char *argv[]) if (!f_cat && !f_how && !f_where) { if (!isatty(1)) f_cat = 1; + else if ((pager = getenv("MANPAGER")) != NULL && + (*pager != '\0')) + pager = check_pager(pager); else if ((pager = getenv("PAGER")) != NULL && (*pager != '\0')) pager = check_pager(pager); else @@ -703,11 +706,11 @@ check_pager(char *name) ++p; /* make sure it's "more", not "morex" */ - if (!strncmp(p, "more", 4) && (!p[4] || isspace(p[4]))){ + if (!strncmp(p, "more", 4) && (p[4] == '\0' || isspace(p[4]))){ save = name; /* allocate space to add the "-s" */ len = strlen(save) + 1 + sizeof("-s"); - if (!(name =malloc(len))) + if ((name = malloc(len)) == NULL) err(1, NULL); (void)snprintf(name, len, "%s %s", save, "-s"); } |