From mvela@irb.hr  Mon Sep 19 18:22:37 2005
Return-Path: <mvela@irb.hr>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B58CB16A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Sep 2005 18:22:37 +0000 (GMT)
	(envelope-from mvela@irb.hr)
Received: from mail.irb.hr (mail.irb.hr [161.53.22.8])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 8FBCD43D49
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Sep 2005 18:22:36 +0000 (GMT)
	(envelope-from mvela@irb.hr)
Received: from diziet.irb.hr (diziet.irb.hr [161.53.22.31])
	by mail.irb.hr (8.13.3/8.13.3/Debian-6) with ESMTP id j8JIMFM0006089
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Sep 2005 20:22:15 +0200
Received: from diziet.irb.hr (localhost [127.0.0.1])
	by diziet.irb.hr (8.13.5/8.13.5/Debian-1) with ESMTP id j8JIMXTK022575
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 19 Sep 2005 20:22:33 +0200
Received: (from mvela@localhost)
	by diziet.irb.hr (8.13.5/8.13.5/Submit) id j8JIMXg7022573
	for FreeBSD-gnats-submit@freebsd.org; Mon, 19 Sep 2005 20:22:33 +0200
Message-Id: <20050919182233.GO7473@diziet.irb.hr>
Date: Mon, 19 Sep 2005 20:22:33 +0200
From: Matej Vela <vela@debian.org>
Reply-To: Matej Vela <vela@debian.org>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] tmac.vgrind: groff cleanup broke indexing
X-Send-Pr-Version: 3.113

>Number:         86343
>Category:       bin
>Synopsis:       [patch] tmac.vgrind: groff cleanup broke indexing
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 19 18:30:07 GMT 2005
>Closed-Date:    Fri Sep 23 12:56:00 GMT 2005
>Last-Modified:  Fri Sep 23 12:56:00 GMT 2005
>Originator:     Matej Vela
>Release:        FreeBSD-CURRENT
>Organization:
Debian
>Environment:
N/A

>Description:
In revision 1.2 of src/usr.bin/vgrind/tmac.vgrind, the following change
was made to eliminate warnings from groff(1):

--- src/usr.bin/vgrind/tmac.vgrind	1994/05/27 12:33:20	1.1
+++ src/usr.bin/vgrind/tmac.vgrind	2000/11/29 10:32:51	1.2
@@ -54,11 +58,9 @@
 ..
 'de FN
 \f2\s14\h'\\n(.lu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
-.if \\nx .tm \\$1 \\*(=F \\n%
 'ds =f \&...\\$1
 ..
 'de FC
-.if \\nx .tm \\$1 \\*(=F \\n%
 'ds =f \&...\\$1
 ..
 'de -F

What the two removed lines say in their wonderfully concise way is, if
the numeric register `x' is non-zero [1], output the function name [2],
the name of the current file [3], and the current page number [4] to the
index file [5] for a second pass by `vgrind -x'.

[1] I.e. if vgrind.sh invoked groff(1) with `-rx1' to enable indexing.
[2] `\$1', the first argument to FN and FC.
[3] Variable `=F', defined by vfontedpr.c:271.
[4] Register `%', maintained by groff(1) itself.
[5] Or to be precise, to standard error, which vgrind.sh redirects to
    the index file.

The reason they were removed is that they cause `register not defined'
warnings if vgrind.sh doesn't supply `-rx1'.  However, removing them
completely breaks indexing.

>How-To-Repeat:
$ cd src/usr.bin/vgrind
$ > index
$ vgrind -p groff vgrindefs.c > source.ps
$ file index
index: empty

The correct behavior looks like this:

$ > index
$ vgrind -p groff vgrindefs.c > source.ps
$ cat index
tdecode vgrindefs.c 5
tgetent vgrindefs.c 2
tgetflag vgrindefs.c 4
tgetnum vgrindefs.c 4
tgetstr vgrindefs.c 5
tnamatch vgrindefs.c 3
tnchktc vgrindefs.c 3
tskip vgrindefs.c 4
$ vgrind -p groff -x index > index.ps

>Fix:
Fix the groff(1) warnings without removing the offending lines, by making
sure `\nx' and `\*(=F' are used only when defined (`if r x', `if d =F'):

--- src/usr.bin/vgrind/tmac.vgrind.orig
+++ src/usr.bin/vgrind/tmac.vgrind
@@ -58,9 +58,11 @@
 ..
 'de FN
 \f2\s14\h'\\n(.lu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
+.if r x .if \\nx .if d =F .tm \\$1 \\*(=F \\n%
 'ds =f \&...\\$1
 ..
 'de FC
+.if r x .if \\nx .if d =F .tm \\$1 \\*(=F \\n%
 'ds =f \&...\\$1
 ..
 'de -F
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Fri Sep 23 12:55:40 GMT 2005 
State-Changed-Why:  
Applied, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=86343 
>Unformatted:
