This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In makedef.pl, refactor the code that reads *.sym files.
authorNicholas Clark <nick@ccl4.org>
Thu, 28 Jul 2011 15:03:04 +0000 (17:03 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 1 Aug 2011 09:53:57 +0000 (11:53 +0200)
Hoist the test that chooses the prefix out of the loop. Tweak the regex to
avoid needing an explicit chomp/ Use 3-arg open and a lexical for the file
handle.

makedef.pl

index 865b5ff..e7d72e3 100644 (file)
@@ -731,17 +731,15 @@ if ($define{'USE_PERLIO'}) {
 # many symbols against them.
 
 for my $syms (@syms) {
-    open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
-    while (<GLOBAL>) {
-       next if (!/^[A-Za-z]/);
-       # Functions have a Perl_ prefix
-       # Variables have a PL_ prefix
-       chomp($_);
-       my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
-       $symbol .= $_;
+    open my $global, '<', $syms or die "failed to open $syms: $!\n";
+    # Functions already have a Perl_ prefix
+    # Variables need a PL_ prefix
+    my $prefix = $syms =~ /var\.sym$/i ? 'PL_' : '';
+    while (<$global>) {
+       next unless /^([A-Za-z].*)/;
+       my $symbol = "$prefix$1";
        ++$export{$symbol} unless exists $skip{$symbol};
     }
-    close(GLOBAL);
 }
 
 # variables