Expand PMF_FN_* macros.
[netbsd-mini2440.git] / bin / ksh / emacs-gen.sh
blobfc154873ebdb32ee4b1fa776d21e793d20fc289c
1 #!/bin/sh
2 # $NetBSD: emacs-gen.sh,v 1.3 2008/10/19 22:10:04 apb Exp $
4 : ${AWK:=awk}
5 : ${SED:=sed}
7 case $# in
8 1) file=$1;;
9 *)
10 echo "$0: Usage: $0 path-to-emacs.c" 1>&2
11 exit 1
12 esac;
14 if [ ! -r "$file" ] ;then
15 echo "$0: can't read $file" 1>&2
16 exit 1
19 cat << E_O_F || exit 1
21 * NOTE: THIS FILE WAS GENERATED AUTOMATICALLY FROM $file
23 * DO NOT BOTHER EDITING THIS FILE
25 E_O_F
27 # Pass 1: print out lines before @START-FUNC-TAB@
28 # and generate defines and function declarations,
29 ${SED} -e '1,/@START-FUNC-TAB@/d' -e '/@END-FUNC-TAB@/,$d' < $file |
30 ${AWK} 'BEGIN { nfunc = 0; }
31 /^[ ]*#/ {
32 print $0;
33 next;
36 fname = $2;
37 c = substr(fname, length(fname), 1);
38 if (c == ",")
39 fname = substr(fname, 1, length(fname) - 1);
40 if (fname != "0") {
41 printf "#define XFUNC_%s %d\n", substr(fname, 3, length(fname) - 2), nfunc;
42 printf "static int %s ARGS((int c));\n", fname;
43 nfunc++;
45 }' || exit 1
47 exit 0