--- /dev/null
+# $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 (<INPUT>)
+{
+ 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;
+