xref: /csrg-svn/usr.bin/ex/makeoptions (revision 63055)
148258Sbostic#!/bin/csh -f
221723Sdist#
3*63055Sbostic# Copyright (c) 1991, 1993
4*63055Sbostic#	The Regents of the University of California.  All rights reserved.
521723Sdist#
648258Sbostic# %sccs.include.proprietary.sh%
721723Sdist#
8*63055Sbostic#	@(#)makeoptions	8.1 (Berkeley) 06/09/93
948258Sbostic#
1016400Speter
11465Smark# remake options -- this isn't necessary unless you add/delete options
12465Smark#
1343854Sbosticset TMP1=/tmp/_vi_vars1
1443854Sbosticset TMP2=/tmp/_vi_vars2
15535Smarkonintr ifintr
1643854Sbostic
1743854Sbosticcat < $argv[1] > $TMP1
1843854Sbosticex - $TMP1 <<'%'
19535Smark	g/^#include/d
20535Smark	w
21535Smark	q
22465Smark'%'
2343854Sbosticshift
2444353Sbosticcpp $* $TMP1 > $TMP2
2543854Sbosticex - $TMP2 <<'X'
26535Smark	" delete all preprocessor output (# line, etc)
27535Smark	g/^# /d
28535Smark	set sh=/bin/csh
29535Smark	" delete junk (all but data lines)
30535Smark	g/^[ 	]*$/d
311540Smark	1,/option options/d
32535Smark	/}/-1,$d
33535Smark	" get rid of all of line but option name
3416400Speter	1,$s/[ 	]*"//
35535Smark	1,$s/".*//
3616400Speter	" begin kludge since options start at 0 but cat -n starts at 1
3716400Speter	"              move first to end and later move it back and renumber
3816400Speter	1m$
3916400Speter	%!cat -n
4016400Speter	$t0
4116400Speter	1s/[0-9][0-9]*/0/
4216400Speter	" end kludge
43535Smark	" make #define lines
4416400Speter	1,$s/[ 	]*\([0-9][0-9]*\)[ 	]*\(.*\)/#define	\U\2\L	\1/
45535Smark	" filter through expand to make it line up nice
46535Smark	%!expand -8\,24
47535Smark	" blank line and number of options.
48535Smark	$i
49465Smark
50465Smark.
51535Smark	$s/e[ 	].*[ 	]/e	NOPTS	/
52558Smark	0a
53*63055Sbostic	/*  sccs id   @(#)  ex_vars.h  @(#)makeoptions	8.1 06/09/93  */
54558Smark.
55535Smark	w! ex_vars.h
56535Smark	q
57465Smark'X'
58465Smarkifintr:
5943854Sbosticrm $TMP1 $TMP2
60