nasty bug in SA.pm (I think)

Logan Shaw lshaw at emitinc.com
Fri Aug 11 23:26:57 IST 2006


On Fri, 11 Aug 2006, Jeff A. Earickson wrote:
> So I stared at SA.pm.  You commented out line 287:
>
> #if (MailScanner::Config::Value('compilespamassassinonce')) {
>
> at some point, which commented out half of a curly-bracket block.
> I can't find where the right curly-bracket for this line is, and I
> think something is mis-aligned here.
>
> Using the power feature of vi whereby you put the cursor over a
> bracket, paren, etc and then hit "%", I don't find the closing curly bracket 
> for line 72 ("sub initialise {").  This routine seems
> mangled and I think this is the root cause of the loop-up bug.

Beware of using "%" in vi on Perl code.  vi's "%" feature was
written for C, and as you may have noticed, Perl's syntax is
not exactly the same as C's.  :-)  (It is similar enough to make
"%" work most of the time, though.)

In particular, vi really doesn't understand braces that are
commented out with Perl comments:

 	while (1)
 	{
 	    bar1();

 	    # this brace will confuse vi ---> }

 	    bar2();
 	}

Try putting your cursor on the "{" right after the "while" and
hitting "%".  You'll see it matching against the wrong brace.

In fact, I think that's what is happening with SA.pm.  An easy
way to test it is to just delete the comment line with the brace
that's confusing vi.  We are probably at different MailScanner
versions since the corresponding line on mine is at 285, but
if you delete the line with 'compilespamassassinonce' on it,
then try to match braces with "%", everything looks good.

   - Logan


More information about the MailScanner mailing list