- cc -E $* /tmp/$$.c >/tmp/foo.c
- ex - /tmp/foo.c <<'X'
- g/^# /d
- set sh=/bin/csh
- g/^[ ]*$/d
- 1,/options/d
- /}/-1,$d
- 1,$s/ "//
- 1,$s/".*//
- 1m$
- w! ex_vars.h
- !rm -f %; num ex_vars.h >%
- e
- $t0
- 1s/......../ 0 /
- 1,$s/\(......\)\(.*\)/#define \U\2\L \1/
- 1,$s/ */ /g
- g/ */s// /g
- w
- !rm -f ex_vars.h; expand -8,24 % >ex_vars.h
- e! ex_vars.h
- $i
+cc -E $* /tmp/$$.c >/tmp/foo.c
+ex - /tmp/foo.c <<'X'
+ " delete all preprocessor output (# line, etc)
+ g/^# /d
+ set sh=/bin/csh
+ " delete junk (all but data lines)
+ g/^[ ]*$/d
+ 1,/options/d
+ /}/-1,$d
+ " get rid of all of line but option name
+ 1,$s/ "//
+ 1,$s/".*//
+ 1m$ " kludge since options start at 0 but num at 1
+ %!num
+ $t0 " unkludge
+ 1s/......../ 0 / " unkludge
+ " make #define lines
+ 1,$s/\(......\)\(.*\)/#define \U\2\L \1/
+ " get rid of extra blanks, turning into (single) tabs.
+ 1,$s/ */ /g
+ g/ */s// /g
+ " filter through expand to make it line up nice
+ %!expand -8\,24
+ " blank line and number of options.
+ $i