xref: /csrg-svn/usr.bin/vgrind/vgrind.sh (revision 36167)
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 are permitted
7# provided that the above copyright notice and this paragraph are
8# duplicated in all such forms and that any documentation,
9# advertising materials, and other materials related to such
10# distribution and use acknowledge that the software was developed
11# by the University of California, Berkeley.  The name of the
12# University may not be used to endorse or promote products derived
13# from this software without specific prior written permission.
14# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17#
18#	@(#)vgrind.sh	5.4 (Berkeley) 10/25/88
19#
20set b=/usr/lib
21set voptions=
22set options=
23set files=
24set f=''
25set head=""
26top:
27if ($#argv > 0) then
28    switch ($1:q)
29
30    case -f:
31	set f='filter'
32	set options = "$options $1:q"
33	shift
34	goto top
35
36    case -t:
37	set voptions = "$voptions -t"
38	shift
39	goto top
40
41    case -o*:
42	set voptions="$voptions $1:q"
43	shift
44	goto top
45
46    case -W:
47	set voptions = "$voptions -W"
48	shift
49	goto top
50
51    case -d:
52	if ($#argv < 2) then
53	    echo "vgrind: $1:q option must have argument"
54	    goto done
55	else
56	    set options = ($options $1:q $2)
57	    shift
58	    shift
59	    goto top
60	endif
61
62    case -h:
63	if ($#argv < 2) then
64	    echo "vgrind: $1:q option must have argument"
65	    goto done
66	else
67	    set head="$2"
68	    shift
69	    shift
70	    goto top
71	endif
72
73    case -*:
74	set options = "$options $1:q"
75	shift
76	goto top
77
78    default:
79	set files = "$files $1:q"
80	shift
81	goto top
82    endsw
83endif
84if (-r index) then
85    echo > nindex
86    foreach i ($files)
87	#	make up a sed delete command for filenames
88	#	being careful about slashes.
89	echo "? $i ?d" | sed -e "s:/:\\/:g" -e "s:?:/:g" >> nindex
90    end
91    sed -f nindex index >xindex
92    if ($f == 'filter') then
93	if ("$head" != "") then
94	    $b/vfontedpr $options -h "$head" $files | cat $b/tmac/tmac.vgrind -
95	else
96	    $b/vfontedpr $options $files | cat $b/tmac/tmac.vgrind -
97	endif
98    else
99	if ("$head" != "") then
100	    $b/vfontedpr $options -h "$head" $files | \
101		/bin/sh -c "vtroff -rx1 $voptions -i -mvgrind 2>> xindex"
102	else
103	    $b/vfontedpr $options $files | \
104		/bin/sh -c "vtroff -rx1 $voptions -i -mvgrind 2>> xindex"
105	endif
106    endif
107    sort -df +0 -2 xindex >index
108    rm nindex xindex
109else
110    if ($f == 'filter') then
111	if ("$head" != "") then
112	    $b/vfontedpr $options -h "$head" $files | cat $b/tmac/tmac.vgrind -
113	else
114	    $b/vfontedpr $options $files | cat $b/tmac/tmac.vgrind -
115	endif
116    else
117	if ("$head" != "") then
118	    $b/vfontedpr $options -h "$head" $files \
119		| vtroff -i $voptions -mvgrind
120	else
121	    $b/vfontedpr $options $files \
122		| vtroff -i $voptions -mvgrind
123	endif
124    endif
125endif
126
127done:
128