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