makelist revision 1.2
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.2Scgd set - `echo $FILES | sed -e 's/\\./_/g'` 581.2Scgd hdr="_h_`basename $1`" 591.1Scgd cat $FILES | $AWK ' 601.1Scgd BEGIN { 611.1Scgd printf("/* Automatically generated file, do not edit */\n"); 621.1Scgd printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'"); 631.1Scgd } 641.1Scgd /\(\):/ { 651.1Scgd pr = substr($2, 1, 2); 661.1Scgd if (pr == "vi" || pr == "em" || pr == "ed") { 671.1Scgd name = substr($2, 1, length($2) - 3); 681.1Scgd printf("protected el_action_t\t%-25.25s __P((EditLine *, int));\n", name); 691.1Scgd } 701.1Scgd } 711.1Scgd END { 721.1Scgd printf("#endif /* %s */\n", "'$hdr'"); 731.1Scgd }';; 741.1Scgd-bc) 751.1Scgd cat $FILES | $AWK ' 761.1Scgd BEGIN { 771.1Scgd printf("/* Automatically generated file, do not edit */\n"); 781.1Scgd printf("#include \"sys.h\"\n#include \"el.h\"\n"); 791.1Scgd printf("private struct el_bindings_t el_func_help[] = {\n"); 801.1Scgd low = "abcdefghijklmnopqrstuvwxyz_"; 811.1Scgd high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 821.1Scgd for (i = 1; i <= length(low); i++) 831.1Scgd tr[substr(low, i, 1)] = substr(high, i, 1); 841.1Scgd } 851.1Scgd /\(\):/ { 861.1Scgd pr = substr($2, 1, 2); 871.1Scgd if (pr == "vi" || pr == "em" || pr == "ed") { 881.1Scgd name = substr($2, 1, length($2) - 3); 891.1Scgd uname = ""; 901.1Scgd fname = ""; 911.1Scgd for (i = 1; i <= length(name); i++) { 921.1Scgd s = substr(name, i, 1); 931.1Scgd uname = uname tr[s]; 941.1Scgd if (s == "_") 951.1Scgd s = "-"; 961.1Scgd fname = fname s; 971.1Scgd } 981.1Scgd 991.1Scgd printf(" { %-30.30s %-30.30s\n","\"" fname "\",", uname ","); 1001.1Scgd ok = 1; 1011.1Scgd } 1021.1Scgd } 1031.1Scgd /^ \*/ { 1041.1Scgd if (ok) { 1051.1Scgd printf(" \""); 1061.1Scgd for (i = 2; i < NF; i++) 1071.1Scgd printf("%s ", $i); 1081.1Scgd printf("%s\" },\n", $i); 1091.1Scgd ok = 0; 1101.1Scgd } 1111.1Scgd } 1121.1Scgd END { 1131.1Scgd printf(" { NULL, 0, NULL }\n"); 1141.1Scgd printf("};\n"); 1151.1Scgd printf("\nprotected el_bindings_t* help__get()"); 1161.1Scgd printf("{ return el_func_help; }\n"); 1171.1Scgd }';; 1181.1Scgd-bh) 1191.1Scgd $AWK ' 1201.1Scgd BEGIN { 1211.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1221.1Scgd printf("#ifndef _h_help_c\n#define _h_help_c\n"); 1231.1Scgd printf("protected el_bindings_t *help__get\t__P((void));\n"); 1241.1Scgd printf("#endif /* _h_help_c */\n"); 1251.1Scgd }' /dev/null;; 1261.1Scgd-fh) 1271.1Scgd cat $FILES | $AWK '/el_action_t/ { print $3 }' | \ 1281.1Scgd sort | tr '[a-z]' '[A-Z]' | $AWK ' 1291.1Scgd BEGIN { 1301.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1311.1Scgd printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n"); 1321.1Scgd count = 0; 1331.1Scgd } 1341.1Scgd { 1351.1Scgd printf("#define\t%-30.30s\t%3d\n", $1, count++); 1361.1Scgd } 1371.1Scgd END { 1381.1Scgd printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count); 1391.1Scgd 1401.1Scgd printf("typedef el_action_t (*el_func_t) __P((EditLine *, int));"); 1411.1Scgd printf("\nprotected el_func_t* func__get __P((void));\n"); 1421.1Scgd printf("#endif /* _h_fcns_c */\n"); 1431.1Scgd }';; 1441.1Scgd-fc) 1451.1Scgd cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK ' 1461.1Scgd BEGIN { 1471.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1481.1Scgd printf("#include \"sys.h\"\n#include \"el.h\"\n"); 1491.1Scgd printf("private el_func_t el_func[] = {"); 1501.1Scgd maxlen = 80; 1511.1Scgd needn = 1; 1521.1Scgd len = 0; 1531.1Scgd } 1541.1Scgd { 1551.1Scgd clen = 25 + 2; 1561.1Scgd len += clen; 1571.1Scgd if (len >= maxlen) 1581.1Scgd needn = 1; 1591.1Scgd if (needn) { 1601.1Scgd printf("\n "); 1611.1Scgd needn = 0; 1621.1Scgd len = 4 + clen; 1631.1Scgd } 1641.1Scgd s = $1 ","; 1651.1Scgd printf("%-26.26s ", s); 1661.1Scgd } 1671.1Scgd END { 1681.1Scgd printf("\n};\n"); 1691.1Scgd printf("\nprotected el_func_t* func__get() { return el_func; }\n"); 1701.1Scgd }';; 1711.1Scgd-e) 1721.1Scgd echo "$FILES" | tr ' ' '\012' | $AWK ' 1731.1Scgd BEGIN { 1741.1Scgd printf("/* Automatically generated file, do not edit */\n"); 1751.1Scgd printf("#define protected static\n"); 1761.1Scgd printf("#define SCCSID\n"); 1771.1Scgd } 1781.1Scgd { 1791.1Scgd printf("#include \"%s\"\n", $1); 1801.1Scgd }';; 1811.1Scgd*) 1821.1Scgd echo $USAGE 1>&2 1831.1Scgd exit 1;; 1841.1Scgdesac 185