From e2294b61e15781ca784a611e8ca7dabe132ebc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 7 Jun 2021 14:12:11 +0200 Subject: First commit (NetBSD 9.1) --- emacs-gen.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 emacs-gen.sh (limited to 'emacs-gen.sh') diff --git a/emacs-gen.sh b/emacs-gen.sh new file mode 100755 index 0000000..3a2de8a --- /dev/null +++ b/emacs-gen.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# $NetBSD: emacs-gen.sh,v 1.4 2008/10/25 22:18:15 apb Exp $ + +: ${AWK:=awk} +: ${SED:=sed} + +case $# in +1) file=$1;; +*) + echo "$0: Usage: $0 path-to-emacs.c" 1>&2 + exit 1 +esac; + +if [ ! -r "$file" ] ;then + echo "$0: can't read $file" 1>&2 + exit 1 +fi + +cat << E_O_F || exit 1 +/* + * NOTE: THIS FILE WAS GENERATED AUTOMATICALLY FROM $file + * + * DO NOT BOTHER EDITING THIS FILE + */ +E_O_F + +# Pass 1: print out lines before @START-FUNC-TAB@ +# and generate defines and function declarations, +${SED} -e '1,/@START-FUNC-TAB@/d' -e '/@END-FUNC-TAB@/,$d' < $file | + ${AWK} 'BEGIN { nfunc = 0; } + /^[ ]*#/ { + print $0; + next; + } + { + fname = $2; + c = substr(fname, length(fname), 1); + if (c == ",") + fname = substr(fname, 1, length(fname) - 1); + if (fname != "0") { + printf "#define XFUNC_%s %d\n", substr(fname, 3, length(fname) - 2), nfunc; + printf "static int %s ARGS((int c));\n", fname; + nfunc++; + } + }' || exit 1 + +exit 0 -- cgit v1.2.3