xref: /original-bsd/usr.bin/ex/makeoptions (revision 3705696b)
1#!/bin/csh -f
2#
3# Copyright (c) 1991, 1993
4#	The Regents of the University of California.  All rights reserved.
5#
6# %sccs.include.proprietary.sh%
7#
8#	@(#)makeoptions	8.1 (Berkeley) 06/09/93
9#
10
11# remake options -- this isn't necessary unless you add/delete options
12#
13set TMP1=/tmp/_vi_vars1
14set TMP2=/tmp/_vi_vars2
15onintr ifintr
16
17cat < $argv[1] > $TMP1
18ex - $TMP1 <<'%'
19	g/^#include/d
20	w
21	q
22'%'
23shift
24cpp $* $TMP1 > $TMP2
25ex - $TMP2 <<'X'
26	" delete all preprocessor output (# line, etc)
27	g/^# /d
28	set sh=/bin/csh
29	" delete junk (all but data lines)
30	g/^[ 	]*$/d
31	1,/option options/d
32	/}/-1,$d
33	" get rid of all of line but option name
34	1,$s/[ 	]*"//
35	1,$s/".*//
36	" begin kludge since options start at 0 but cat -n starts at 1
37	"              move first to end and later move it back and renumber
38	1m$
39	%!cat -n
40	$t0
41	1s/[0-9][0-9]*/0/
42	" end kludge
43	" make #define lines
44	1,$s/[ 	]*\([0-9][0-9]*\)[ 	]*\(.*\)/#define	\U\2\L	\1/
45	" filter through expand to make it line up nice
46	%!expand -8\,24
47	" blank line and number of options.
48	$i
49
50.
51	$s/e[ 	].*[ 	]/e	NOPTS	/
52	0a
53	/*  sccs id   @(#)  ex_vars.h  @(#)makeoptions	8.1 06/09/93  */
54.
55	w! ex_vars.h
56	q
57'X'
58ifintr:
59rm $TMP1 $TMP2
60