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:
parent
9f0dc52934
commit
8e34feea0b
12
reader.c
12
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)
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue