diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 | 
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 | 
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /unicode/mkhtmlent.pl | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'unicode/mkhtmlent.pl')
| -rw-r--r-- | unicode/mkhtmlent.pl | 69 | 
1 files changed, 69 insertions, 0 deletions
| diff --git a/unicode/mkhtmlent.pl b/unicode/mkhtmlent.pl new file mode 100644 index 0000000..7120ac7 --- /dev/null +++ b/unicode/mkhtmlent.pl @@ -0,0 +1,69 @@ +#! /usr/bin/perl +# +# Compile list of HTML 4.0/XHTML entities. + +my %ent=("amp" => 38, "lt" => 60, "gt" => 62); + +foreach ("xhtml-lat1.ent", "xhtml-special.ent", "xhtml-symbol.ent") +{ +    open(F, "<$_") or die "$_: $!\n"; + +    my $l; + +    while (defined($l=<F>)) +    { +	chomp $l; +	next unless $l =~ m/^<!ENTITY\s+([^\s]+)\s+"&#(\d+);">/; + +	$ent{$1}=$2; +    } +} + +print "static const char n[]={\n"; + +my $prev="\t"; + +foreach (sort keys %ent) +{ +    my $n=$_; + +    my $str=""; + +    print $prev; +    $prev=""; + +    foreach (0..length($n)-1) +    { +	$str .= $prev . ord(substr($n, $_, 1)); +	$prev=", "; +    } + +    print $str; + +    $prev=","; + +    $prev .= (" " x (40 - length($str))) +	if (length($str) < 40); + +    $prev .= " /* $n */\n\t"; +} + +substr($prev, 0, 1)=" "; + +$prev =~ s/\t//; + +print "$prev};\n\nstatic const struct i ii[]={"; + +$prev="\n\t"; + +my $n=0; + +foreach (sort keys %ent) +{ +    print $prev . "{$n, " . length($_) . ", $ent{$_}" . "}"; + +    $n += length($_); +    $prev=",\n\t"; +} + +print "\n};\n"; | 
