summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/hash.c b/hash.c
index 543c2d62..73738b6b 100644
--- a/hash.c
+++ b/hash.c
@@ -226,10 +226,12 @@ cnum cobj_hash_op(val obj)
static val print_key_val(val out, val key, val value)
{
+ width_check(out, chr(' '));
+
if (value)
- format(out, lit(" (~s ~s)"), key, value, nao);
+ format(out, lit("(~s ~s)"), key, value, nao);
else
- format(out, lit(" (~s)"), key, nao);
+ format(out, lit("(~s)"), key, nao);
return nil;
}
@@ -349,15 +351,23 @@ static void hash_print_op(val hash, val out)
{
struct hash *h = coerce(struct hash *, hash->co.handle);
int need_space = 0;
+ val save_mode = test_set_indent_mode(out, num_fast(indent_off),
+ num_fast(indent_data));
+ val save_indent;
+
+ put_string(lit("#H("), out);
+
+ save_indent = inc_indent(out, zero);
+
+ put_char(chr('('), out);
- put_string(lit("#H(("), out);
if (h->hash_fun == equal_hash) {
obj_print(equal_based_k, out);
need_space = 1;
}
if (h->flags != hash_weak_none) {
if (need_space)
- put_string(lit(" "), out);
+ put_char(chr(' '), out);
switch (h->flags) {
case hash_weak_both:
obj_print(weak_keys_k, out);
@@ -375,6 +385,9 @@ static void hash_print_op(val hash, val out)
put_string(lit(")"), out);
maphash(curry_123_23(func_n3(print_key_val), out), hash);
put_string(lit(")"), out);
+
+ set_indent_mode(out, save_mode);
+ set_indent(out, save_indent);
}
static void hash_mark(val hash)