Commit 684423f9 authored by Erick's avatar Erick

Small improvements on read/write of circular structures

parent 8e5ce4d1
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: ??-Oct-1993 ??:??
* Last file update: 19-Oct-2018 21:22 (eg)
* Last file update: 22-Oct-2018 17:35 (eg)
*
*/
#include <ctype.h>
......@@ -339,13 +339,11 @@ static void printlist_star(SCM exp, SCM port, int mode, cycles *c)
if (NULLP(exp=CDR(exp))) break;
value = STk_hash_ref_default(c->seen, exp, STk_false);
if (!CONSP(exp) || value != STk_false) {
if (!CONSP(exp) || value == STk_true || INTP(value)) { //FIXME: value == #t??
if (!CONSP(exp) || value != STk_false) { /* value is #t or an integer */
/* either ". X" or ". #0=(...)" or ". #0#" */
STk_nputs(port, " . ", 3);
print_cycle(exp, port, mode, c);
break;
}
}
STk_putc(' ', port);
}
......
......@@ -20,7 +20,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: ??-Oct-1993 ??:??
* Last file update: 2-Jul-2018 16:32 (eg)
* Last file update: 27-Nov-2018 10:38 (eg)
*
*/
......@@ -406,7 +406,7 @@ static void patch_references(SCM port, SCM l, SCM cycles)
tmp = *((SCM *) CAR(l));
k = PLACEHOLDER_VAL(tmp);
if ((tmp = STk_assv(k, cycles)) != STk_false) {
if ((tmp = STk_assq(k, cycles)) != STk_false) {
*((SCM *) CAR(l)) = CDR(tmp);
}
else
......@@ -432,7 +432,7 @@ static SCM read_cycle(SCM port, int c, struct read_context *ctx)
k = MAKE_INT(atoi(buffer));
switch (c) {
case '#': if ((tmp = STk_assv(k, ctx->cycles)) != STk_false) {
case '#': if ((tmp = STk_assq(k, ctx->cycles)) != STk_false) {
val = CDR(tmp);
if (PLACEHOLDERP(val))
CAR(val) = STk_true; /* Mark the placeholder as read */
......@@ -449,10 +449,10 @@ static SCM read_cycle(SCM port, int c, struct read_context *ctx)
* (#0=(1 2 . #0#) #0#)
* the first reference will use the placeholder cell, whereas
* the second one will be correct.
* We call here the function find_inner_references to capture
* We call here the function add_inner_references to capture
* the reference which are in the second case.
*
* At the end, of the entire read (and only at the end to
* At the end of the entire read (and only at the end to
* avoid a long time calculation, or even infinite loops),
* the function "patch_references" will correct all the
* remaining references that must be modified.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment