diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-10-20 05:55:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-10-20 05:55:23 -0700 |
commit | 86523c667aceef602f80034d18edf68ee2949a11 (patch) | |
tree | de7dfb85eebb4bcaef9d356488db82b683c2db07 /struct.c | |
parent | 86f3d2ba19925ccece5c2cecc46db57817ffa85b (diff) | |
download | txr-86523c667aceef602f80034d18edf68ee2949a11.tar.gz txr-86523c667aceef602f80034d18edf68ee2949a11.tar.bz2 txr-86523c667aceef602f80034d18edf68ee2949a11.zip |
Implement *print-circle* for sharing and cycles.
* lib.c (obj_print_impl): On entry, ctx being non-null
indicates that cycle and substructure detecting is enabled via
*print-circle* for this print job. In this case, check
whether this is the first request to print a
multiply-referenced object, in which case we print the #<n>=
label definition, or whether it is a second or additional
reference, in which case we render the object as #<n>#.
Special handling must also be introduced into the loop which
prints list elements. At any point in a list, the rest of the
list could be shared substructure or a cyclic link that must
be rendered with the appropriate notation.
(populate_obj_hash): New static function. Enters all objects
in the substructure that are eligible for the circle notation
into the hash that is stored in the print context. Any object
that appears two or more times is associated with a t value.
(obj_print, obj_pprint): Unless circle printing is already in
effect, check *print-circle* and turn it on if necessary and
prepare the context, associating it with the stream. Either
way, if circle printing is enabled, call populate_obj_hash to
walk the object and add its components to the hash.
Diffstat (limited to 'struct.c')
0 files changed, 0 insertions, 0 deletions