Module Name:    src
Committed By:   christos
Date:           Sun Oct  6 16:43:41 UTC 2013

Modified Files:
        src/usr.bin/man: man.c

Log Message:
Recognize .gz and .bz2 suffixes so $ man ./man.1.gz works. From Franco Fichter
via dfly.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/man/man.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/man/man.c
diff -u src/usr.bin/man/man.c:1.57 src/usr.bin/man/man.c:1.58
--- src/usr.bin/man/man.c:1.57	Sun Oct  6 12:29:26 2013
+++ src/usr.bin/man/man.c	Sun Oct  6 12:43:41 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.57 2013/10/06 16:29:26 christos Exp $	*/
+/*	$NetBSD: man.c,v 1.58 2013/10/06 16:43:41 christos Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19
 #if 0
 static char sccsid[] = "@(#)man.c	8.17 (Berkeley) 1/31/95";
 #else
-__RCSID("$NetBSD: man.c,v 1.57 2013/10/06 16:29:26 christos Exp $");
+__RCSID("$NetBSD: man.c,v 1.58 2013/10/06 16:43:41 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -555,9 +555,14 @@ manual(char *page, struct manstate *mp, 
 			goto notfound;
 
 		/* clip suffix for the suffix check below */
-		p = strrchr(escpage, '.');
-		if (p && p[0] == '.' && isdigit((unsigned char)p[1]))
-			p[0] = '\0';
+		if ((p = strrchr(escpage, '.')) != NULL) {
+			if (strcmp(p, ".gz") == 0 || strcmp(p, ".bz2") == 0) {
+				*p = '\0';
+				p = strrchr(escpage, '.');
+			}
+			if (p && isdigit((unsigned char)p[1]))
+				*p = '\0';
+		}
 
 		found = 0;
 		for (cnt = pg->gl_pathc - pg->gl_matchc;

Reply via email to