# -*- C -*- --- well, not actually... # $Id: config_var.awk,v 1.7 1993/11/06 23:51:22 ppessi Exp $ # # Copyright © 1993 AmiTCP/IP Group, # Helsinki University of Technology, Finland. # All rights reserved. # # Created : Wed Apr 28 21:09:22 1993 puhuri # Last modified: Thu Nov 4 07:33:09 1993 ppessi # # $Log: config_var.awk,v $ # Revision 1.7 1993/11/06 23:51:22 ppessi # Added `global' definitions, allowing to export second level strings. # # Revision 1.6 1993/06/04 11:16:15 jraja # Fixes for first public release. # # Revision 1.5 1993/05/04 13:44:00 ppessi # Fixed Aliasing, removed level 0 \begin{description} \end{description} # # Revision 1.4 93/05/03 13:46:42 13:46:42 puhuri (Markus Peuhkuri) # Modified to use \Alias(es) command. # # Revision 1.3 93/04/29 22:05:16 22:05:16 puhuri (Markus Peuhkuri) # Now gawk supouse substitute FILENAME # # Revision 1.2 93/04/29 08:55:05 08:55:05 puhuri (Markus Peuhkuri) # Changed field seperator to ; surrounded by zero or more spaces or tabs. # # Revision 1.1 93/04/28 21:55:56 21:55:56 ppessi (Pekka Pessi) # Initial revision # BEGIN { FS="[\t ]*;[\t ]*"; level=1; tab=""; vars=""; var2=""; GFN = "kern/variables.src (" FILENAME ")"; if (TARGETTI == "TEX") { TEXTARGET = 1; CTARGET = 0; startcomment = "% -*- LaTeX -*-"; comment = "%"; endcomment = "%"; } else if (TARGETTI == "C") { CTARGET = 1; TEXTARGET = 0; startcomment = "/* -*- C -*-"; comment = " *"; endcomment = " */"; } print startcomment; printf "%s This file is automatically generated from %s\n", comment, GFN; print comment; printf "%s Do not change this file\n", comment; print endcomment; if (CTARGET) { print ""; print "\#include "; print "\#include "; print "\#include "; print "\#include "; print "\#include "; print ""; } } # skip comments and empty lines /^#/ { next } /^ *$/ { next } # Collect global variables /^global/ { gsub("^global ", ""); globals = globals "\n" $0; next; } # Change _ to \_ in TeX TEXTARGET && /_/ { gsub("_","\\_") } # Generate indentation, add environment parenthesis level != $2 && TEXTARGET { if (level < $2) for(i=level; i < $2; i++) { tab = sprintf("%"2*i"s", ""); print tab "\\begin{description}"; } else for(i=level; i > $2; i--) { tab = sprintf("% "2*i "s", ""); print tab "\\end{description}"; } level = $2; tab = sprintf("%" 2*level "s", ""); print ""; } TEXTARGET { n = split($1,temp,"="); printf "%s\\item[\\code{%s}] %s\n",tab,temp[n],$3; if(n>1) { printf tab " \\Alias%s{%s",(n>2)?"es":"",temp[1]; for(i=2;i 60) { printf "\" \\\n \""; cnt=0; } cnt += length(t2[i]); printf "%s,",t2[i]; } if (length(t2[n2]) + cnt > 60) printf "\" \\\n \""; printf "%s\"\n\n", t2[n2]; } curvar=temp[n]; varcom=$3; if (length(vars) > 0) { vars=vars "," $1; } else { vars=$1; } var2 = ""; # Get external vars getline extern; externs = externs "\n" extern; # get variables line getline varline; if (length(varlines) > 0) { varlines = varlines ",\n" varline; } else { varlines = varline; } } else { if(length(var2) == 0) { var2=$1; } else { var2 = var2 "," $1; } } } END { if (TEXTARGET) { for(i = level; i > 1; i--) print "\\end{description}"; } else { if (length(var2) > 0) { printf "/* %s */\n#define KW_%s \\\n \"", varcom, curvar; n2 = split(var2, t2, ","); cnt = 0; for(i=1;i60) { printf "\" \\\n \""; cnt=0; } cnt += length(t2[i]); printf "%s,",t2[i]; } if (length(t2[n2])+cnt> 60) printf "\" \\\n \""; printf "%s\"\n\n", t2[n2]; } if (length(vars) > 0) { printf "/* %s */\nSTRPTR KW_%s =\n \"", "Level 1 variables", "VARS"; n2 = split(vars, t2, ","); cnt=0; for(i=1; i 60) { printf "\"\n \""; cnt=0; } cnt+=length(t2[i]); printf "%s,",t2[i]; } printf "%s\";\n\n", t2[n2]; } if (length(externs)) { print "/* extern declarations */"; print externs; print; } if (length(globals)) { printf "/* Global variables */"; print globals; print; } if (length(varlines)) { print "struct cfg_variable variables[] = {"; print varlines; print "};"; } } }