1#!/bin/sh 2# $NetBSD: emacs-gen.sh,v 1.3 2008/10/19 22:10:04 apb Exp $ 3 4: ${AWK:=awk} 5: ${SED:=sed} 6 7case $# in 81) file=$1;; 9*) 10 echo "$0: Usage: $0 path-to-emacs.c" 1>&2 11 exit 1 12esac; 13 14if [ ! -r "$file" ] ;then 15 echo "$0: can't read $file" 1>&2 16 exit 1 17fi 18 19cat << E_O_F || exit 1 20/* 21 * NOTE: THIS FILE WAS GENERATED AUTOMATICALLY FROM $file 22 * 23 * DO NOT BOTHER EDITING THIS FILE 24 */ 25E_O_F 26 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; 34 } 35 { 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++; 44 } 45 }' || exit 1 46 47exit 0 48