@matheusbsbs / matheus-bagliano / commits / ad87e4f6f1
Fork 0

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 <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jakub Narebski committed May 11, 2009 at 03:21 UTC ad87e4f6f19e78b3f2d7dde3d3ed403db4f79a03
1 file changed +12 -13
gitweb/gitweb.perl
+12 -13
@@ -2065,18 +2065,17 @@ sub git_get_project_ctags {
2065 my $ctags = {};
2066
2067 $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>;
2073 chomp $val;
2075 - close CT;
2074 + close $ct;
2075 my $ctag = $_; $ctag =~ s#.*/##;
2076 $ctags->{$ctag} = $val;
2077 }
2079 - closedir D;
2078 + closedir $dh;
2079 $ctags;
2080 }
2081
@@ -2804,18 +2803,18 @@ sub mimetype_guess_file {
2803 -r $mimemap or return undef;
2804
2805 my %mimemap;
2807 - open(MIME, $mimemap) or return undef;
2808 - while (<MIME>) {
2806 + open(my $mh, $mimemap) or return undef;
2807 + while (<$mh>) {
2808 next if m/^#/; # skip comments
2810 - my ($mime, $exts) = split(/\t+/);
2809 + my ($mimetype, $exts) = split(/\t+/);
2810 if (defined $exts) {
2811 my @exts = split(/\s+/, $exts);
2812 foreach my $ext (@exts) {
2814 - $mimemap{$ext} = $mime;
2813 + $mimemap{$ext} = $mimetype;
2814 }
2815 }
2816 }
2818 - close(MIME);
2817 + close($mh);
2818
2819 $filename =~ /\.([^.]*)$/;
2820 return $mimemap{$1};