/usr/lib/perl5/XML/SAX/ExpatXS/Encoding.pm is in libxml-sax-expatxs-perl 1.32-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | # $Id: Encoding.pm,v 1.2 2004/05/15 15:56:26 cvspetr Exp $
package XML::SAX::ExpatXS::Encoding;
require 5.004;
use strict;
use vars qw(@ISA %Encoding_Table @Encoding_Path $have_File_Spec);
use XML::SAX::ExpatXS;
use Carp;
require DynaLoader;
@ISA = qw(DynaLoader);
$have_File_Spec = $INC{'File/Spec.pm'} || do 'File/Spec.pm';
%Encoding_Table = ();
if ($have_File_Spec) {
@Encoding_Path = (grep(-d $_,
map(File::Spec->catdir($_, qw(XML SAX ExpatXS Encodings)),
@INC)),
File::Spec->curdir);
}
else {
@Encoding_Path = (grep(-d $_, map($_ . '/XML/SAX/ExpatXS/Encodings', @INC)), '.');
}
sub load_encoding {
my ($file) = @_;
$file =~ s!([^/]+)$!\L$1\E!;
$file .= '.enc' unless $file =~ /\.enc$/;
unless ($file =~ m!^/!) {
foreach (@Encoding_Path) {
my $tmp = ($have_File_Spec
? File::Spec->catfile($_, $file)
: "$_/$file");
if (-e $tmp) {
$file = $tmp;
last;
}
}
}
local(*ENC);
open(ENC, $file) or croak("Couldn't open encmap $file:\n$!\n");
binmode(ENC);
my $data;
my $br = sysread(ENC, $data, -s $file);
croak("Trouble reading $file:\n$!\n")
unless defined($br);
close(ENC);
my $name = XML::SAX::ExpatXS::LoadEncoding($data, $br);
croak("$file isn't an encmap file")
unless defined($name);
$name;
} # End load_encoding
################################################################
package XML::SAX::ExpatXS::Encinfo;
sub DESTROY {
my $self = shift;
XML::SAX::ExpatXS::FreeEncoding($self);
}
################################################################
package XML::SAX::ExpatXS::ContentModel;
use overload '""' => \&asString, 'eq' => \&thiseq;
sub EMPTY () {1}
sub ANY () {2}
sub MIXED () {3}
sub NAME () {4}
sub CHOICE () {5}
sub SEQ () {6}
sub isempty {
return $_[0]->{Type} == EMPTY;
}
sub isany {
return $_[0]->{Type} == ANY;
}
sub ismixed {
return $_[0]->{Type} == MIXED;
}
sub isname {
return $_[0]->{Type} == NAME;
}
sub name {
return $_[0]->{Tag};
}
sub ischoice {
return $_[0]->{Type} == CHOICE;
}
sub isseq {
return $_[0]->{Type} == SEQ;
}
sub quant {
return $_[0]->{Quant};
}
sub children {
my $children = $_[0]->{Children};
if (defined $children) {
return @$children;
}
return undef;
}
sub asString {
my ($self) = @_;
my $ret;
if ($self->{Type} == NAME) {
$ret = $self->{Tag};
}
elsif ($self->{Type} == EMPTY) {
return "EMPTY";
}
elsif ($self->{Type} == ANY) {
return "ANY";
}
elsif ($self->{Type} == MIXED) {
$ret = '(#PCDATA';
foreach (@{$self->{Children}}) {
$ret .= '|' . $_;
}
$ret .= ')';
}
else {
my $sep = $self->{Type} == CHOICE ? '|' : ',';
$ret = '(' . join($sep, map { $_->asString } @{$self->{Children}}) . ')';
}
$ret .= $self->{Quant} if $self->{Quant};
return $ret;
}
sub thiseq {
my $self = shift;
return $self->asString eq $_[0];
}
1;
__END__
=head1 NAME
XML::SAX::ExpatXS::Encoding - Encoding support for XML::SAX::ExpatXS
=head1 DESCRIPTION
This module is derived from XML::Parser::Expat. It provides XML::SAX::ExpatXS
parser with support of not-built-in encodings.
=head1 AUTHORS
Larry Wall <F<larry@wall.org>>
and
Clark Cooper <F<coopercc@netheaven.com>> authored XML::Parser::Expat.
Petr Cimprich <F<petr@gingerall.cz>> addapted it for XML::SAX::ExpatXS.
=cut
|