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