xref: /original-bsd/usr.bin/vgrind/vgrind.sh (revision 6c57d260)
1#
2# vgrind
3#
4set b=/usr/lib
5set voptions=
6set options=
7set files=
8set f=''
9set head=""
10top:
11if ($#argv > 0) then
12    switch ($1:q)
13
14    case -f:
15	set f='filter'
16	set options = "$options $1:q"
17	shift
18	goto top
19
20    case -t:
21	set voptions = "$voptions -t"
22	shift
23	goto top
24
25    case -o*:
26	set voptions="$voptions $1:q"
27	shift
28	goto top
29
30    case -W:
31	set voptions = "$voptions -W"
32	shift
33	goto top
34
35    case -d:
36	if ($#argv < 2) then
37	    echo "vgrind: $1:q option must have argument"
38	    goto done
39	else
40	    set options = ($options $1:q $2)
41	    shift
42	    shift
43	    goto top
44	endif
45
46    case -h:
47	if ($#argv < 2) then
48	    echo "vgrind: $1:q option must have argument"
49	    goto done
50	else
51	    set head="$2"
52	    shift
53	    shift
54	    goto top
55	endif
56
57    case -*:
58	set options = "$options $1:q"
59	shift
60	goto top
61
62    default:
63	set files = "$files $1:q"
64	shift
65	goto top
66    endsw
67endif
68if (-r index) then
69    echo > nindex
70    foreach i ($files)
71	echo "/ $i /d" >> nindex
72    end
73    sed -f nindex index >xindex
74    if ($f == 'filter') then
75	if ("$head" != "") then
76	    $b/vfontedpr $options -h "$head" $files | cat $b/tmac/tmac.vgrind -
77	else
78	    $b/vfontedpr $options $files | cat $b/tmac/tmac.vgrind -
79	endif
80    else
81	if ("$head" != "") then
82	    $b/vfontedpr $options -h "$head" $files | \
83		/bin/sh -c "vtroff -rx1 $voptions -i -mvgrind 2>> xindex"
84	else
85	    $b/vfontedpr $options $files | \
86		/bin/sh -c "vtroff -rx1 $voptions -i -mvgrind 2>> xindex"
87	endif
88    endif
89    sort -df +0 -2 xindex >index
90    rm nindex xindex
91else
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		| vtroff -i $voptions -mvgrind
102	else
103	    $b/vfontedpr $options $files \
104		| vtroff -i $voptions -mvgrind
105	endif
106    endif
107endif
108
109done:
110