This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Porting/corelist.pl didn't handle newlines in the pod version list
[perl5.git] / Porting / corelist.pl
index c5952c3..8887774 100755 (executable)
@@ -145,6 +145,18 @@ exit unless %modlist;
 # data by "Module", which is really a dist.
 my $file_to_M = files_to_modules( values %module_to_file );
 
+sub slurp_utf8($) {
+    open my $fh, "<:utf8", "$_[0]"
+       or die "can't open $_[0] for reading: $!";
+    return do { local $/; <$fh> };
+}
+
+sub parse_cpan_meta($) {
+    return Parse::CPAN::Meta->${
+       $_[0] =~ /\A\x7b/ ? \"load_json_string" : \"load_yaml_string"
+    }($_[0]);
+}
+
 my %module_to_upstream;
 my %module_to_dist;
 my %dist_to_meta_YAML;
@@ -175,13 +187,13 @@ while ( my ( $module, $file ) = each %module_to_file ) {
     my $meta_YAML_url = 'http://ftp.funet.fi/pub/CPAN/' . $meta_YAML_path;
 
     if ( -e "$cpan/$meta_YAML_path" ) {
-        $dist_to_meta_YAML{$dist} = Parse::CPAN::Meta::LoadFile( $cpan . "/" . $meta_YAML_path );
+        $dist_to_meta_YAML{$dist} = parse_cpan_meta(slurp_utf8( $cpan . "/" . $meta_YAML_path ));
     } elsif ( my $content = fetch_url($meta_YAML_url) ) {
         unless ($content) {
             warn "Failed to fetch $meta_YAML_url\n";
             next;
         }
-        eval { $dist_to_meta_YAML{$dist} = Parse::CPAN::Meta::Load($content); };
+        eval { $dist_to_meta_YAML{$dist} = parse_cpan_meta($content); };
         if ( my $err = $@ ) {
             warn "$meta_YAML_path: ".$err;
             next;
@@ -226,6 +238,7 @@ foreach my $module ( sort keys %module_to_upstream ) {
     my $dist = $module_to_dist{$module};
     $bug_tracker = $dist_to_meta_YAML{$dist}->{resources}{bugtracker}
         if $dist;
+    $bug_tracker = $bug_tracker->{web} if ref($bug_tracker) eq "HASH";
 
     $bug_tracker = defined $bug_tracker ? "'$bug_tracker'" : 'undef';
        next if $bug_tracker eq "'http://rt.perl.org/perlbug/'";
@@ -254,7 +267,7 @@ my $pod = join( '', <$pod_fh> );
 
 unless ( $pod =~ /and $perl_vstring releases of perl/ ) {
     warn "Adding $perl_vstring to the list of perl versions covered by Module::CoreList\n";
-    $pod =~ s/(currently covers (?:.*?))\s*and (.*?) releases of perl/$1, $2 and $perl_vstring releases of perl/ism;
+    $pod =~ s/(currently\s+covers\s+(?:.*?))\s*and\s+(.*?)\s+releases\s+of\s+perl/$1, $2 and $perl_vstring releases of perl/ism;
 }
 
 write_corelist($pod,$pod_file);