diff --git a/usr/src/cmd/man/src/man.c b/usr/src/cmd/man/src/man.c index 41439fd..9b39f38 100644 --- a/usr/src/cmd/man/src/man.c +++ b/usr/src/cmd/man/src/man.c @@ -17,13 +17,15 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - */ -/* + * + * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T. */ -/* All rights reserved. */ +/* + * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T. + * All rights reserved. + */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 @@ -1861,8 +1863,7 @@ searchdir(char *path, char *dir, char *name) char sectpath[MAXPATHLEN+1]; char file[MAXNAMLEN+1]; char dname[MAXPATHLEN+1]; - char *last; - int nlen; + int last; /* * TRANSLATION_NOTE - message for man -d or catman -p @@ -1870,7 +1871,7 @@ searchdir(char *path, char *dir, char *name) */ DPRINTF(gettext(" scanning = %s\n"), dir); (void) sprintf(sectpath, "%s/%s", path, dir); - (void) snprintf(file, MAXPATHLEN, "%s.", name); + (void) snprintf(file, MAXPATHLEN, "%s", name); if ((sdp = opendir(sectpath)) == 0) { if (errno != ENOTDIR) /* ignore matching cruft */ @@ -1878,9 +1879,16 @@ searchdir(char *path, char *dir, char *name) return (0); } while ((sd = readdir(sdp))) { - last = strrchr(sd->d_name, '.'); - nlen = last - sd->d_name; - (void) sprintf(dname, "%.*s.", nlen, sd->d_name); + for (last = strlen(sd->d_name)-1; last > 0; last--) { + /* hacky support for .gz */ + if (last > 1 && sd->d_name[last-2] == '.' && + sd->d_name[last-1] == 'g' && sd->d_name[last] == 'z') + last -= 3; + if (sd->d_name[last] == '.') + break; + } + (void) strncpy(dname, sd->d_name, last); + dname[last] = '\0'; if (eq(dname, file) || eq(sd->d_name, name)) { if (no_sroff && *dir == 's') { sman_no_man_no_sroff = 1; @@ -2777,10 +2785,10 @@ so_again: if (++socount > SOLIMIT) { macros, troffit ? "" : " | col -x", tmpname); } else - (void) sprintf(cbp, "%s %s %s%s > %s", + (void) sprintf(cbp, "gzcat -f %s | %s - %s%s > %s", + pipestage == 0 ? manpname : "-", troffit ? troffcmd : "nroff -u0 -Tlp", - macros, pipestage == 0 ? manpname : "-", - troffit ? "" : " | col -x", tmpname); + macros, troffit ? "" : " | col -x", tmpname); /* Reformat the page. */ if (sys(cmdbuf)) {