From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Reduce the number of special cases to build contrib modules on windows |
Date: | 2020-11-09 14:06:58 |
Message-ID: | 20201109140658.GA32074@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2020-Nov-06, David Rowley wrote:
> +# Handle makefile rules for when file to be added to the project
> +# does not exist. Returns 1 when the original file add should be
> +# skipped.
> +sub FindAndAddAdditionalFiles
> +{
> + my $self = shift;
> + my $fname = shift;
> + my ($ext) = $fname =~ /(\.[^.]+)$/;
> +
> + # For .c files, check if a .l file of the same name exists and add that
> + # too.
> + if ($ext eq ".c")
> + {
> + my $filenoext = $fname;
> + $filenoext =~ s{\.[^.]+$}{};
I think you can make this simpler by capturing both the basename and the
extension in one go. For example,
$fname =~ /(.*)(\.[^.]+)$/;
$filenoext = $1;
$ext = $2;
so you avoid the second =~ statement.
> + if (-e "$filenoext.l")
> + {
> + AddFileConditional($self, "$filenoext.l");
> + return 1;
> + }
> + if (-e "$filenoext.y")
> + {
> + AddFileConditional($self, "$filenoext.y");
Maybe DRY like
for my $ext (".l", ".y") {
my $file = $filenoext . $ext;
AddFileConditional($self, $file) if -f $file;
return 1;
}
Note: comment says "check if a .l file" and then checks both .l and .y.
Probably want to update the comment ...
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2020-11-09 14:28:56 | Re: Prevent printing "next step instructions" in initdb and pg_upgrade |
Previous Message | Dave Cramer | 2020-11-09 13:56:42 | Re: Making cancellations safe |