1#!/bin/sh - 2# 3# Copyright (c) 1992 The Regents of the University of California. 4# All rights reserved. 5# 6# This code is derived from software contributed to Berkeley by 7# Christos Zoulas of Cornell University. 8# 9# %sccs.include.redist.sh% 10# 11# @(#)makelist 5.1 (Berkeley) 07/06/92 12 13# makelist.sh: Automatically generate header files... 14 15# On vangogh /usr/bin/awk is broken; christos Fri Jul 3 14:01:03 EDT 1992 16AWK=/usr/old/bin/awk 17#AWK=/usr/bin/awk 18USAGE="Usage: $0 -h|-e|-fc|-fh|-bc|-bh <filenames>" 19 20if [ "x$1" = "x" ] 21then 22 echo $USAGE 1>&2 23 exit 1 24fi 25 26FLAG="$1" 27shift 28 29FILES="$@" 30 31case $FLAG in 32-h) 33 OIFS="$IFS" 34 IFS=".$IFS" 35 set - $FILES 36 IFS="$OIFS" 37 hdr="_h_`basename $1`_$2" 38 cat $FILES | $AWK ' 39 BEGIN { 40 printf("/* Automatically generated file, do not edit */\n"); 41 printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'"); 42 } 43 /\(\):/ { 44 pr = substr($2, 1, 2); 45 if (pr == "vi" || pr == "em" || pr == "ed") { 46 name = substr($2, 1, length($2) - 3); 47 printf("protected el_action_t\t%-25.25s __P((EditLine *, int));\n", name); 48 } 49 } 50 END { 51 printf("#endif /* %s */\n", "'$hdr'"); 52 }';; 53-bc) 54 cat $FILES | $AWK ' 55 BEGIN { 56 printf("/* Automatically generated file, do not edit */\n"); 57 printf("#include \"sys.h\"\n#include \"el.h\"\n"); 58 printf("private struct el_bindings_t el_func_help[] = {\n"); 59 low = "abcdefghijklmnopqrstuvwxyz_"; 60 high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 61 for (i = 1; i <= length(low); i++) 62 tr[substr(low, i, 1)] = substr(high, i, 1); 63 } 64 /\(\):/ { 65 pr = substr($2, 1, 2); 66 if (pr == "vi" || pr == "em" || pr == "ed") { 67 name = substr($2, 1, length($2) - 3); 68 uname = ""; 69 fname = ""; 70 for (i = 1; i <= length(name); i++) { 71 s = substr(name, i, 1); 72 uname = uname tr[s]; 73 if (s == "_") 74 s = "-"; 75 fname = fname s; 76 } 77 78 printf(" { %-30.30s %-30.30s\n","\"" fname "\",", uname ","); 79 ok = 1; 80 } 81 } 82 /^ \*/ { 83 if (ok) { 84 printf(" \""); 85 for (i = 2; i < NF; i++) 86 printf("%s ", $i); 87 printf("%s\" },\n", $i); 88 ok = 0; 89 } 90 } 91 END { 92 printf(" { NULL, 0, NULL }\n"); 93 printf("};\n"); 94 printf("\nprotected el_bindings_t* help__get()"); 95 printf("{ return el_func_help; }\n"); 96 }';; 97-bh) 98 $AWK ' 99 BEGIN { 100 printf("/* Automatically generated file, do not edit */\n"); 101 printf("#ifndef _h_help_c\n#define _h_help_c\n"); 102 printf("protected el_bindings_t *help__get\t__P((void));\n"); 103 printf("#endif /* _h_help_c */\n"); 104 }' /dev/null;; 105-fh) 106 cat $FILES | $AWK '/el_action_t/ { print $3 }' | \ 107 sort | tr '[a-z]' '[A-Z]' | $AWK ' 108 BEGIN { 109 printf("/* Automatically generated file, do not edit */\n"); 110 printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n"); 111 count = 0; 112 } 113 { 114 printf("#define\t%-30.30s\t%3d\n", $1, count++); 115 } 116 END { 117 printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count); 118 119 printf("typedef el_action_t (*el_func_t) __P((EditLine *, int));"); 120 printf("\nprotected el_func_t* func__get __P((void));\n"); 121 printf("#endif /* _h_fcns_c */\n"); 122 }';; 123-fc) 124 cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK ' 125 BEGIN { 126 printf("/* Automatically generated file, do not edit */\n"); 127 printf("#include \"sys.h\"\n#include \"el.h\"\n"); 128 printf("private el_func_t el_func[] = {"); 129 maxlen = 80; 130 needn = 1; 131 len = 0; 132 } 133 { 134 clen = 25 + 2; 135 len += clen; 136 if (len >= maxlen) 137 needn = 1; 138 if (needn) { 139 printf("\n "); 140 needn = 0; 141 len = 4 + clen; 142 } 143 s = $1 ","; 144 printf("%-26.26s ", s); 145 } 146 END { 147 printf("\n};\n"); 148 printf("\nprotected el_func_t* func__get() { return el_func; }\n"); 149 }';; 150-e) 151 echo "$FILES" | tr ' ' '\012' | $AWK ' 152 BEGIN { 153 printf("/* Automatically generated file, do not edit */\n"); 154 printf("#define protected static\n"); 155 printf("#define SCCSID\n"); 156 } 157 { 158 printf("#include \"%s\"\n", $1); 159 }';; 160*) 161 echo $USAGE 1>&2 162 exit 1;; 163esac 164