From 9c51a9002e22ee888906a2f589cbe7d1ead6835c Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Thu, 17 Jun 1993 18:45:53 -0800 Subject: [PATCH] `man tty 4' dumped core on the sparc From: Craig Leres SCCS-vsn: usr.bin/man/man.c 5.27 --- usr/src/usr.bin/man/man.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/usr/src/usr.bin/man/man.c b/usr/src/usr.bin/man/man.c index 139b0ddcc6..bf14aad65b 100644 --- a/usr/src/usr.bin/man/man.c +++ b/usr/src/usr.bin/man/man.c @@ -12,7 +12,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)man.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)man.c 5.27 (Berkeley) %G%"; #endif /* not lint */ #include @@ -104,12 +104,12 @@ main(argc, argv) if (p_path || (p_path = getenv("MANPATH"))) { char buf[MAXPATHLEN], **av; - tmp = strtok(p_path, ":"); + tmp = strtok(p_path, ":"); while (tmp) { (void)snprintf(buf, sizeof(buf), "%s/", tmp); for (av = arorder; *av; ++av) - cadd(buf, strlen(buf), *av); - tmp = strtok(NULL, ":"); + cadd(buf, strlen(buf), *av); + tmp = strtok(NULL, ":"); } p_path = pathbuf; } else if (!(p_path = getpath(section)) && !p_augment) { @@ -143,22 +143,24 @@ manual(path, name) char *path, *name; { register int res; - register char *end; + register char *cp; char fname[MAXPATHLEN + 1]; - for (res = 0;; path = end + 1) { - if (!*path) /* foo: */ - break; - if (end = index(path, ':')) { - if (end == path + 1) /* foo::bar */ + for (res = 0; path != NULL && *path != '\0'; path = cp) { + if (cp = strchr(path, ':')) { + if (cp == path + 1) { /* foo::bar */ + ++cp; continue; - *end = '\0'; + } + *cp = '\0'; } (void)sprintf(fname, "%s/%s.0", path, name); if (access(fname, R_OK)) { (void)sprintf(fname, "%s/%s/%s.0", path, machine, name); - if (access(fname, R_OK)) + if (access(fname, R_OK)) { + ++cp; continue; + } } if (f_where) @@ -172,9 +174,8 @@ manual(path, name) if (!f_all) return(1); res = 1; - if (!end) - break; - *end = ':'; + if (cp) + *cp++ = ':'; } return(res); } -- 2.20.1