gitweb: Always use three argument form of open
From 94638fb6edf3ea693228c680a6a30271ccd77522 Mon Sep 17 00:00:00 2001 From: Jakub Narebski <jnareb@gmail.com> Date: Mon, 11 May 2009 03:25:55 +0200 Subject: [PATCH] gitweb: Localize magic variable $/ Instead of undefining and then restoring magic variable $/ (input record separator) for 'slurp mode', localize it. While at it, state explicitely that "local $/;" makes it undefined, by using explicit "local $/ = undef;". 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:29 UTC
34122b57eca747022336f5a3dc1aa80377d1ce56
1 file changed
+14
-11
gitweb/gitweb.perl
+14
-11
@@ -3325,7 +3325,7 @@ sub git_get_link_target {
3325
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
3326
or return;
3327
{
3328
- local $/;
3328
+ local $/ = undef;
3329
$link_target = <$fd>;
3330
}
3331
close $fd
@@ -4800,11 +4800,10 @@ sub git_blob_plain {
4800
-content_disposition =>
4801
($sandbox ? 'attachment' : 'inline')
4802
. '; filename="' . $save_as . '"');
4803
- undef $/;
4803
+ local $/ = undef;
4804
binmode STDOUT, ':raw';
4805
print <$fd>;
4806
binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
4807
- $/ = "\n";
4807
close $fd;
4808
}
4809
@@ -4906,12 +4905,16 @@ sub git_tree {
4905
}
4906
}
4907
die_error(404, "No such tree") unless defined($hash);
4909
- $/ = "\0";
4910
- open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
4911
- or die_error(500, "Open git-ls-tree failed");
4912
- my @entries = map { chomp; $_ } <$fd>;
4913
- close $fd or die_error(404, "Reading tree failed");
4914
- $/ = "\n";
4908
+
4909
+ my @entries = ();
4910
+ {
4911
+ local $/ = "\0";
4912
+ open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
4913
+ or die_error(500, "Open git-ls-tree failed");
4914
+ @entries = map { chomp; $_ } <$fd>;
4915
+ close $fd
4916
+ or die_error(404, "Reading tree failed");
4917
+ }
4918
4919
my $refs = git_get_references();
4920
my $ref = format_ref_marker($refs, $hash_base);
@@ -5806,7 +5809,7 @@ sub git_search {
5809
5810
print "<table class=\"pickaxe search\">\n";
5811
my $alternate = 1;
5809
- $/ = "\n";
5812
+ local $/ = "\n";
5813
open my $fd, '-|', git_cmd(), '--no-pager', 'log', @diff_opts,
5814
'--pretty=format:%H', '--no-abbrev', '--raw', "-S$searchtext",
5815
($search_use_regexp ? '--pickaxe-regex' : ());
@@ -5876,7 +5879,7 @@ sub git_search {
5879
print "<table class=\"grep_search\">\n";
5880
my $alternate = 1;
5881
my $matches = 0;
5879
- $/ = "\n";
5882
+ local $/ = "\n";
5883
open my $fd, "-|", git_cmd(), 'grep', '-n',
5884
$search_use_regexp ? ('-E', '-i') : '-F',
5885
$searchtext, $co{'tree'};