#!/usr/bin/env perl
# $Id; patchglyphnames.pl $
#
# Author: Tomi Ollila -- too ät iki piste fi
#
#	Copyright (c) 2007 Tomi Ollila
#	    All rights reserved
#
# Created: Wed Nov 07 21:23:08 EET 2007 too
# Last modified: Mon Nov 19 19:26:01 EET 2007 too

use strict;
use warnings;

use charnames ':full';

while (<>)
{
    if (/^STARTCHAR/)
    {
	my @lines = $_;
	while (<>)
	{
	    push @lines, $_;
	    last if /ENDCHAR/;
	    if (/^ENCODING\s+(\d+)/)
	    {
		my $s = charnames::viacode($1);
		$lines[0] = sprintf("STARTCHAR U+%04X %s\n", $1, lc($s))
		  if defined $s;

	    }
	}
	print @lines;
    }
    else { print $_; }

}

