xref: /csrg-svn/usr.bin/ex/makeoptions (revision 535)
1465Smark#
2465Smark# remake options -- this isn't necessary unless you add/delete options
3465Smark#
4*535Smarkonintr ifintr
5*535Smarkcp ex_data.c /tmp/$$.c
6*535Smarkex - /tmp/$$.c <<'%'
7*535Smark	g/^#include/d
8*535Smark	w
9*535Smark	q
10465Smark'%'
11*535Smarkcc -E $* /tmp/$$.c >/tmp/foo.c
12*535Smarkex - /tmp/foo.c <<'X'
13*535Smark	" delete all preprocessor output (# line, etc)
14*535Smark	g/^# /d
15*535Smark	set sh=/bin/csh
16*535Smark	" delete junk (all but data lines)
17*535Smark	g/^[ 	]*$/d
18*535Smark	1,/options/d
19*535Smark	/}/-1,$d
20*535Smark	" get rid of all of line but option name
21*535Smark	1,$s/	"//
22*535Smark	1,$s/".*//
23*535Smark	1m$	" kludge since options start at 0 but num at 1
24*535Smark	%!num
25*535Smark	$t0	" unkludge
26*535Smark	1s/......../     0  /	" unkludge
27*535Smark	" make #define lines
28*535Smark	1,$s/\(......\)\(.*\)/#define	\U\2\L	\1/
29*535Smark	" get rid of extra blanks, turning into (single) tabs.
30*535Smark	1,$s/	 */	/g
31*535Smark	g/  */s//	/g
32*535Smark	" filter through expand to make it line up nice
33*535Smark	%!expand -8\,24
34*535Smark	" blank line and number of options.
35*535Smark	$i
36465Smark
37465Smark.
38*535Smark	$s/e[ 	].*[ 	]/e	NOPTS	/
39*535Smark	w! ex_vars.h
40*535Smark	q
41465Smark'X'
42465Smarkifintr:
43*535Smarkrm /tmp/foo.c
44