From 8e34feea0b312481ee3861862b95c81e5db5c1db Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 14 Nov 2009 18:41:44 -0600 Subject: [PATCH] Fix an order-of-operations bug in finalize_placeholders(). The bug would have prevented the resolution of multiple levels of links. --- reader.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/reader.c b/reader.c index 0260aaa..0884a02 100644 --- a/reader.c +++ b/reader.c @@ -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) { - 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. - * Self-links indicate cycles and are replaced with UNDEFINED. - * We're done when no placeholders link to other placeholders. */ + changed = false; + + /* 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)) { if (_CADR(item) == item)