Project

General

Profile

Bug #1157 » illumos-man-gz.diff

Andrew Stormont, 2011-06-27 01:28 PM

View differences:

usr/src/cmd/man/src/man.c
17 17
 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18
 *
19 19
 * CDDL HEADER END
20
 */
21
/*
20
 *
21
 * Copyright (c) 2011 Nexenta Systems, Inc.  All rights reserved.
22 22
 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
23 23
 */
24 24

  
25
/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989  AT&T.	*/
26
/*		All rights reserved.					*/
25
/*
26
 *	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989  AT&T.
27
 *		All rights reserved.
28
 */
27 29

  
28 30
/*
29 31
 * University Copyright- Copyright (c) 1982, 1986, 1988
......
1861 1863
	char sectpath[MAXPATHLEN+1];
1862 1864
	char file[MAXNAMLEN+1];
1863 1865
	char dname[MAXPATHLEN+1];
1864
	char *last;
1865
	int nlen;
1866
	int last;
1866 1867

  
1867 1868
/*
1868 1869
 * TRANSLATION_NOTE - message for man -d or catman -p
......
1870 1871
 */
1871 1872
	DPRINTF(gettext("    scanning = %s\n"), dir);
1872 1873
	(void) sprintf(sectpath, "%s/%s", path, dir);
1873
	(void) snprintf(file, MAXPATHLEN, "%s.", name);
1874
	(void) snprintf(file, MAXPATHLEN, "%s", name);
1874 1875

  
1875 1876
	if ((sdp = opendir(sectpath)) == 0) {
1876 1877
		if (errno != ENOTDIR)	/* ignore matching cruft */
......
1878 1879
		return (0);
1879 1880
	}
1880 1881
	while ((sd = readdir(sdp))) {
1881
		last = strrchr(sd->d_name, '.');
1882
		nlen = last - sd->d_name;
1883
		(void) sprintf(dname, "%.*s.", nlen, sd->d_name);
1882
		/* hacky support for .gz */
1883
		for (last = strlen(sd->d_name)-1; last > 0; last--) {
1884
			if (last > 1) {
1885
			 	if (sd->d_name[last-2] == '.' && 
1886
				    sd->d_name[last-1] == 'g' && 
1887
				    sd->d_name[last] == 'z')
1888
					last -= 3;
1889
				if (sd->d_name[last] == '.')
1890
					break;
1891
			}
1892
		}
1893
		if (!last)
1894
			continue;
1895
		(void) strncpy(dname, sd->d_name, last);
1896
		dname[last] = '\0';
1884 1897
		if (eq(dname, file) || eq(sd->d_name, name)) {
1885 1898
			if (no_sroff && *dir == 's') {
1886 1899
				sman_no_man_no_sroff = 1;
......
2338 2351
	char *new_m;
2339 2352
	char	*tmpsubdir;
2340 2353

  
2354
	/* hacky support for .gz */
2355
	int pg_len, gzipit = ((pg_len = strlen(pg)) > 3 && pg[pg_len-3] == '.' 
2356
		&& pg[pg_len-2] == 'g' && pg[pg_len-1] == 'z');
2357

  
2341 2358
	found++;
2342 2359

  
2343 2360
	if (*dir != 'm' && *dir != 's')
......
2777 2794
	    macros, troffit ? "" : " | col -x", tmpname);
2778 2795

  
2779 2796
		} else
2780
	(void) sprintf(cbp, "%s %s %s%s > %s",
2797
	(void) sprintf(cbp, "%s %s | %s - %s%s > %s",
2798
	    gzipit ? "gzip -c -d" : "cat",
2799
	    pipestage == 0 ? manpname : "-",
2781 2800
	    troffit ? troffcmd : "nroff -u0 -Tlp",
2782
	    macros, pipestage == 0 ? manpname : "-",
2783
	    troffit ? "" : " | col -x", tmpname);
2801
	    macros, troffit ? "" : " | col -x", tmpname);
2784 2802

  
2785 2803
		/* Reformat the page. */
2786 2804
		if (sys(cmdbuf)) {
(1-1/3)