|
From: Robin M. <rob...@gm...> - 2006-06-08 12:18:28
|
Here's the patch. This one implements a *proper* recursive, lazy-loading interpolation approach, and no longer suffers from the "stop when a $$ is seen" problem. If anything stops interpolation of one key, the rest of the keys in the string will not have their interpolation stopped. Thus, "$foo + $bar + $baz" will follow "$baz" all the way down the interpolation tree even if "$foo" immediately evaluates to "$$99.95" (which becomes "$99.95" and stops interpolation of "$foo"). Infinite-recursion loops will be detected as soon as any value is entered for the second time, and an exception will be thrown at that point. This has the added advantage of making the MAX_INTERPOL_DEPTH value completely unnecessary -- with my patch applied, MAX_INTERPOL_DEPTH can still be set, but it has no effect whatsoever. The recursion will continue down as deep as necessary as long as there are no loops. I've tested this code against all the scenarios I could come up with, and it's worked properly every time. This version of the patch makes no change to the "which section to look at" behavior: it only looks at sections named DEFAULT. Next up: a patch that changes this lookup order to the following: 1) Current section 2) Current section's DEFAULT 3) current = current.parent; repeat from 1 -- Robin Munn Rob...@gm... GPG key 0xD6497014 |