develooper Front page | perl.perl5.porters | Postings from February 2016

RE: Re: [PATCH] strict.pm modernisation

Thread Previous | Thread Next
From:
vadim.konovalov.ext
Date:
February 25, 2016 14:12
Subject:
RE: Re: [PATCH] strict.pm modernisation
Message ID:
264C8A3AD6014D47AA88C560B7778DD30110E97D9B@FR712WXCHMBA10.zeu.alcatel-lucent.com
> From: Aristotle Pagaltzis
> * Konovalov, Vadim [2016-02-22 10:55]:
> > +    if ( __FILE__ !~ /strict\.pmc?$/ and -e __FILE__ ) {
> 
> 
> This patch should not be applied.
> 
> Looking for the file on the filesystem using -e causes the
> exact same bug as you were complaining about, if the file
> was packed in FatPacker style.
> 
> FatPacker makes __FILE__ point to the fatpacked script. So
> -e __FILE__ will be true.
> 
> And __FILE__ !~ /strict\.pmc?$/ will also be true, because
> __FILE__ is the name of some script.
> 
> Therefore the error will be thrown, even though the user
> did not mistype the `use strict` line.

Then - how this works *now* for fatpacker - the curerct check?

unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) {
    # Can't use Carp, since Carp uses us!
    my (undef, $f, $l) = caller;
    die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n");
}

You must admit that __FILE__ends with "strict.pm" for __FILE__ in fatpacker

> 
> FatPacker has a very good reason to point __FILE__ to the
> fatpacked
> script: this way, die() and warn() messages will contain
> the actual file and line of the code that caused the
> message.
> 
> Therefore it is the check that is wrong, and not FatPacker.
> 
> 
> Regards,
> --
> Aristotle Pagaltzis // <http://plasmasturm.org/>
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About