etc/services - sync with NetBSD-8
[minix.git] / bin / ksh / emacs-gen.sh
blob3a2de8a7963f8637d6cac49830b70a275f4897c2
1 #!/bin/sh
2 # $NetBSD: emacs-gen.sh,v 1.4 2008/10/25 22:18:15 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