#!/usr/bin/awk -f # # Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. BEGIN{ printf("FIELD DESCRIPTION\n"); printf("SEGMENT:FIELD:NAME:DESCRIPTION\n"); printf("sym:num:str:str\n"); HOT = 0; } # Print error message and abort # function error(msg, obj) { printf("e:%s,%d at `%s': %s\n", FILENAME, FNR, obj, msg) > "/dev/stderr" ; ERROR=1 ; exit 3 ; } function warning(msg, obj) { printf("w:%s,%d at `%s': %s\n", FILENAME, FNR, obj, msg) > "/dev/stderr" ; } $0~"^FIELD NOTES: ... " { if (HOT) warning("lost end of last segment",$0); #initialize for reading of the new segment SEGID=tolower($3); HOT=1; next; } # A new section is the end of the description # HOT && $0~"^[1-9]+\\.[1-9]+\\." { HOT=0 ; next; } HOT && $1~"^[1-9]+.$" && $2~"^[0-9][0-9][0-9][0-9][0-9]$" { gsub("Ä","",$0); gsub("\"","'",$0); if(gsub(":","",$0)) warning("a kolon was killed",":"); name=$3; for(i=4; $i~"^[A-Z/#]+\\.?$"; i++) { name=name " " $i; if (sub("\\.$","",name)) break; } number=$1; sub("\\.$","",number); printf(SEGID ":" number ":" tolower(name) ":"); for(i++;i