From 6703ae951f287d07dcb6d373346355a8e0e34b55 Mon Sep 17 00:00:00 2001 From: jkh Date: Sat, 5 Mar 1994 13:48:38 +0000 Subject: New manpage compression support. Only one macro controls compression now, DO_COMPRESS. This controls whether or not catpages are compressed or not (on by default, since little else uses the catpages and those few things that do can always configure in a `zmore' in place of more or something, and saving space is more important, IMHO). Uncompression support is now on by default since that's the only way to support mixed-mode environments. If you don't like it, just don't compress your man pages and it won't be used! :-). Supports gzip. You can also compress the man pages themselves (or gzip them) now and it will work. --- gnu/usr.bin/man/Makefile.inc | 2 + gnu/usr.bin/man/catman/Makefile | 17 +++++--- gnu/usr.bin/man/lib/Makefile | 5 ++- gnu/usr.bin/man/lib/config.h_dist | 16 +++---- gnu/usr.bin/man/makewhatis/Makefile | 4 +- gnu/usr.bin/man/makewhatis/makewhatis.sh | 9 +++- gnu/usr.bin/man/man/Makefile | 3 +- gnu/usr.bin/man/man/man.c | 73 ++++++++++++-------------------- gnu/usr.bin/man/man/man.man | 4 +- 9 files changed, 66 insertions(+), 67 deletions(-) (limited to 'gnu/usr.bin/man') diff --git a/gnu/usr.bin/man/Makefile.inc b/gnu/usr.bin/man/Makefile.inc index c0df250..b993e79 100644 --- a/gnu/usr.bin/man/Makefile.inc +++ b/gnu/usr.bin/man/Makefile.inc @@ -19,6 +19,8 @@ refer= /usr/bin/refer grap= # no grap pic= /usr/bin/pic zcat= /usr/bin/zcat +compress= gzip -c +compext= .gz # For scripts. .if !target(obj) diff --git a/gnu/usr.bin/man/catman/Makefile b/gnu/usr.bin/man/catman/Makefile index de870e3..15672d5 100644 --- a/gnu/usr.bin/man/catman/Makefile +++ b/gnu/usr.bin/man/catman/Makefile @@ -1,8 +1,15 @@ -obj cleandir clean depend rcsfreeze tags all: - @echo -n +NOMAN= noman +CLEANFILES= catman -install: - install -c -o bin -g bin -m 555 catman ${DESTDIR}/usr/bin +beforeinstall: catman + install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/catman ${DESTDIR}${BINDIR} -.include "../Makefile.inc" .include + +catman: catman.sh + sed -e 's,%compress%,${compress},' \ + -e 's,%compext%,${compext},' \ + -e 's,%zcat%,${zcat},' \ + ${.CURDIR}/catman.sh > catman + diff --git a/gnu/usr.bin/man/lib/Makefile b/gnu/usr.bin/man/lib/Makefile index d364b32..7134c86 100644 --- a/gnu/usr.bin/man/lib/Makefile +++ b/gnu/usr.bin/man/lib/Makefile @@ -6,8 +6,9 @@ CONFH= ${.CURDIR}/obj/config.h CONFH= ${.CURDIR}/config.h .endif +NOPROFILE= YES -CFLAGS+= -I${.CURDIR} -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS -DALT_SYSTEMS +CFLAGS+= -I${.CURDIR} -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_COMPRESS -DALT_SYSTEMS CLEANFILES+= ${CONFH} SRCS = util.c gripes.c @@ -25,6 +26,8 @@ depend ${CONFH}: ${.CURDIR}/config.h_dist ../Makefile.inc -e 's,%vgrind%,${vgrind},' -e 's,%refer%,${refer},' \ -e 's,%grap%,${grap},' -e 's,%zcat%,${zcat},' \ -e 's,%manpath_config_file%,${manpath_config_file},' \ + -e 's,%compress%,${compress},' \ + -e 's,%compext%,${compext},' \ ${.CURDIR}/config.h_dist > ${CONFH} .include diff --git a/gnu/usr.bin/man/lib/config.h_dist b/gnu/usr.bin/man/lib/config.h_dist index 74122df..3438e6f 100644 --- a/gnu/usr.bin/man/lib/config.h_dist +++ b/gnu/usr.bin/man/lib/config.h_dist @@ -22,11 +22,6 @@ * Austin, Texas 78712 */ -#ifdef COMPRESS -#define DO_COMPRESS -#define DO_UNCOMPRESS -#endif - /* * This is the size of a number of internal buffers. It should * probably not be less than 512. @@ -132,27 +127,26 @@ /* * Define the uncompression program(s) to use for those preformatted * pages that end in the given character. If you add extras here, you - * may need to change man.c. + * may need to change man.c. [I have no idea what FCAT and YCAT files + * are! - I will leave them in for now.. -jkh] */ -#ifdef DO_UNCOMPRESS /* .F files */ #define FCAT "" /* .Y files */ #define YCAT "" /* .Z files */ #define ZCAT "%zcat%" -#endif /* * This is the standard program to use on this system for compressing * pages once they have been formatted, and the character to tack on * to the end of those files. The program listed is expected to read * from the standard input and write compressed output to the standard - * output. + * output. These won't actually be used unless compression is enabled. */ #ifdef DO_COMPRESS -#define COMPRESSOR "" -#define COMPRESS_EXT "" +#define COMPRESSOR "%compress%" +#define COMPRESS_EXT "%compext%" #endif /* diff --git a/gnu/usr.bin/man/makewhatis/Makefile b/gnu/usr.bin/man/makewhatis/Makefile index f146c9d..ea9c4e4 100644 --- a/gnu/usr.bin/man/makewhatis/Makefile +++ b/gnu/usr.bin/man/makewhatis/Makefile @@ -5,11 +5,13 @@ CLEANFILES= makewhatis beforeinstall: makewhatis install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/makewhatis.sh ${DESTDIR}${BINDIR}/makewhatis + ${.CURDIR}/makewhatis ${DESTDIR}${BINDIR} .include makewhatis: makewhatis.sh sed -e 's/%sections%/ "1", "n", "l", "6", "8", "2", "3", "4", "5", "7", "p", "o", NULL/' \ + -e 's,%zcat%,${zcat},' \ + -e 's,%compext%,${compext},' \ ${.CURDIR}/makewhatis.sh > makewhatis diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.sh b/gnu/usr.bin/man/makewhatis/makewhatis.sh index 1d86d19..28b871d 100644 --- a/gnu/usr.bin/man/makewhatis/makewhatis.sh +++ b/gnu/usr.bin/man/makewhatis/makewhatis.sh @@ -30,9 +30,16 @@ do then for f in `find $subdir -type f -print` do + suffix=`echo $f | sed -e 's/.*\\.//'` + if [ ".$suffix" = "%compext%" ]; then + output=%zcat% + else + output=cat + fi + $output $f | \ sed -n '/^\.TH.*$/p /^\.Dt.*$/p - /^\.S[hH][ ]*NAME/,/^\.S[hH]/p' $f |\ + /^\.S[hH][ ]*NAME/,/^\.S[hH]/p'|\ sed -e 's/\\[ ]*\-/-/ s/^.P[Pp].*$// s/\\(em// diff --git a/gnu/usr.bin/man/man/Makefile b/gnu/usr.bin/man/man/Makefile index c00976b..4181aef 100644 --- a/gnu/usr.bin/man/man/Makefile +++ b/gnu/usr.bin/man/man/Makefile @@ -17,13 +17,14 @@ MAN1= ${.CURDIR}/man.1 DPADD+= ${MAN1} CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -CFLAGS+= -DDO_UNCOMPRESS -DALT_SYSTEMS -DSETREUID -DCATMODE=0664 +CFLAGS+= -DDO_COMPRESS -DALT_SYSTEMS -DSETREUID -DCATMODE=0664 CLEANFILES+= ${MAN1} ${MAN1}: ${.CURDIR}/man.man sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \ -e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \ -e 's,%manpath_config_file%,${manpath_config_file},' \ + -e 's,%compress%,${compress},' \ ${.CURDIR}/man.man > ${MAN1} .include diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c index c5b4ee0..5e7d157 100644 --- a/gnu/usr.bin/man/man/man.c +++ b/gnu/usr.bin/man/man/man.c @@ -524,11 +524,15 @@ convert_name (name, to_cat) if (to_cat) { int len = strlen (name) + 3; + int cextlen = strlen(COMPRESS_EXT); + to_name = (char *) malloc (len); if (to_name == NULL) gripe_alloc (len, "to_name"); strcpy (to_name, name); - strcat (to_name, ".Z"); + /* Avoid tacking it on twice */ + if (strcmp(name + (len - (3 + cextlen)), COMPRESS_EXT)) + strcat (to_name, COMPRESS_EXT); } else to_name = strdup (name); @@ -660,43 +664,30 @@ make_name (path, section, name, cat) return &names[0]; } -#ifdef DO_UNCOMPRESS char * get_expander (file) char *file; { - char *expander = NULL; - int len = strlen (file); + char *end = file + (strlen (file) - 1); - if (file[len - 2] == '.') - { - switch (file[len - 1]) - { + while (end > file && end[-1] != '.') + --end; + if (end == file) + return NULL; #ifdef FCAT - case 'F': - if (strcmp (FCAT, "") != 0) - expander = strdup (FCAT); - break; -#endif + if (*end == 'F') + return FCAT; +#endif /* FCAT */ #ifdef YCAT - case 'Y': - if (strcmp (YCAT, "") != 0) - expander = strdup (YCAT); - break; -#endif + if (*end == 'Y') + return YCAT; +#endif /* YCAT */ #ifdef ZCAT - case 'Z': - if (strcmp (ZCAT, "") != 0) - expander = strdup (ZCAT); - break; -#endif - default: - break; - } - } - return expander; + if (*end == 'Z' || !strcmp(end, "gz")) + return ZCAT; +#endif /* ZCAT */ + return NULL; } -#endif /* * Simply display the preformatted page. @@ -712,16 +703,12 @@ display_cat_file (file) if (access (file, R_OK) == 0) { -#ifdef DO_UNCOMPRESS char *expander = get_expander (file); if (expander != NULL) sprintf (command, "%s %s | %s", expander, file, pager); else sprintf (command, "%s %s", pager, file); -#else - sprintf (command, "%s %s", pager, file); -#endif found = do_system_command (command); } @@ -911,7 +898,6 @@ parse_roff_directive (cp, file, buf) strcat (buf, " | "); strcat (buf, NROFF); } - if (tbl_found && !troff && strcmp (COL, "") != 0) { strcat (buf, " | "); @@ -992,22 +978,21 @@ make_roff_command (file) if (debug) fprintf (stderr, "using default preprocessor sequence\n"); + if ((cp = get_expander(file)) == NULL) + cp = "cat"; + sprintf(buf, "%s %s | ", cp, file); #ifdef HAS_TROFF if (troff) { if (strcmp (TBL, "") != 0) { - strcpy (buf, TBL); - strcat (buf, " "); - strcat (buf, file); + strcat (buf, TBL); strcat (buf, " | "); strcat (buf, TROFF); } else { - strcpy (buf, TROFF); - strcat (buf, " "); - strcat (buf, file); + strcat (buf, TROFF); } } else @@ -1015,17 +1000,13 @@ make_roff_command (file) { if (strcmp (TBL, "") != 0) { - strcpy (buf, TBL); - strcat (buf, " "); - strcat (buf, file); + strcat (buf, TBL); strcat (buf, " | "); strcat (buf, NROFF); } else { strcpy (buf, NROFF); - strcat (buf, " "); - strcat (buf, file); } if (strcmp (COL, "") != 0) @@ -1073,7 +1054,7 @@ make_cat_file (path, man_file, cat_file) #endif /* * Don't let the user interrupt the system () call and screw up - * the formmatted man page if we're not done yet. + * the formatted man page if we're not done yet. */ fprintf (stderr, "Formatting page, please wait..."); fflush(stderr); diff --git a/gnu/usr.bin/man/man/man.man b/gnu/usr.bin/man/man/man.man index 2c034fe..bddfc02 100644 --- a/gnu/usr.bin/man/man/man.man +++ b/gnu/usr.bin/man/man/man.man @@ -27,7 +27,9 @@ like to display the formatted pages. If section is specified, man only looks in that section of the manual. You may also specify the order to search the sections for entries and which preprocessors to run on the source files via command line options or environment -variables. +variables. If enabled by the system administrator, formatted man +pages will also be compressed with the `%compress%' command to save +space. .SH OPTIONS .TP .B \-\^M " path" -- cgit v1.1