bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] error: drop spurious semicolon


From: Eric Blake
Subject: Re: [PATCH] error: drop spurious semicolon
Date: Thu, 04 Sep 2014 10:06:11 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

On 09/04/2014 09:57 AM, Jim Meyering wrote:
> On Thu, Sep 4, 2014 at 8:11 AM, Ben Pfaff <address@hidden> wrote:
>> On Thu, Sep 04, 2014 at 06:28:19AM -0600, Eric Blake wrote:
>>> Noticed this while writing a syntax check rule to look for bogus
>>> doubled semicolons.  If there's interest, I could add this rule
>>> to maint.mk:
>>>
>>> # Except for shell files and for loops, double semicolon is probably a 
>>> mistake
>>> sc_prohibit_double_semicolon:
>>>       @prohibit=';;'                                          \
>>>       in_vc_files='\.[ch]$$'                                  \
>>>       exclude='for \(.*\)'                                    \
>>>       halt="Double semicolon detected"                        \
>>>         $(_sc_search_regexp)
>>
>> That looks useful to me.
> 
> I like it, too.  But please relax it to also match
> whitespace-separated semicolons.
> Also, I'd anchor it at end of line, to avoid most false positives for the
> legitimate use of two adjacent semicolons in a for-expression.

The exclude= already covers the legitimate case of 'for (;;)', so
anchoring doesn't change anything there.

The biggest other legitimate use is when writing shell case statements.
 So I suppose if you have C code that generates shell via string
literals, anchoring to the end of the line will prevent false positives
on "case $blah in *) ;; esac" of the string literal in teh C code.  But
adding the anchor would also cause false negatives (it would no longer
flag English text in comments or string literals that also abused double
semicolon).

So which is more important, avoiding false positives (rule is too noisy
on legitimate code) or minimizing false negatives (rule misses cases
that were questionable but outside the pattern of the rule)?  Once we
decide that, I can push the syntax check addition to maint.mk.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]