Skip to content

Commit ad87e4f

Browse files
jnarebgitster
authored andcommitted
gitweb: Do not use bareword filehandles
gitweb: Do not use bareword filehandles The script was using bareword filehandles. This is considered a bad practice so they have been changed to indirect filehandles. Changes touch git_get_project_ctags and mimetype_guess_file; while at it rename local variable from $mime to $mimetype (in mimetype_guess_file) to better reflect its value (its contents). Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6345d7a commit ad87e4f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

gitweb/gitweb.perl

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,18 +2065,17 @@ sub git_get_project_ctags {
20652065
my $ctags = {};
20662066

20672067
$git_dir = "$projectroot/$path";
2068-
unless (opendir D, "$git_dir/ctags") {
2069-
return $ctags;
2070-
}
2071-
foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir(D)) {
2072-
open CT, $_ or next;
2073-
my $val = <CT>;
2068+
opendir my $dh, "$git_dir/ctags"
2069+
or return $ctags;
2070+
foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir($dh)) {
2071+
open my $ct, $_ or next;
2072+
my $val = <$ct>;
20742073
chomp $val;
2075-
close CT;
2074+
close $ct;
20762075
my $ctag = $_; $ctag =~ s#.*/##;
20772076
$ctags->{$ctag} = $val;
20782077
}
2079-
closedir D;
2078+
closedir $dh;
20802079
$ctags;
20812080
}
20822081

@@ -2804,18 +2803,18 @@ sub mimetype_guess_file {
28042803
-r $mimemap or return undef;
28052804

28062805
my %mimemap;
2807-
open(MIME, $mimemap) or return undef;
2808-
while (<MIME>) {
2806+
open(my $mh, $mimemap) or return undef;
2807+
while (<$mh>) {
28092808
next if m/^#/; # skip comments
2810-
my ($mime, $exts) = split(/\t+/);
2809+
my ($mimetype, $exts) = split(/\t+/);
28112810
if (defined $exts) {
28122811
my @exts = split(/\s+/, $exts);
28132812
foreach my $ext (@exts) {
2814-
$mimemap{$ext} = $mime;
2813+
$mimemap{$ext} = $mimetype;
28152814
}
28162815
}
28172816
}
2818-
close(MIME);
2817+
close($mh);
28192818

28202819
$filename =~ /\.([^.]*)$/;
28212820
return $mimemap{$1};

0 commit comments

Comments
 (0)