From owner-svn-src-all@FreeBSD.ORG Fri Jun 3 05:16:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC595106564A; Fri, 3 Jun 2011 05:16:33 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A41678FC19; Fri, 3 Jun 2011 05:16:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p535GXKX049084; Fri, 3 Jun 2011 05:16:33 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p535GXau049081; Fri, 3 Jun 2011 05:16:33 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <201106030516.p535GXau049081@svn.freebsd.org> From: Ruslan Ermilov Date: Fri, 3 Jun 2011 05:16:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222635 - head/usr.bin/man X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jun 2011 05:16:33 -0000 Author: ru Date: Fri Jun 3 05:16:33 2011 New Revision: 222635 URL: http://svn.freebsd.org/changeset/base/222635 Log: Added support for the MANWIDTH environment variable: If set to a numeric value, used as the width manpages should be displayed. Otherwise, if set to a special value ``tty'', and output is to a terminal, the pages may be displayed over the whole width of the screen. Modified: head/usr.bin/man/man.1 head/usr.bin/man/man.sh Modified: head/usr.bin/man/man.1 ============================================================================== --- head/usr.bin/man/man.1 Fri Jun 3 03:39:33 2011 (r222634) +++ head/usr.bin/man/man.1 Fri Jun 3 05:16:33 2011 (r222635) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 1, 2010 +.Dd June 2, 2011 .Dt MAN 1 .Os .Sh NAME @@ -283,6 +283,12 @@ Restricts manual sections searched to th Corresponds to the .Fl S option. +.It Ev MANWIDTH +If set to a numeric value, used as the width manpages should be displayed. +Otherwise, if set to a special value +.Dq Li tty , +and output is to a terminal, +the pages may be displayed over the whole width of the screen. .It Ev PAGER Program used to display files. If unset, Modified: head/usr.bin/man/man.sh ============================================================================== --- head/usr.bin/man/man.sh Fri Jun 3 03:39:33 2011 (r222634) +++ head/usr.bin/man/man.sh Fri Jun 3 05:16:33 2011 (r222635) @@ -112,7 +112,11 @@ check_man() { setup_cattool $manpage decho " Found manpage $manpage" - if exists "$2" && is_newer $found $manpage; then + if [ -n "${use_width}" ]; then + # non-standard width + unset use_cat + decho " Skipping catpage: non-standard page width" + elif exists "$2" && is_newer $found $manpage; then # cat page found and is newer, use that use_cat=yes catpage=$found @@ -352,6 +356,10 @@ man_display_page() { ;; esac + if [ -n "${use_width}" ]; then + NROFF="$NROFF -rLL=${use_width}n -rLT=${use_width}n" + fi + if [ -n "$MANROFFSEQ" ]; then set -- -$MANROFFSEQ while getopts 'egprtv' preproc_arg; do @@ -562,6 +570,35 @@ man_setup() { build_manpath man_setup_locale + man_setup_width +} + +# Usage: man_setup_width +# Set up page width. +man_setup_width() { + local sizes + + unset use_width + case "$MANWIDTH" in + [0-9]*) + if [ "$MANWIDTH" -gt 0 2>/dev/null ]; then + use_width=$MANWIDTH + fi + ;; + [Tt][Tt][Yy]) + if { sizes=$($STTY size 0>&3 2>/dev/null); } 3>&1; then + set -- $sizes + if [ $2 -gt 80 ]; then + use_width=$(($2-2)) + fi + fi + ;; + esac + if [ -n "$use_width" ]; then + decho "Using non-standard page width: ${use_width}" + else + decho 'Using standard page width' + fi } # Usage: man_setup_locale @@ -900,6 +937,7 @@ VGRIND=vgrind COL=/usr/bin/col LOCALE=/usr/bin/locale +STTY=/bin/stty SYSCTL=/sbin/sysctl debug=0