1#! /bin/sh 2 3if test -z "$AWK"; then 4 AWK=awk 5fi 6if test -z "$srcdir"; then 7 srcdir=. 8fi 9 10LC_ALL=C 11export LC_ALL 12 13rm -f term.h 14cat << EOF > term.h 15/* 16 * This file is automagically created from term.c -- DO NOT EDIT 17 */ 18 19#define T_FLG 0 20#define T_NUM 1 21#define T_STR 2 22 23struct term 24{ 25 char *tcname; 26 int type; 27}; 28 29union tcu 30{ 31 int flg; 32 int num; 33 char *str; 34}; 35 36EOF 37 38# 39# SCO-Unix sufferers may need to use the following lines: 40# perl -p < ${srcdir}/term.c \ 41# -e 's/"/"C/ if /"[A-Z]."/;' \ 42# -e 'y/[a-z]/[A-Z]/ if /"/;' \ 43# 44sed < ${srcdir}/term.c \ 45 -e '/"[A-Z]."/s/"/"C/' \ 46 -e '/"/y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ 47| $AWK ' 48/^ [{] ".*KMAPDEF[(].*$/{ 49 if (min == 0) min = s 50 max = s; 51} 52/^ [{] ".*KMAPADEF[(].*$/{ 53 if (amin == 0) amin = s 54 amax = s; 55} 56/^ [{] ".*KMAPMDEF[(].*$/{ 57 if (mmin == 0) mmin = s 58 mmax = s; 59} 60/^ [{] ".*$/{ 61a=substr($2,2,length($2)-3); 62b=substr($3,3,3); 63if (nolist == 0) { 64 printf "#define d_%s d_tcs[%d].%s\n",a,s,b 65 printf "#define D_%s (D_tcs[%d].%s)\n",a,s,b 66 } 67s++; 68} 69/\/* define/{ 70printf "#define %s %d\n",$3,s 71} 72/\/* nolist/{ 73nolist = 1; 74} 75/\/* list/{ 76nolist = 0; 77} 78END { 79 printf "\n#ifdef MAPKEYS\n" 80 printf "# define KMAPDEFSTART %d\n", min 81 printf "# define NKMAPDEF %d\n", max-min+1 82 printf "# define KMAPADEFSTART %d\n", amin 83 printf "# define NKMAPADEF %d\n", amax-amin+1 84 printf "# define KMAPMDEFSTART %d\n", mmin 85 printf "# define NKMAPMDEF %d\n", mmax-mmin+1 86 printf "#endif\n" 87} 88' | sed -e s/NUM/num/ -e s/STR/str/ -e s/FLG/flg/ \ 89>> term.h 90 91rm -f kmapdef.c 92cat << EOF > kmapdef.c 93/* 94 * This file is automagically created from term.c -- DO NOT EDIT 95 */ 96 97#include "config.h" 98 99#ifdef MAPKEYS 100 101EOF 102 103$AWK < ${srcdir}/term.c ' 104/^ [{] ".*KMAP.*$/{ 105 for (i = 0; i < 3; i++) { 106 q = $(5+i) 107 if (substr(q, 1, 5) == "KMAPD") { 108 if (min == 0) min = s 109 max = s 110 arr[s] = substr(q, 9, length(q)-9) 111 } 112 if (substr(q, 1, 5) == "KMAPA") { 113 if (amin == 0) amin = s 114 amax = s 115 anarr[s] = substr(q, 10, length(q)-10) 116 } 117 if (substr(q, 1, 5) == "KMAPM") { 118 if (mmin == 0) mmin = s 119 mmax = s 120 mnarr[s] = substr(q, 10, length(q)-10) 121 } 122 } 123} 124/^ [{] ".*$/{ 125 s++; 126} 127END { 128 printf "char *kmapdef[] = {\n" 129 for (s = min; s <= max; s++) { 130 if (arr[s]) 131 printf "%s", arr[s] 132 else 133 printf "0" 134 if (s < max) 135 printf ",\n" 136 else 137 printf "\n" 138 } 139 printf "};\n\n" 140 printf "char *kmapadef[] = {\n" 141 for (s = amin; s <= amax; s++) { 142 if (anarr[s]) 143 printf "%s", anarr[s] 144 else 145 printf "0" 146 if (s < amax) 147 printf ",\n" 148 else 149 printf "\n" 150 } 151 printf "};\n\n" 152 printf "char *kmapmdef[] = {\n" 153 for (s = mmin; s <= mmax; s++) { 154 if (mnarr[s]) 155 printf "%s", mnarr[s] 156 else 157 printf "0" 158 if (s < mmax) 159 printf ",\n" 160 else 161 printf "\n" 162 } 163 printf "};\n\n#endif\n" 164} 165' >> kmapdef.c 166 167chmod a-w kmapdef.c 168chmod a-w term.h 169 170