Re: [PATCH 1/5] gitweb: Add a comment explaining the meaning of $/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2013-12-04 at 16:11 +0100, Jakub Narębski wrote:
> On Wed, Dec 4, 2013 at 2:42 PM, Krzesimir Nowak <krzesimir@xxxxxxxxxxxx> wrote:
> 
> > So future reader will know what does it mean without running "perldoc
> > perlvar".
> 
> Hmmm... shouldn't future reader know it anyway?  It is not that cryptic.
> I'd say it is idiomatic Perl.
> 

It's plainly obscure. And I think it is not that often used - I keep
forgetting what that pair of punctuation is actually meaning. In this
case I guess it would be more readable to use the following code
instead:
$fh->input_record_separator ("\0");

> Besides, it is not the only place where we set input record separator to NUL,
> to match corresponding option to git command to separate records with NUL
> (the '-z' option in this case).  Others are git_get_path_by_hash(),
> parse_commit(),
> and parse_commits(), git_tree(), not including places where we set $/ to undef
> to slurp whole file: git_get_link_target(), git_blobdiff() for $format
> == 'plain', etc.

Yes, but I stumbled upon that one when trying to understand how config
parsing works. So I added a comment.

> 
> > Signed-off-by: Krzesimir Nowak <krzesimir@xxxxxxxxxxxx>
> > ---
> >  gitweb/gitweb.perl | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index 68c77f6..ee61f9e 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -2629,6 +2629,8 @@ sub git_parse_project_config {
> >         my $section_regexp = shift;
> >         my %config;
> >
> > +       # input record separator, so getline does end on null, not
> > +       # newline
> >         local $/ = "\0";
> 
> It is here because of '-z' option below (to account for values with
> embedded newlines).
> 
> >
> >         open my $fh, "-|", git_cmd(), "config", '-z', '-l',
> > --
> > 1.8.3.1
> >
> 
> 
> 

-- 
Krzesimir Nowak
Software Developer
Endocode AG

krzesimir@xxxxxxxxxxxx

------
Endocode AG, Johannisstraße 20, 10117 Berlin
info@xxxxxxxxxxxx | www.endocode.com

Vorstandsvorsitzender: Mirko Boehm
Vorstände: Dr. Karl Beecher, Chris Kühl, Sebastian Sucker
Aufsichtsratsvorsitzende: Jennifer Beecher

Registergericht: Amtsgericht Charlottenburg - HRB 150748 B



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]