makelist revision 1.1
11.1Scgd#!/bin/sh - 21.1Scgd# 31.1Scgd# Copyright (c) 1992, 1993 41.1Scgd# The Regents of the University of California. All rights reserved. 51.1Scgd# 61.1Scgd# This code is derived from software contributed to Berkeley by 71.1Scgd# Christos Zoulas of Cornell University. 81.1Scgd# 91.1Scgd# Redistribution and use in source and binary forms, with or without 101.1Scgd# modification, are permitted provided that the following conditions 111.1Scgd# are met: 121.1Scgd# 1. Redistributions of source code must retain the above copyright 131.1Scgd# notice, this list of conditions and the following disclaimer. 141.1Scgd# 2. Redistributions in binary form must reproduce the above copyright 151.1Scgd# notice, this list of conditions and the following disclaimer in the 161.1Scgd# documentation and/or other materials provided with the distribution. 171.1Scgd# 3. All advertising materials mentioning features or use of this software 181.1Scgd# must display the following acknowledgement: 191.1Scgd# This product includes software developed by the University of 201.1Scgd# California, Berkeley and its contributors. 211.1Scgd# 4. Neither the name of the University nor the names of its contributors 221.1Scgd# may be used to endorse or promote products derived from this software 231.1Scgd# without specific prior written permission. 241.1Scgd# 251.1Scgd# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 261.1Scgd# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271.1Scgd# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281.1Scgd# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 291.1Scgd# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301.1Scgd# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311.1Scgd# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321.1Scgd# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 331.1Scgd# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 341.1Scgd# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 351.1Scgd# SUCH DAMAGE. 361.1Scgd# 371.1Scgd# @(#)makelist 5.3 (Berkeley) 6/4/93 381.1Scgd 391.1Scgd# makelist.sh: Automatically generate header files... 401.1Scgd 411.1ScgdAWK=/usr/bin/awk 421.1ScgdUSAGE="Usage: $0 -h|-e|-fc|-fh|-bc|-bh <filenames>" 431.1Scgd 441.1Scgdif [ "x$1" = "x" ] 451.1Scgdthen 461.1Scgd echo $USAGE 1>&2 471.1Scgd exit 1 481.1Scgdfi 491.1Scgd 501.1ScgdFLAG="$1" 511.1Scgdshift 521.1Scgd 531.1ScgdFILES="$@" 541.1Scgd 551.1Scgdcase $FLAG in 561.1Scgd-h) 571.1Scgd OIFS="$IFS" 581.1Scgd IFS=".$IFS" 591.1Scgd set - $FILES 601.1Scgd IFS="$OIFS" 611.1Scgd hdr="_h_`basename $1`_$2" 621.1Scgd cat $FILES | $AWK ' 631.1Scgd BEGIN { 641.1Scgd printf("/* Automatically generated file, do not edit */\n"); 651.1Scgd printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'"); 661.1Scgd } 671.1Scgd /\(\):/ { 681.1Scgd pr = substr($2, 1, 2); 691.1Scgd if (pr == "vi" || pr == "em" || pr == "ed") { 701.1Scgd name = substr($2, 1, length($2) - 3); 711.1Scgd printf("protected el_action_t\t%-25.25s __P((EditLine *, int));\n", name); 721.1Scgd } 731.1Scgd } 741.1Scgd END { 751.1Scgd printf("#endif /* %s */\n", "'$hdr'"); 761.1Scgd }';; 771.1Scgd-bc) 781.1Scgd cat $FILES | $AWK ' 791.1Scgd BEGIN { 801.1Scgd printf("/* Automatically generated file, do not edit */\n"); 811.1Scgd printf("#include \"sys.h\"\n#include \"el.h\"\n"); 821.1Scgd printf("private struct el_bindings_t el_func_help[] = {\n"); 831.1Scgd low = "abcdefghijklmnopqrstuvwxyz_"; 841.1Scgd high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 851.1Scgd for (i = 1; i <= length(low); i++) 861.1Scgd tr[substr(low, i, 1)] = substr(high, i, 1); 871.1Scgd } 881.1Scgd /\(\):/ { 891.1Scgd pr = substr($2, 1, 2); 901.1Scgd if (pr == "vi" || pr == "em" || pr == "ed") { 911.1Scgd name = substr($2, 1, length($2) - 3); 921.1Scgd uname = ""; 931.1Scgd fname = ""; 941.1Scgd for (i = 1; i <= length(name); i++) { 951.1Scgd s = substr(name, i, 1); 961.1Scgd uname = uname tr[s]; 971.1Scgd if (s == "_") 981.1Scgd s = "-"; 991.1Scgd fname = fname s; 1001.1Scgd } 1011.1Scgd 1021.1Scgd printf(" { %-30.30s %-30.30s\n","\"" fname "\",", uname ","); 1031.1Scgd ok = 1; 1041.1Scgd } 1051.1Scgd } 1061.1Scgd /^ \*/ { 1071.1Scgd if (ok) { 1081.1Scgd printf(" \""); 1091.1Scgd for (i = 2; i < NF; i++) 1101.1Scgd printf("%s ", $i); 1111.1Scgd printf("%s\" },\n", $i); 1121.1Scgd ok = 0; 1131.1Scgd } 1141.1Scgd } 1151.1Scgd END { 1161.1Scgd printf(" { NULL, 0, NULL }\n"); 1171.1Scgd printf("};\n"); 1181.1Scgd printf("\nprotected el_bindings_t* help__get()"); 1191.1Scgd printf("{ return el_func_help; }\n"); 1201.1Scgd }';; 1211.1Scgd-bh) 1221.1Scgd $AWK ' 1231.1Scgd BEGIN { 1241.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1251.1Scgd printf("#ifndef _h_help_c\n#define _h_help_c\n"); 1261.1Scgd printf("protected el_bindings_t *help__get\t__P((void));\n"); 1271.1Scgd printf("#endif /* _h_help_c */\n"); 1281.1Scgd }' /dev/null;; 1291.1Scgd-fh) 1301.1Scgd cat $FILES | $AWK '/el_action_t/ { print $3 }' | \ 1311.1Scgd sort | tr '[a-z]' '[A-Z]' | $AWK ' 1321.1Scgd BEGIN { 1331.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1341.1Scgd printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n"); 1351.1Scgd count = 0; 1361.1Scgd } 1371.1Scgd { 1381.1Scgd printf("#define\t%-30.30s\t%3d\n", $1, count++); 1391.1Scgd } 1401.1Scgd END { 1411.1Scgd printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count); 1421.1Scgd 1431.1Scgd printf("typedef el_action_t (*el_func_t) __P((EditLine *, int));"); 1441.1Scgd printf("\nprotected el_func_t* func__get __P((void));\n"); 1451.1Scgd printf("#endif /* _h_fcns_c */\n"); 1461.1Scgd }';; 1471.1Scgd-fc) 1481.1Scgd cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK ' 1491.1Scgd BEGIN { 1501.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1511.1Scgd printf("#include \"sys.h\"\n#include \"el.h\"\n"); 1521.1Scgd printf("private el_func_t el_func[] = {"); 1531.1Scgd maxlen = 80; 1541.1Scgd needn = 1; 1551.1Scgd len = 0; 1561.1Scgd } 1571.1Scgd { 1581.1Scgd clen = 25 + 2; 1591.1Scgd len += clen; 1601.1Scgd if (len >= maxlen) 1611.1Scgd needn = 1; 1621.1Scgd if (needn) { 1631.1Scgd printf("\n "); 1641.1Scgd needn = 0; 1651.1Scgd len = 4 + clen; 1661.1Scgd } 1671.1Scgd s = $1 ","; 1681.1Scgd printf("%-26.26s ", s); 1691.1Scgd } 1701.1Scgd END { 1711.1Scgd printf("\n};\n"); 1721.1Scgd printf("\nprotected el_func_t* func__get() { return el_func; }\n"); 1731.1Scgd }';; 1741.1Scgd-e) 1751.1Scgd echo "$FILES" | tr ' ' '\012' | $AWK ' 1761.1Scgd BEGIN { 1771.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1781.1Scgd printf("#define protected static\n"); 1791.1Scgd printf("#define SCCSID\n"); 1801.1Scgd } 1811.1Scgd { 1821.1Scgd printf("#include \"%s\"\n", $1); 1831.1Scgd }';; 1841.1Scgd*) 1851.1Scgd echo $USAGE 1>&2 1861.1Scgd exit 1;; 1871.1Scgdesac 188