Annotation of src/usr.bin/vgrind/vgrind.sh, Revision 1.5
1.1 deraadt 1: #!/bin/csh -f
2: #
1.5 ! millert 3: # $OpenBSD: vgrind.sh,v 1.5 2008/04/11 14:07:12 millert Exp $
1.1 deraadt 4: # $NetBSD: vgrind.sh,v 1.3 1994/11/17 08:28:06 jtc Exp $
5: #
6: # Copyright (c) 1980, 1993
7: # The Regents of the University of California. All rights reserved.
8: #
9: # Redistribution and use in source and binary forms, with or without
10: # modification, are permitted provided that the following conditions
11: # are met:
12: # 1. Redistributions of source code must retain the above copyright
13: # notice, this list of conditions and the following disclaimer.
14: # 2. Redistributions in binary form must reproduce the above copyright
15: # notice, this list of conditions and the following disclaimer in the
16: # documentation and/or other materials provided with the distribution.
1.4 millert 17: # 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 18: # may be used to endorse or promote products derived from this software
19: # without specific prior written permission.
20: #
21: # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24: # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31: # SUCH DAMAGE.
32: #
33: # @(#)vgrind.sh 8.1 (Berkeley) 6/6/93
34: #
35:
1.3 tholo 36: # Allow troff to be overridden
37: if ( $?TROFF ) then
38: set troff = "$TROFF"
39: else
1.5 ! millert 40: set troff = "groff"
1.3 tholo 41: endif
42:
43: set vf=/usr/libexec/vfontedpr
44: set tm=/usr/share/tmac
45:
1.1 deraadt 46: set voptions=
47: set options=
48: set files=
49: set f=''
50: set head=""
1.3 tholo 51:
1.1 deraadt 52: top:
53: if ($#argv > 0) then
54: switch ($1:q)
55:
56: case -f:
57: set f='filter'
58: set options = "$options $1:q"
59: shift
60: goto top
61:
1.5 ! millert 62: case -T:
! 63: if ($#argv < 2) then
! 64: echo "vgrind: $1:q option must have argument"
! 65: goto done
! 66: else
! 67: set voptions = ($voptions $1:q $2)
! 68: shift
! 69: shift
! 70: goto top
! 71: endif
! 72:
1.1 deraadt 73: case -t:
1.5 ! millert 74: # ignore for backwards compatibility
1.1 deraadt 75: shift
76: goto top
77:
78: case -o*:
79: set voptions="$voptions $1:q"
80: shift
81: goto top
82:
83: case -W:
84: set voptions = "$voptions -W"
85: shift
86: goto top
87:
88: case -d:
89: if ($#argv < 2) then
90: echo "vgrind: $1:q option must have argument"
91: goto done
92: else
93: set options = ($options $1:q $2)
94: shift
95: shift
96: goto top
97: endif
98:
99: case -h:
100: if ($#argv < 2) then
101: echo "vgrind: $1:q option must have argument"
102: goto done
103: else
104: set head="$2"
105: shift
106: shift
107: goto top
108: endif
109:
110: case -*:
111: set options = "$options $1:q"
112: shift
113: goto top
114:
115: default:
116: set files = "$files $1:q"
117: shift
118: goto top
119: endsw
120: endif
121: if (-r index) then
122: echo > nindex
123: foreach i ($files)
124: # make up a sed delete command for filenames
125: # being careful about slashes.
126: echo "? $i ?d" | sed -e "s:/:\\/:g" -e "s:?:/:g" >> nindex
127: end
128: sed -f nindex index >xindex
129: if ($f == 'filter') then
130: if ("$head" != "") then
131: $vf $options -h "$head" $files | cat $tm/tmac.vgrind -
132: else
133: $vf $options $files | cat $tm/tmac.vgrind -
134: endif
135: else
136: if ("$head" != "") then
137: $vf $options -h "$head" $files | \
1.3 tholo 138: sh -c "$troff -rx1 $voptions -i -mvgrind 2>> xindex"
1.1 deraadt 139: else
140: $vf $options $files | \
1.3 tholo 141: sh -c "$troff -rx1 $voptions -i -mvgrind 2>> xindex"
1.1 deraadt 142: endif
143: endif
144: sort -df +0 -2 xindex >index
145: rm nindex xindex
146: else
147: if ($f == 'filter') then
148: if ("$head" != "") then
149: $vf $options -h "$head" $files | cat $tm/tmac.vgrind -
150: else
151: $vf $options $files | cat $tm/tmac.vgrind -
152: endif
153: else
154: if ("$head" != "") then
1.3 tholo 155: $vf $options -h "$head" $files | $troff -i $voptions -mvgrind
1.1 deraadt 156: else
1.3 tholo 157: $vf $options $files | $troff -i $voptions -mvgrind
1.1 deraadt 158: endif
159: endif
160: endif
161:
162: done: