From owner-freebsd-stable@FreeBSD.ORG Sat Jul 19 15:34:54 2003 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7AC2A37B401 for ; Sat, 19 Jul 2003 15:34:54 -0700 (PDT) Received: from out001.verizon.net (out001pub.verizon.net [206.46.170.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C05343FB1 for ; Sat, 19 Jul 2003 15:34:53 -0700 (PDT) (envelope-from cswiger@mac.com) Received: from mac.com ([141.149.47.46]) by out001.verizon.net (InterMail vM.5.01.05.33 201-253-122-126-133-20030313) with ESMTP id <20030719223452.RAWK12592.out001.verizon.net@mac.com>; Sat, 19 Jul 2003 17:34:52 -0500 Message-ID: <3F19C78A.7030008@mac.com> Date: Sat, 19 Jul 2003 18:34:50 -0400 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stable@FreeBSD.ORG, jwe@che.utexas.edu X-Enigmail-Version: 0.76.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH at out001.verizon.net from [141.149.47.46] at Sat, 19 Jul 2003 17:34:52 -0500 Subject: A patch to man to handle "man.1"... X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jul 2003 22:34:54 -0000 Hi, all-- I've always thought that specifying sections via "man -s 1 man" or "man 1 man" was ugly, and didn't work very well with filename completion. Diff relative to /usr/src/gnu/usr.bin/man to also handle the syntax of "man man.1": --- man_old/man.c Sat Jul 19 17:17:13 2003 +++ man/man.c Sat Jul 19 18:08:23 2003 @@ -149,6 +149,8 @@ void do_apropos (); void do_whatis (); int man (); + int arglength = 0; + int i; prognam = mkprogname (argv[0]); longsec = NULL; @@ -200,6 +202,23 @@ continue; } + + /* handle a section specified as "man.1" */ + arglength = strlen(nextarg); + + for (i = arglength; i > 0 ; i--) { + if (nextarg[i] == '.') { + tmp = is_section (&(nextarg[i + 1]), manp); + if (tmp != NULL) { + shortsec = tmp; + nextarg[i] = '\0'; + + if (debug) + fprintf (stderr, "\nsection (via suffix): %s\n", shortsec); + } + break; + } + } if (apropos) { do_apropos (nextarg); --- man_old/version.h Sat Jul 19 17:17:13 2003 +++ man/version.h Sat Jul 19 18:28:07 2003 @@ -14,4 +14,4 @@ * Austin, Texas 78712 */ -static char version[] = "1.1"; +static char version[] = "1.2"; -- This patch seems to handle boundary cases like rc.i386 (which at least somewhat resembles a section number :-) properly. -- -Chuck PS: People using ZSH will find the following completion script very handy in conjunction with the above, as it provides tab-based completion for manpages: # Manual page completion man_glob () { local a read -cA a if [[ $a[2] = [0-9]* ]] then reply=( $^manpath/man$a[2]/$1*$2(N:t:r) ) else reply=( $^manpath/man*/$1*$2(N:t:r) ) fi } compctl -K man_glob man