Re: [patch v4] checkpatch: Signature format verification

From: Steven Rostedt
Date: Fri May 27 2011 - 16:18:37 EST


On Sat, 2011-05-28 at 01:24 +0530, anish singh wrote:
>

>
> Anish, do you have a response to this?
> Your approach is correct but i am trying to do in my own way.

Why?? Correct is more important than individual preferences.

>
> > I have replaced b/w with "between".
> > And as Manish rightly exlained this patch is not meant for
> > email validation.
>
>
> Yet it does incorrectly anyway to nominally skip
> name and find <.*>. That's the problem.
>
> Look again at the patterns:
>
> + if ($line =~ /^\s*$sign(.*)/i)
> {
> + if ($1 !~ /^\s
> +([a-zA-Z\s\"\.\-\'\,]*.*)/i) {

Note, why the []? Because you basically have:

/^\s+([blahblah]*.*)/

which is the same as:

/^\s+(.*)/

> + WARN("Space
> required after $sign\n" .
> +
> $herecurr);
>
> + }
>
> here i am trying to check space between sign & name.
> In first if loop i am checking if sign is present in line or not.
> If yes, enter into second if loop & check if $1 starts with space
> or not(which takes care of checking space between sign & name).
> In this if loop again i am catching name & rest of the things in $1.
> $1 will be used for checking space between name & mail-id.

BTW, people hate perl for this very reason. This subtle changing of $1
is very hard to follow if you are not a perl expert. I use perl all the
time (recordmcount.pl and ktest.pl), but if you look at my code, you
will see that I purposely avoid these subtle characteristics of perl,
because that's the (very rightfully so) reason people complain that perl
is a write once and never maintain language.

I understood from the beginning what you were doing, but I had to think
about it more than I should have.

>
> and
>
> + if ($1 !~ /([\sa-zA-Z
> \"\.\-\'\,]*)\s<.*>/i) {
> + WARN("Space
> required b/w Full Name & Mail-id:\n" .
> +
> $herecurr);
>
> + }


You really need to get a new MUA.
>
>
>
> In this If loop i am using $1 (returned by earlier pattern) to check
> space
> between mail and <mail-id>.
> If we print $1 after last if loop, we can get name appropriately.
> So, i am not skipping name here to match <>.
>
> I will change <.*> to <.*?> (non-greedy match) for matching very first
> enclosing bracket.

Again, this doesn't explain the space warning when I have just his:

Signed-off-by: <me@xxxxxxx>

Because that will not match the above, because the $1 will be
"<me@xxxxxxx>". With no space.


-- Steve



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/