xref: /original-bsd/usr.bin/ex/makeoptions (revision 56abee86)
1#
2# remake options -- this isn't necessary unless you add/delete options
3#
4onintr ifintr
5cp ex_data.c /tmp/$$.c
6ex - /tmp/$$.c <<'%'
7	g/^#include/d
8	w
9	q
10'%'
11cc -E $* /tmp/$$.c >/tmp/foo.c
12ex - /tmp/foo.c <<'X'
13	" delete all preprocessor output (# line, etc)
14	g/^# /d
15	set sh=/bin/csh
16	" delete junk (all but data lines)
17	g/^[ 	]*$/d
18	1,/option options/d
19	/}/-1,$d
20	" get rid of all of line but option name
21	1,$s/	"//
22	1,$s/".*//
23	1m$	" kludge since options start at 0 but num at 1
24	%!num
25	$t0	" unkludge
26	1s/......../     0  /	" unkludge
27	" make #define lines
28	1,$s/\(......\)\(.*\)/#define	\U\2\L	\1/
29	" get rid of extra blanks, turning into (single) tabs.
30	1,$s/	 */	/g
31	g/  */s//	/g
32	" filter through expand to make it line up nice
33	%!expand -8\,24
34	" blank line and number of options.
35	$i
36
37.
38	$s/e[ 	].*[ 	]/e	NOPTS	/
39	0a
40	/*  sccs id   @(#)  ex_vars.h  @(#)makeoptions	6.1 10/19/80  */
41.
42	w! ex_vars.h
43	q
44'X'
45ifintr:
46rm /tmp/foo.c
47