On Mon, Jun 03, 2013 at 12:03:02PM +0300, Niko Tyni wrote:
> On Sun, Jun 02, 2013 at 11:12:37PM +0100, Dominic Hargreaves wrote:
> > Package: perl
> > Version: 5.18.0-1
> > Severity: minor
> > 
> > Even though perl -V displays them correctly:
> 
> > perlbug doesn't seem to. See eg
> > https://rt.perl.org/rt3/Public/Bug/Display.html?id=118271:
> 
> > The same behaviour exists in 5.14.2-21 at least.
> 
> Urgh. This is unfortunate. I assume it broke after squeeze
> when I switched patchlevel.h to use
> 
>  #ifdef DEBIAN
>  #include "patchlevel-debian.h"
>  #endif
> 
> as perlbug just skips those preprocessor directives.
> 
> I think we'll have to either make utils/perlbug.PL follow #include
> directives, or just hardcode patchlevel-debian.h.

Or maybe just run cpp on the file, like this?
-- 
Niko Tyni   nt...@debian.org
>From 502f877a7f4daadc3c72ce6094377fc8bf624997 Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Mon, 3 Jun 2013 14:33:48 +0300
Subject: [PATCH] Make perlbug.PL run patchlevel.h through cpp where possible

This makes it possible to use #include directives in patchlevel.h
and get them into perlbug reports.
---
 utils/perlbug.PL |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/utils/perlbug.PL b/utils/perlbug.PL
index bf86670..ab1c6ab 100644
--- a/utils/perlbug.PL
+++ b/utils/perlbug.PL
@@ -24,12 +24,21 @@ open OUT, ">$file" or die "Can't create $file: $!";
 
 # extract patchlevel.h information
 
-open PATCH_LEVEL, "<" . catfile(updir, "patchlevel.h")
-    or die "Can't open patchlevel.h: $!";
+my $cpp = $Config{cpp};
+my $cppflags = $Config{cppflags};
 
-my $patchlevel_date = (stat PATCH_LEVEL)[9];
+my $patchfile = catfile(updir, "patchlevel.h");
 
-while (<PATCH_LEVEL>) {
+my $in;
+if (!open $in, "$cpp $cppflags $patchfile|") {
+    warn "Warning: can't run cpp ('$cpp $cppflags $patchfile'): $!";
+    open $in, "<$patchfile"
+        or die "Can't open patchlevel.h: $!";
+}
+
+my $patchlevel_date = (stat $patchfile)[9];
+
+while (<$in>) {
     last if $_ =~ /^\s*static\s+(?:const\s+)?char.*?local_patches\[\]\s*=\s*{\s*$/;
 }
 
@@ -38,7 +47,7 @@ if (! defined($_)) {
 }
 
 my @patches;
-while (<PATCH_LEVEL>) {
+while (<$in>) {
     last if /^\s*}/;
     next if /^\s*#/;  # preprocessor stuff
     next if /PERL_GIT_UNPUSHED_COMMITS/;    # XXX expand instead
@@ -52,7 +61,7 @@ while (<PATCH_LEVEL>) {
 my $patch_desc = "'" . join("',\n    '", @patches) . "'";
 my $patch_tags = join "", map /(\S+)/ ? "+$1 " : (), @patches;
 
-close(PATCH_LEVEL) or die "Error closing patchlevel.h: $!";
+close($in) or die "Error closing handle to patchlevel.h: $!";
 
 # TO DO (prehaps): store/embed $Config::config_sh into perlbug. When perlbug is
 # used, compare $Config::config_sh with the stored version. If they differ then

Reply via email to