From dac8a4dd167210b17ef6cd727ebd3a6db0cde738 Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Sat, 21 Dec 2002 15:38:14 +0000 Subject: [PATCH] Auto-generation of tag names. --- gedcom/process_tags | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 gedcom/process_tags diff --git a/gedcom/process_tags b/gedcom/process_tags new file mode 100755 index 0000000..41dc74b --- /dev/null +++ b/gedcom/process_tags @@ -0,0 +1,46 @@ +# $Id$ +# $Name$ + +use strict; +use diagnostics; + +my $inputfile = "$ENV{srcdir}/gedcom.tabgen.h"; +my $outputfile = "$ENV{srcdir}/tag_names.h"; + +my %tags; +my ($min, $max) = (9999, 0); + +open INPUT, $inputfile or die "Can't read $inputfile\n"; +open OUTPUT, ">$outputfile" or die "Can't write $outputfile\n"; + +while () +{ + if (/TAG_(.*?)\s+(\d+)/) { + my ($name, $num) = ($1, $2); + $tags{$num} = $name; + $min = $num if $num < $min; + $max = $num if $num > $max; + } +} + +print OUTPUT "/* This file is automatically generated */\n"; +print OUTPUT "\n"; +print OUTPUT "#define TAG_NUM_START $min\n"; +print OUTPUT "#define TAG_NUM_END $max\n"; +print OUTPUT "\n"; +print OUTPUT "char* tag_name[] =\n"; +print OUTPUT "{"; + +foreach my $tagnum (sort keys %tags) { + if (($tagnum - $min) % 8 == 0) { + print OUTPUT "\n"; + print OUTPUT " /* $tagnum */ "; + } + print OUTPUT "\"$tags{$tagnum}\", "; +} + +print OUTPUT "\n};\n"; + +close OUTPUT; +close INPUT; + -- 2.30.2