summaryrefslogtreecommitdiff
path: root/sbin/fdisk
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/fdisk
parentd342fa430e91c59a31ca21ada4b5f48d3793106f (diff)
gzip embedded man pages, and pipe through gunzip when viewing.
ok deraadt@
Diffstat (limited to 'sbin/fdisk')
-rw-r--r--sbin/fdisk/Makefile14
-rw-r--r--sbin/fdisk/cmd.c16
2 files changed, 17 insertions, 13 deletions
diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile
index 1c4ab151976..ca52b654f48 100644
--- a/sbin/fdisk/Makefile
+++ b/sbin/fdisk/Makefile
@@ -1,5 +1,5 @@
#
-# $OpenBSD: Makefile,v 1.27 2004/05/03 15:18:19 drahn Exp $
+# $OpenBSD: Makefile,v 1.28 2004/11/06 18:57:59 otto Exp $
#
# Copyright (c) 1997 Tobias Weingartner
# All rights reserved.
@@ -38,14 +38,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: fdisk.cat8
- (echo 'char manpage[] = "\\'; \
- sed -e 's/[\\"]/\\&/g' -e 's/$$/\\n\\/' fdisk.cat8; \
- echo '";' ) > manual.c
+ (echo 'const char manpage[] = {'; \
+ gzip -9c fdisk.cat8 | hexdump -ve '"0x" 1/1 "%02x,"'; \
+ echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c
.endif
.else
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 9dc885c3a24..beb47b9f35b 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.36 2004/09/18 23:22:05 deraadt Exp $ */
+/* $OpenBSD: cmd.c,v 1.37 2004/11/06 18:57:59 otto Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -379,16 +379,20 @@ Xmanual(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset)
char *pager = "/usr/bin/less";
char *p;
sig_t opipe;
- extern char manpage[];
+ extern const char manpage[];
+ extern const int manpage_sz;
FILE *f;
opipe = signal(SIGPIPE, SIG_IGN);
if ((p = getenv("PAGER")) != NULL && (*p != '\0'))
pager = p;
- f = popen(pager, "w");
- if (f) {
- (void) fwrite(manpage, strlen(manpage), 1, f);
- pclose(f);
+ if (asprintf(&p, "gunzip -qc|%s", pager) != -1) {
+ f = popen(p, "w");
+ if (f) {
+ (void) fwrite(manpage, manpage_sz, 1, f);
+ pclose(f);
+ }
+ free(p);
}
(void)signal(SIGPIPE, opipe);