#!/usr/bin/perl -- # -*- Perl -*-

my $firstDecl = 1;

while (<>) {
    if (/<!ENTITY/ && $firstDecl) {
	print "\n";
	print "<!ENTITY lt     '&#38;#60;'>\n";
	print "<!ENTITY gt     '&#62;'>\n";
	print "<!ENTITY amp    '&#38;#38;'>\n";
	print "<!ENTITY apos   '&#39;'>\n";
	print "<!ENTITY quot   '&#34;'>\n";
	print "<!ENTITY nbsp   '&#160;'>\n";
	print "<!ENTITY mdash  '&#38;#x2014;'>\n";
	print "<!ENTITY ldquo  '&#38;#x201C;'>\n";
	print "<!ENTITY rdquo  '&#38;#x201D;'>\n";
	print "\n";
	$firstDecl = 0;
    }

    s/(<!ENTITY % \S+ )\"\">/\1\" \">/;

    print $_;
}
