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>
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							6345d7a0d1
						
					
				
				
					commit
					ad87e4f6f1
				
			@ -2065,18 +2065,17 @@ sub git_get_project_ctags {
 | 
			
		||||
	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;
 | 
			
		||||
		close CT;
 | 
			
		||||
		close $ct;
 | 
			
		||||
		my $ctag = $_; $ctag =~ s#.*/##;
 | 
			
		||||
		$ctags->{$ctag} = $val;
 | 
			
		||||
	}
 | 
			
		||||
	closedir D;
 | 
			
		||||
	closedir $dh;
 | 
			
		||||
	$ctags;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2804,18 +2803,18 @@ sub mimetype_guess_file {
 | 
			
		||||
	-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
 | 
			
		||||
		my ($mime, $exts) = split(/\t+/);
 | 
			
		||||
		my ($mimetype, $exts) = split(/\t+/);
 | 
			
		||||
		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};
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user