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