[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Layer selective DRC



On Sat, Aug 06, 2011 at 05:23:59PM +0200, Kai-Martin Knaak wrote:
> 
> The continue statement completely messes the DRC check. I get more
> violations with PCB::skip-drc than without. Seems like the if-statements
> have some side effect that should not be skipped. What does the r_search 
> line actually do?
> 
> The comment in rtree.h says, this function returns true if something 
> is found in a region given by the parameters. But in the context of 
> find.c the result of the r_search() does not seem to be used:
> 
>           info.layer = layer;
>           /* add touching lines */
>           if (setjmp (info.env) == 0)
>             r_search (LAYER_PTR (layer)->line_tree, (BoxType *) & info.pv,
>                       NULL, LOCtoPVline_callback, &info);
>           else
>             return true;
> 
> Does r_search() change any aspect of the parameters it gets?

r_search does not, directly. But if it finds something, it calls
LOCtoPVline_callback, which might. It definitely modifies global
state.

Probably there is a counter or something. Everything is hidden
behind macros.

I had a similar bug in cleaning up LineLineIntersect. It changed
the number of DRC errors on my stereo bike from 10 to ~50. In the
end I did not understand the bug or how it worked -- I only found
the place where I had changed the code's behavior accidentally.

> What is the logic behind the if statement? That is, what is it supposed
> to mean if inf.env does equal zero or contains some other value?
> 
> Sorry for being such a programming noob. My hacking skills are pretty
> under developed.
>

I really wish we were not using setjmp/longjmp. They are essentially
global goto statements -- setjmp stores the stack frame and instruction
pointer ("environment") in the given variable, and longjmp restores it.

setjmp returns zero when you first call it. But when restoring the
stack frame, it returns 1, so that we don't get an infinite loop.

They make even experienced programmers very nervous.

-- 
Andrew Poelstra
Email: asp11 at sfu.ca OR apoelstra at wpsoftware.net
Web:   http://www.wpsoftware.net/andrew/



_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user