xref: /csrg-svn/usr.bin/ex/makeoptions (revision 21723)
1*21723Sdist#
2*21723Sdist# Copyright (c) 1980 Regents of the University of California.
3*21723Sdist# All rights reserved.  The Berkeley software License Agreement
4*21723Sdist# specifies the terms and conditions for redistribution.
5*21723Sdist#
6*21723Sdist#	@(#)makeoptions	6.4 (Berkeley) 05/31/85
7*21723Sdist#
816400Speter
9465Smark#
10465Smark# remake options -- this isn't necessary unless you add/delete options
11465Smark#
12535Smarkonintr ifintr
1316404Spetercat < ex_data.c > /tmp/$$.c
14535Smarkex - /tmp/$$.c <<'%'
15535Smark	g/^#include/d
16535Smark	w
17535Smark	q
18465Smark'%'
19535Smarkcc -E $* /tmp/$$.c >/tmp/foo.c
20535Smarkex - /tmp/foo.c <<'X'
21535Smark	" delete all preprocessor output (# line, etc)
22535Smark	g/^# /d
23535Smark	set sh=/bin/csh
24535Smark	" delete junk (all but data lines)
25535Smark	g/^[ 	]*$/d
261540Smark	1,/option options/d
27535Smark	/}/-1,$d
28535Smark	" get rid of all of line but option name
2916400Speter	1,$s/[ 	]*"//
30535Smark	1,$s/".*//
3116400Speter	" begin kludge since options start at 0 but cat -n starts at 1
3216400Speter	"              move first to end and later move it back and renumber
3316400Speter	1m$
3416400Speter	%!cat -n
3516400Speter	$t0
3616400Speter	1s/[0-9][0-9]*/0/
3716400Speter	" end kludge
38535Smark	" make #define lines
3916400Speter	1,$s/[ 	]*\([0-9][0-9]*\)[ 	]*\(.*\)/#define	\U\2\L	\1/
40535Smark	" filter through expand to make it line up nice
41535Smark	%!expand -8\,24
42535Smark	" blank line and number of options.
43535Smark	$i
44465Smark
45465Smark.
46535Smark	$s/e[ 	].*[ 	]/e	NOPTS	/
47558Smark	0a
48*21723Sdist	/*  sccs id   @(#)  ex_vars.h  @(#)makeoptions	6.4 05/31/85  */
49558Smark.
50535Smark	w! ex_vars.h
51535Smark	q
52465Smark'X'
53465Smarkifintr:
54535Smarkrm /tmp/foo.c
55