mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Remove use of global barewords in most file handling code.
This is not considered good practise in modern Perl code. A few cases of this still remain in code which is due to be rewritten anyway.
This commit is contained in:
parent
f0ca3397ea
commit
3cf2dd8247
@ -208,9 +208,9 @@ sub test_file($$;$) {
|
|||||||
sub test_header($$;$) {
|
sub test_header($$;$) {
|
||||||
my ($compiler, $header, $args) = @_;
|
my ($compiler, $header, $args) = @_;
|
||||||
$args //= '';
|
$args //= '';
|
||||||
open(COMPILER, "| $compiler -E - $args ${\CONFIGURE_ERROR_PIPE}") or return 0;
|
open(my $fh, "| $compiler -E - $args ${\CONFIGURE_ERROR_PIPE}") or return 0;
|
||||||
print COMPILER "#include <$header>";
|
print $fh "#include <$header>";
|
||||||
close(COMPILER);
|
close $fh;
|
||||||
return !$?;
|
return !$?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,11 +257,11 @@ sub parse_templates($$$) {
|
|||||||
# Iterate through files in make/template.
|
# Iterate through files in make/template.
|
||||||
foreach (<make/template/*>) {
|
foreach (<make/template/*>) {
|
||||||
print_format "Parsing <|GREEN $_|> ...\n";
|
print_format "Parsing <|GREEN $_|> ...\n";
|
||||||
open(TEMPLATE, $_) or print_error "unable to read $_: $!";
|
open(my $fh, $_) or print_error "unable to read $_: $!";
|
||||||
my (@lines, $mode, @platforms, %targets);
|
my (@lines, $mode, @platforms, %targets);
|
||||||
|
|
||||||
# First pass: parse template variables and directives.
|
# First pass: parse template variables and directives.
|
||||||
while (my $line = <TEMPLATE>) {
|
while (my $line = <$fh>) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
|
|
||||||
# Does this line match a variable?
|
# Does this line match a variable?
|
||||||
@ -301,7 +301,7 @@ sub parse_templates($$$) {
|
|||||||
}
|
}
|
||||||
push @lines, $line;
|
push @lines, $line;
|
||||||
}
|
}
|
||||||
close(TEMPLATE);
|
close $fh;
|
||||||
|
|
||||||
# Only proceed if this file should be templated on this platform.
|
# Only proceed if this file should be templated on this platform.
|
||||||
if ($#platforms < 0 || grep { $_ eq $^O } @platforms) {
|
if ($#platforms < 0 || grep { $_ eq $^O } @platforms) {
|
||||||
@ -397,11 +397,11 @@ sub parse_templates($$$) {
|
|||||||
|
|
||||||
# Write the template file.
|
# Write the template file.
|
||||||
print_format "Writing <|GREEN $target|> ...\n";
|
print_format "Writing <|GREEN $target|> ...\n";
|
||||||
open(TARGET, '>', $target) or print_error "unable to write $target: $!";
|
open(my $fh, '>', $target) or print_error "unable to write $target: $!";
|
||||||
foreach (@final_lines) {
|
foreach (@final_lines) {
|
||||||
say TARGET $_;
|
say $fh $_;
|
||||||
}
|
}
|
||||||
close(TARGET);
|
close $fh;
|
||||||
|
|
||||||
# Set file permissions.
|
# Set file permissions.
|
||||||
if (defined $mode) {
|
if (defined $mode) {
|
||||||
|
@ -41,16 +41,16 @@ our @EXPORT = qw(get_directive
|
|||||||
sub get_directive($$;$)
|
sub get_directive($$;$)
|
||||||
{
|
{
|
||||||
my ($file, $property, $default) = @_;
|
my ($file, $property, $default) = @_;
|
||||||
open(MODULE, $file) or return $default;
|
open(my $fh, $file) or return $default;
|
||||||
|
|
||||||
my $value = '';
|
my $value = '';
|
||||||
while (<MODULE>) {
|
while (<$fh>) {
|
||||||
if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
|
if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
|
||||||
next unless $1 eq $property;
|
next unless $1 eq $property;
|
||||||
$value .= ' ' . execute_functions($file, $1, $2);
|
$value .= ' ' . execute_functions($file, $1, $2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(MODULE);
|
close $fh;
|
||||||
|
|
||||||
# Strip all extraneous whitespace.
|
# Strip all extraneous whitespace.
|
||||||
$value =~ s/^\s+|\s+$//g;
|
$value =~ s/^\s+|\s+$//g;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user