#+++ # title: Mkselinc.awk # abstract: Generate include file for use with SELECTABLE chartables. # author: T.R.Hageman, Groningen, The Netherlands. # created: november 1993 # modified: (see Log at end) # description: # # usage: awk -f Mkselinc.awk [BASE=] [DIR=] # # This script takes as input a list of difftable filenames, # to be included in the selectable chartable include file. # # The header file is meant to be included twice: # - once with macro `Entry' UNdefined to include the difftables, # - once with `Entry' defined, to generate the entries in an # administration table. # # The prefix DIR is stripped from the difftable filenames, if defined. # # A unique tag is derived from the difftable filenames, # by stripping the BASE prefix and the extension. This tag is # appended to the difftable identifiers to uniquize them. # # bugs: # This script aint the pillar of robustness... #--- BEGIN { split("$Id: Mkselinc.awk,v 1.1 1993/11/06 00:46:20 tom Exp tom $", Id) if (i = index(Id[2], ",")) ScriptName = substr(Id[2], 1, i - 1) else if ((ScriptName = Id[2]) == "") ScriptName = "Mkselinc.awk" print "/* This file is generated by the awk script \"" \ ScriptName "\" (" Id[3] " " Id[4] ") */" print "" print "/* Generate really const difftables. */" print "#undef Const" print "#define Const const" print "" print "/* Indirect preprocessor token catenation. */" print "#ifndef CAT_INDIR" print "# define CAT_INDIR(a,b) _ANSI_CAT_(a,b)" print "#endif" print "#ifndef ID" print "# define ID(name) CAT_INDIR(name, Id)" print "#endif" } # Expect line(s) with file names of the form ${DIR}${BASE}tag.dt { for (i = 1; i <= NF; i++) { if (DIR != "" && index($i, DIR) == 1) $i = substr($i, length(DIR) + 1) if (b = index($i, BASE)) t = length(BASE) + b else t = 1 tag = substr($i, t, index($i, ".") - t) print "" print "#define Id " tag print "#ifndef Entry" print "# include \"" $i "\"" print "#else" print " Entry(" tag ")," print "#endif" print "#undef Id" } } #====================================================================== # $Log: Mkselinc.awk,v $ # Revision 1.1 1993/11/06 00:46:20 tom # Initial revision # #======================================================================