]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Do not use bareword filehandles
authorJakub Narebski <redacted>
Mon, 11 May 2009 01:21:06 +0000 (03:21 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:38 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 1cfb78e4a47576ad3fe78e4dd7e11624a04a9adb7dc52dc58d0a3ebf1fb3926b..22df90680b990a133e027d36fcd0f852ba599898e16c5b3a6cbb0d8ab722eedd 100755 (executable)
@@ -2066,18 +2066,17 @@ sub git_get_project_ctags {
        my $ctags = {};
 
        $git_dir = "$projectroot/$path";
        my $ctags = {};
 
        $git_dir = "$projectroot/$path";
-       unless (opendir D, "$git_dir/ctags") {
-               return $ctags;
-       }
-       foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir(D)) {
-               open CT, $_ or next;
-               my $val = <CT>;
+       opendir my $dh, "$git_dir/ctags"
+               or return $ctags;
+       foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir($dh)) {
+               open my $ct, $_ or next;
+               my $val = <$ct>;
                chomp $val;
                chomp $val;
-               close CT;
+               close $ct;
                my $ctag = $_; $ctag =~ s#.*/##;
                $ctags->{$ctag} = $val;
        }
                my $ctag = $_; $ctag =~ s#.*/##;
                $ctags->{$ctag} = $val;
        }
-       closedir D;
+       closedir $dh;
        $ctags;
 }
 
        $ctags;
 }
 
@@ -2805,18 +2804,18 @@ sub mimetype_guess_file {
        -r $mimemap or return undef;
 
        my %mimemap;
        -r $mimemap or return undef;
 
        my %mimemap;
-       open(MIME, $mimemap) or return undef;
-       while (<MIME>) {
+       open(my $mh, $mimemap) or return undef;
+       while (<$mh>) {
                next if m/^#/; # skip comments
                next if m/^#/; # skip comments
-               my ($mime, $exts) = split(/\t+/);
+               my ($mimetype, $exts) = split(/\t+/);
                if (defined $exts) {
                        my @exts = split(/\s+/, $exts);
                        foreach my $ext (@exts) {
                if (defined $exts) {
                        my @exts = split(/\s+/, $exts);
                        foreach my $ext (@exts) {
-                               $mimemap{$ext} = $mime;
+                               $mimemap{$ext} = $mimetype;
                        }
                }
        }
                        }
                }
        }
-       close(MIME);
+       close($mh);
 
        $filename =~ /\.([^.]*)$/;
        return $mimemap{$1};
 
        $filename =~ /\.([^.]*)$/;
        return $mimemap{$1};
This page took 0.300842 seconds and 4 git commands to generate.