Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/man Recognize .gz and .bz2 suffixes so $ man ./man.1...



details:   https://anonhg.NetBSD.org/src/rev/0c6ac7db0bac
branches:  trunk
changeset: 790410:0c6ac7db0bac
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 06 16:43:41 2013 +0000

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

diffstat:

 usr.bin/man/man.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r 221b59ba0c19 -r 0c6ac7db0bac usr.bin/man/man.c
--- a/usr.bin/man/man.c Sun Oct 06 16:34:48 2013 +0000
+++ b/usr.bin/man/man.c Sun Oct 06 16:43:41 2013 +0000
@@ -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 @@
 #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 @@
                        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;



Home | Main Index | Thread Index | Old Index