Changeset 23895

Show
Ignore:
Timestamp:
11.04.2011 16:55:18 (8 years ago)
Author:
sjm84
Message:

Modified several Perl files to merge the locations where XML::Parser checked for the current version of perl into one location. Also tidied up several locations where a difference was specified between 5.6 and 5.8+ to do with ProtocolEncoding? being used to initialise an XML::Parser. Given the recent "

Location:
main/trunk/greenstone2/perllib
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/buildConfigxml.pm

    r22485 r23895  
    3535no strict 'subs'; 
    3636 
    37 # Wrapper that ensures the right version of XML::Parser is loaded given 
    38 # the version of Perl being used.  Need to distinguish between Perl 5.6 and 
    39 # Perl 5.8 
    40 sub BEGIN { 
    41     my $perl_dir; 
    42  
    43     # Note: $] encodes the version number of perl 
    44     if ($]>=5.010) {  
    45     $perl_dir = "perl-5.10"; 
    46     } 
    47     elsif ($]>5.008) {  
    48     # perl 5.8.1 or above 
    49     $perl_dir = "perl-5.8"; 
    50     } 
    51     elsif ($]<5.008) { 
    52     # assume perl 5.6 
    53     $perl_dir = "perl-5.6"; 
    54     } 
    55     else { 
    56     print STDERR "Warning: Perl 5.8.0 is not a maintained release.\n"; 
    57     print STDERR "         Please upgrade to a newer version of Perl.\n"; 
    58     $perl_dir = "perl-5.8"; 
    59     } 
    60  
    61     if ($ENV{'GSDLOS'} !~ /^windows$/i) { 
    62     # Use push to put this on the end, so an existing XML::Parser will be used by default 
    63     push (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/$perl_dir"); 
    64     } 
    65 } 
    66  
    67 use XML::Parser; 
     37use XMLParser; 
    6838 
    6939 
     
    9464    } 
    9565 
     66    # Removed ProtocolEncoding (see MetadataXMLPlugin for details) 
     67 
    9668    # create XML::Parser object for parsing metadata.xml files 
    97     my $parser; 
    98     if ($]<5.008) { 
    99     # Perl 5.6 
    100     $parser = new XML::Parser('Style' => 'Stream', 
    101                   'Handlers' => {'Char' => \&Char, 
     69    my $parser = new XML::Parser('Style' => 'Stream', 
     70                 'Pkg' => 'buildConfigxml', 
     71                 'Handlers' => {'Char' => \&Char, 
    10272                         'Doctype' => \&Doctype 
    10373                         }); 
    104     } 
    105     else { 
    106     # Perl 5.8 
    107     $parser = new XML::Parser('Style' => 'Stream', 
    108                   'ProtocolEncoding' => 'ISO-8859-1', 
    109                   'Handlers' => {'Char' => \&Char, 
    110                          'Doctype' => \&Doctype 
    111                          }); 
    112     } 
    11374 
    11475    if (!open (COLCFG, $filename)) { 
  • main/trunk/greenstone2/perllib/collConfigxml.pm

    r22485 r23895  
    3131no strict 'subs'; 
    3232 
    33 # Wrapper that ensures the right version of XML::Parser is loaded given 
    34 # the version of Perl being used.  Need to distinguish between Perl 5.6 and 
    35 # Perl 5.8 
    36 sub BEGIN { 
    37     my $perl_dir; 
    38  
    39     # Note: $] encodes the version number of perl 
    40     if ($]>=5.010) {  
    41     $perl_dir = "perl-5.10"; 
    42     } 
    43     elsif ($]>5.008) {  
    44     # perl 5.8.1 or above 
    45     $perl_dir = "perl-5.8"; 
    46     } 
    47     elsif ($]<5.008) { 
    48     # assume perl 5.6 
    49     $perl_dir = "perl-5.6"; 
    50     } 
    51     else { 
    52     print STDERR "Warning: Perl 5.8.0 is not a maintained release.\n"; 
    53     print STDERR "         Please upgrade to a newer version of Perl.\n"; 
    54     $perl_dir = "perl-5.8"; 
    55     } 
    56  
    57     if ($ENV{'GSDLOS'} !~ /^windows$/i) { 
    58     # Use push to put this on the end, so an existing XML::Parser will be used by default 
    59     push (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/$perl_dir"); 
    60     } 
    61 } 
    62  
    63 use XML::Parser; 
     33use XMLParser; 
    6434 
    6535# A mapping hash to resolve name discrepancy between gs2 and gs3. 
     
    12696    } 
    12797 
     98    # Removed ProtocolEncoding (see MetadataXMLPlugin for details) 
     99 
    128100    # create XML::Parser object for parsing metadata.xml files 
    129     my $parser; 
    130     if ($]<5.008) { 
    131     # Perl 5.6 
    132     $parser = new XML::Parser('Style' => 'Stream', 
    133                   'Handlers' => {'Char' => \&Char, 
     101    my $parser = new XML::Parser('Style' => 'Stream', 
     102                 'Pkg' => 'collConfigxml', 
     103                 'Handlers' => {'Char' => \&Char, 
    134104                         'Doctype' => \&Doctype 
    135105                         }); 
    136     } 
    137     else { 
    138     # Perl 5.8 
    139     $parser = new XML::Parser('Style' => 'Stream', 
    140                   'ProtocolEncoding' => 'ISO-8859-1', 
    141                   'Handlers' => {'Char' => \&Char, 
    142                          'Doctype' => \&Doctype 
    143                          }); 
    144     } 
    145  
    146106    if (!open (COLCFG, $filename)) { 
    147107    print STDERR "cfgread::read_cfg_file couldn't read the cfg file $filename\n"; 
  • main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm

    r23561 r23895  
    133133    } 
    134134     
     135    # The following used to be passed in as a parameter to XML::Parser, 
     136    # if the version of perl was greater than or equal to 5.8.  
     137    # The svn commit comment explaining the reason for adding this was 
     138    # not very clear and also said that it was quick fix and hadn't 
     139    # been tested under windows.  
     140    # More recent work has been to make strings in Perl "Unicode-aware" 
     141    # and so this line might actually be potentially harmful, however 
     142    # it is not the case that we encountered an actual error leading to 
     143    # its removal, rather it has been eliminated in an attempt to tighten 
     144    # up the code. For example, this protocol encoding is not used in 
     145    # ReadXMLFile. 
     146    # 'ProtocolEncoding' => 'ISO-8859-1', 
     147 
    135148    # create XML::Parser object for parsing metadata.xml files 
    136     my $parser; 
    137     if ($]<5.008) { 
    138     # Perl 5.6 
    139     $parser = new XML::Parser('Style' => 'Stream', 
     149    my $parser = new XML::Parser('Style' => 'Stream', 
    140150                                  'PluginObj' => $self, 
     151                                  'Pkg' => 'MetadataXMLPlugin', 
    141152                  'Handlers' => {'Char' => \&Char, 
    142153                         'Doctype' => \&Doctype 
    143154                         }); 
    144     } 
    145     else { 
    146     # Perl 5.8 or greater 
    147     $parser = new XML::Parser('Style' => 'Stream', 
    148                                   'PluginObj' => $self, 
    149                   'ProtocolEncoding' => 'ISO-8859-1', 
    150                   'Handlers' => {'Char' => \&Char, 
    151                          'Doctype' => \&Doctype 
    152                          }); 
    153     } 
    154155 
    155156    $self->{'parser'} = $parser;