[pacman-dev] [PATCH 2/3] pacsearch with repo-agnostic coloring
ambrevar at gmail.com
Wed Jan 15 11:49:33 EST 2014
On 14-01-15 17:03:39, Martti Kühne wrote:
> On Wed, Jan 15, 2014 at 9:50 AM, Allan McRae <allan at archlinux.org> wrote:
> >> + # hash function (x*2+1) is completely arbitrary.
> >> + my $repohash = $v;
> >> + $repohash =~ s/(.)/ord($1)*2+1/ge;
> > I have very little perl knowledge, so I have no idea what that hash is
> > doing. Can someone explain to me so I can see if that "hash" is reasonable.
> Replace each character with its  ascii index times two plus one?
> 'g' is group regexes, 'e' is eval expressions , as to utilize the
> result of the calculation.
>  http://perldoc.perl.org/functions/ord.html
>  http://stackoverflow.com/questions/6082219/perl-regex-e-eval-modifier-with-s
That's right except for 'g' as you stated in you following mail.
This hash function is a bit hackish though, but I do not think this problem has
any better solution.
* We need to color repo according to their name.
* We want repo to have different colors.
* We have only 6 colors...
So my hash functions makes core, multilib, local, extra and community have
different colors. With different repo names, the hash may return the same color
for all of them.
Any better idea?
Sometimes love ain't nothing but a misunderstanding between two fools.
More information about the pacman-dev