emacs-gen.sh revision 1.1
11.1Sjtc#!/bin/sh 21.1Sjtc 31.1Sjtccase $# in 41.1Sjtc1) file=$1;; 51.1Sjtc*) 61.1Sjtc echo "$0: Usage: $0 path-to-emacs.c" 1>&2 71.1Sjtc exit 1 81.1Sjtcesac; 91.1Sjtc 101.1Sjtcif [ ! -r "$file" ] ;then 111.1Sjtc echo "$0: can't read $file" 1>&2 121.1Sjtc exit 1 131.1Sjtcfi 141.1Sjtc 151.1Sjtccat << E_O_F || exit 1 161.1Sjtc/* 171.1Sjtc * NOTE: THIS FILE WAS GENERATED AUTOMATICALLY FROM $file 181.1Sjtc * 191.1Sjtc * DO NOT BOTHER EDITING THIS FILE 201.1Sjtc */ 211.1SjtcE_O_F 221.1Sjtc 231.1Sjtc# Pass 1: print out lines before @START-FUNC-TAB@ 241.1Sjtc# and generate defines and function declarations, 251.1Sjtcsed -e '1,/@START-FUNC-TAB@/d' -e '/@END-FUNC-TAB@/,$d' < $file | 261.1Sjtc awk 'BEGIN { nfunc = 0; } 271.1Sjtc /^[ ]*#/ { 281.1Sjtc print $0; 291.1Sjtc next; 301.1Sjtc } 311.1Sjtc { 321.1Sjtc fname = $2; 331.1Sjtc c = substr(fname, length(fname), 1); 341.1Sjtc if (c == ",") 351.1Sjtc fname = substr(fname, 1, length(fname) - 1); 361.1Sjtc if (fname != "0") { 371.1Sjtc printf "#define XFUNC_%s %d\n", substr(fname, 3, length(fname) - 2), nfunc; 381.1Sjtc printf "static int %s ARGS((int c));\n", fname; 391.1Sjtc nfunc++; 401.1Sjtc } 411.1Sjtc }' || exit 1 421.1Sjtc 431.1Sjtcexit 0 44