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

gEDA-user: Fix for infinite loop in m4 macros



I'm new to gaf/pcb.  My first layout caused an infinite loop in gsch2pcb.
This seems to be due to an infinite loop in the SIL m4 macro, which is
due to two things:

1)  The macro has what I'm guessing is cut'n'paste code left from DIL
to draw dividers on the silkscreen "pins/2-1" times instead of "pins-1"
times, which means any odd SIL is going to make a non-integer end, and

2)  The forloop macro loops from start to exactly equal to end, so if
the start is less than the end (eg SIL for 1 pin has no dividers) or
the expression produces a fraction that can't match, the m4 will loop
forever.

The solution to (2) is more important because it probably affects many
macros.  My m4 skills are rusty, but I think this replacement (in
common.m4) should work:

define(`forloop',
	`pushdef(`$1', `$2')_forloop(`$1', `$2', `$3', `$4')popdef(`$1')')
define(`_forloop',
	`$4`'ifelse(eval($1 < `$3'),1,
	`define(`$1', incr($1))_forloop(`$1', `$2', `$3', `$4')')')

The change to PKG_SIL in misc.inc is trivial, change the end of the loop
to $4-1 instead of $4/2-1.

-- 
Ben Jackson AD7GD
<ben@xxxxxxx>
http://www.ben.com/


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