Annotation of src/usr.bin/vgrind/vgrind.sh, Revision 1.4
1.1 deraadt 1: #!/bin/csh -f
2: #
1.4 ! millert 3: # $OpenBSD: vgrind.sh,v 1.3 1996/10/03 19:32:20 tholo 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
40: set troff = "troff"
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:
62: case -t:
63: set voptions = "$voptions -t"
64: shift
65: goto top
66:
67: case -o*:
68: set voptions="$voptions $1:q"
69: shift
70: goto top
71:
72: case -W:
73: set voptions = "$voptions -W"
74: shift
75: goto top
76:
77: case -d:
78: if ($#argv < 2) then
79: echo "vgrind: $1:q option must have argument"
80: goto done
81: else
82: set options = ($options $1:q $2)
83: shift
84: shift
85: goto top
86: endif
87:
88: case -h:
89: if ($#argv < 2) then
90: echo "vgrind: $1:q option must have argument"
91: goto done
92: else
93: set head="$2"
94: shift
95: shift
96: goto top
97: endif
98:
99: case -*:
100: set options = "$options $1:q"
101: shift
102: goto top
103:
104: default:
105: set files = "$files $1:q"
106: shift
107: goto top
108: endsw
109: endif
110: if (-r index) then
111: echo > nindex
112: foreach i ($files)
113: # make up a sed delete command for filenames
114: # being careful about slashes.
115: echo "? $i ?d" | sed -e "s:/:\\/:g" -e "s:?:/:g" >> nindex
116: end
117: sed -f nindex index >xindex
118: if ($f == 'filter') then
119: if ("$head" != "") then
120: $vf $options -h "$head" $files | cat $tm/tmac.vgrind -
121: else
122: $vf $options $files | cat $tm/tmac.vgrind -
123: endif
124: else
125: if ("$head" != "") then
126: $vf $options -h "$head" $files | \
1.3 tholo 127: sh -c "$troff -rx1 $voptions -i -mvgrind 2>> xindex"
1.1 deraadt 128: else
129: $vf $options $files | \
1.3 tholo 130: sh -c "$troff -rx1 $voptions -i -mvgrind 2>> xindex"
1.1 deraadt 131: endif
132: endif
133: sort -df +0 -2 xindex >index
134: rm nindex xindex
135: else
136: if ($f == 'filter') then
137: if ("$head" != "") then
138: $vf $options -h "$head" $files | cat $tm/tmac.vgrind -
139: else
140: $vf $options $files | cat $tm/tmac.vgrind -
141: endif
142: else
143: if ("$head" != "") then
1.3 tholo 144: $vf $options -h "$head" $files | $troff -i $voptions -mvgrind
1.1 deraadt 145: else
1.3 tholo 146: $vf $options $files | $troff -i $voptions -mvgrind
1.1 deraadt 147: endif
148: endif
149: endif
150:
151: done: