From: Jeff King <peff@peff.net>
To: rh <richard_hubbe11@lavabit.com>
Cc: Jakub Narebski <jnareb@gmail.com>, git@vger.kernel.org
Subject: Re: gitweb
Date: Mon, 29 Oct 2012 01:28:15 -0400 [thread overview]
Message-ID: <20121029052815.GA30186@sigill.intra.peff.net> (raw)
In-Reply-To: <20121028165647.b79fe3fcb6784c4ae547439e@lavabit.com>
On Sun, Oct 28, 2012 at 04:56:47PM -0700, rh wrote:
> I'm not using gitweb I was thinking about using it and was looking at the
> cgi and saw this in this file:
> https://github.com/git/git/blob/master/gitweb/gitweb.perl
>
> I think I understand the intention but the outcome is wrong.
>
> our %highlight_ext = (
> # main extensions, defining name of syntax;
> # see files in /usr/share/highlight/langDefs/ directory
> map { $_ => $_ }
> qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl sql make),
> # alternate extensions, see /etc/highlight/filetypes.conf
> 'h' => 'c',
> map { $_ => 'sh' } qw(bash zsh ksh),
> map { $_ => 'cpp' } qw(cxx c++ cc),
> map { $_ => 'php' } qw(php3 php4 php5 phps),
> map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
> map { $_ => 'make'} qw(mak mk),
> map { $_ => 'xml' } qw(xhtml html htm),
> );
Yeah, this is wrong. The first map will eat the rest of the list, and
you will get "h => h", "cxx => cxx", and so forth. I do not know this
chunk of code, but that does not seem like it is the likely intent.
You could fix it with extra parentheses:
our %he = (
(map { $_ => $_ } qw(py c cpp ...)),
'h' => 'c',
(map { $_ => 'sh' } qw(bash zsh ksh)),
... etc ...
);
> I think the intent is better met with this, (the print is for show)
>
> our %he = ();
> $he{'h'} = 'c';
> $he{$_} = $_ for (qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl sql make));
> $he{$_} = 'cpp' for (qw(cxx c++ cc));
> $he{$_} = 'php' for (qw(php3 php4 php5 phps));
> $he{$_} = 'pl' for (qw(cgi perl pm));
> $he{$_} = 'make' for (qw(mak mk));
> $he{$_} = 'xml' for (qw(xhtml html htm));
> $he{$_} = 'sh' for (qw(bash zsh ksh));
That is more readable to me (though it does lose the obviousness that it
is a variable initialization).
Looks like this was broken since 592ea41 (gitweb: Refactor syntax
highlighting support, 2010-04-27). I do not use gitweb (nor highlight)
at all, but I'd guess the user-visible impact is that "*.h" files are
not correctly highlighted (unless highlight does this extension mapping
itself, but then why are we doing it here?).
Jakub, can you confirm the intent and a fix like the one above makes
things better?
-Peff
next prev parent reply other threads:[~2012-10-29 5:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-28 23:56 gitweb rh
2012-10-29 5:28 ` Jeff King [this message]
2012-10-29 7:12 ` gitweb Jakub Narębski
2012-10-29 7:14 ` gitweb Jeff King
-- strict thread matches above, loose matches on Subject: below --
2008-09-12 12:48 Gitweb delux
2008-09-12 13:27 ` Gitweb Jakub Narebski
2005-10-15 19:31 gitweb Nico -telmich- Schottelius
2005-10-15 19:37 ` gitweb Nico -telmich- Schottelius
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121029052815.GA30186@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=richard_hubbe11@lavabit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).