Fix an order-of-operations bug in finalize_placeholders().

The bug would have prevented the resolution of multiple levels of links.
This commit is contained in:
Jesse D. McDonald 2009-11-14 18:41:44 -06:00
parent 9f0dc52934
commit 8e34feea0b
1 changed files with 8 additions and 4 deletions

View File

@ -590,11 +590,15 @@ static void set_placeholder(reader_state_t *state, value_t place, value_t value)
static void finalize_placeholders(reader_state_t *state) static void finalize_placeholders(reader_state_t *state)
{ {
for (bool changed = true; changed; changed = false) bool changed = true;
/* We're done when no placeholders link to other placeholders. */
while (changed)
{ {
/* On each cycle, placeholder cycles/lists should come one link closer to self or actual value. changed = false;
* Self-links indicate cycles and are replaced with UNDEFINED.
* We're done when no placeholders link to other placeholders. */ /* Resolve one level of placeholder-to-placeholder links.
* Self-links indicate cycles and are replaced with UNDEFINED. */
for (value_t item = state->ref_alist.value; !is_nil(item); item = _CDDR(item)) for (value_t item = state->ref_alist.value; !is_nil(item); item = _CDDR(item))
{ {
if (_CADR(item) == item) if (_CADR(item) == item)