xref: /csrg-svn/usr.bin/ex/makeoptions (revision 44353)
121723Sdist#
221723Sdist# Copyright (c) 1980 Regents of the University of California.
321723Sdist# All rights reserved.  The Berkeley software License Agreement
421723Sdist# specifies the terms and conditions for redistribution.
521723Sdist#
6*44353Sbostic#	@(#)makeoptions	6.6 (Berkeley) 06/28/90
721723Sdist#
816400Speter
9465Smark#
10465Smark# remake options -- this isn't necessary unless you add/delete options
11465Smark#
1243854Sbosticset TMP1=/tmp/_vi_vars1
1343854Sbosticset TMP2=/tmp/_vi_vars2
14535Smarkonintr ifintr
1543854Sbostic
1643854Sbosticcat < $argv[1] > $TMP1
1743854Sbosticex - $TMP1 <<'%'
18535Smark	g/^#include/d
19535Smark	w
20535Smark	q
21465Smark'%'
2243854Sbosticshift
23*44353Sbosticcpp $* $TMP1 > $TMP2
2443854Sbosticex - $TMP2 <<'X'
25535Smark	" delete all preprocessor output (# line, etc)
26535Smark	g/^# /d
27535Smark	set sh=/bin/csh
28535Smark	" delete junk (all but data lines)
29535Smark	g/^[ 	]*$/d
301540Smark	1,/option options/d
31535Smark	/}/-1,$d
32535Smark	" get rid of all of line but option name
3316400Speter	1,$s/[ 	]*"//
34535Smark	1,$s/".*//
3516400Speter	" begin kludge since options start at 0 but cat -n starts at 1
3616400Speter	"              move first to end and later move it back and renumber
3716400Speter	1m$
3816400Speter	%!cat -n
3916400Speter	$t0
4016400Speter	1s/[0-9][0-9]*/0/
4116400Speter	" end kludge
42535Smark	" make #define lines
4316400Speter	1,$s/[ 	]*\([0-9][0-9]*\)[ 	]*\(.*\)/#define	\U\2\L	\1/
44535Smark	" filter through expand to make it line up nice
45535Smark	%!expand -8\,24
46535Smark	" blank line and number of options.
47535Smark	$i
48465Smark
49465Smark.
50535Smark	$s/e[ 	].*[ 	]/e	NOPTS	/
51558Smark	0a
52*44353Sbostic	/*  sccs id   @(#)  ex_vars.h  @(#)makeoptions	6.6 06/28/90  */
53558Smark.
54535Smark	w! ex_vars.h
55535Smark	q
56465Smark'X'
57465Smarkifintr:
5843854Sbosticrm $TMP1 $TMP2
59