summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-11-06 18:58:00 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-11-06 18:58:00 +0000
commite7b9f1287fa3b69e6b82148f3838cf4a47b1ac39 (patch)
tree875eeebb1f1c91f6b49498490a0a515d0d36dbbf /sbin/disklabel
parentd342fa430e91c59a31ca21ada4b5f48d3793106f (diff)
gzip embedded man pages, and pipe through gunzip when viewing.
ok deraadt@
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/Makefile14
-rw-r--r--sbin/disklabel/editor.c16
2 files changed, 17 insertions, 13 deletions
diff --git a/sbin/disklabel/Makefile b/sbin/disklabel/Makefile
index d579685a120..e21d059622c 100644
--- a/sbin/disklabel/Makefile
+++ b/sbin/disklabel/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.33 2004/05/03 15:18:19 drahn Exp $
+# $OpenBSD: Makefile,v 1.34 2004/11/06 18:57:59 otto Exp $
PROG= disklabel
SRCS= disklabel.c dkcksum.c editor.c manual.c
@@ -13,14 +13,14 @@ CLEANFILES+=manual.c
.ifdef NOMAN
manual.c:
- (echo 'char manpage[] = "\\'; \
- echo "no manual\\"; \
- echo '";' ) > manual.c
+ (echo 'const char manpage[] = {'; \
+ echo 'no manual' | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \
+ echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c
.else
manual.c: disklabel.cat8
- (echo 'char manpage[] = "\\'; \
- sed -e 's/[\\"]/\\&/g' -e 's/$$/\\n\\/' disklabel.cat8; \
- echo '";' ) > manual.c
+ (echo 'const char manpage[] = {'; \
+ gzip -9c disklabel.cat8 | hexdump -ve '"0x" 1/1 "%02x,"'; \
+ echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c
.endif
.if (${MACHINE} == "amiga")
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 83f8d689fa5..aa81c12bfee 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.96 2004/10/04 15:09:41 otto Exp $ */
+/* $OpenBSD: editor.c,v 1.97 2004/11/06 18:57:59 otto Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.96 2004/10/04 15:09:41 otto Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.97 2004/11/06 18:57:59 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -295,17 +295,21 @@ editor(struct disklabel *lp, int f, char *dev, char *fstabfile)
case 'M': {
sig_t opipe = signal(SIGPIPE, SIG_IGN);
- char *pager;
- extern char manpage[];
+ char *pager, *cmd = NULL;
+ extern const char manpage[];
+ extern const int manpage_sz;
if ((pager = getenv("PAGER")) == NULL || *pager == '\0')
pager = _PATH_LESS;
- if ((fp = popen(pager, "w")) != NULL) {
- (void) fwrite(manpage, strlen(manpage), 1, fp);
+
+ if (asprintf(&cmd, "gunzip -qc|%s", pager) != -1 &&
+ (fp = popen(cmd, "w")) != NULL) {
+ (void) fwrite(manpage, manpage_sz, 1, fp);
pclose(fp);
} else
warn("unable to execute %s", pager);
+ free(cmd);
(void)signal(SIGPIPE, opipe);
break;
}