diff options
author | Björn Gustavsson <[email protected]> | 2019-05-14 08:15:59 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-05-29 16:31:06 +0200 |
commit | 3d7b35dcc7852ec735f39a66566f80f8dad65701 (patch) | |
tree | 8a1cfb20b9e0438799db042ad6aa5dbb34001cfc /lib/erl_interface/src | |
parent | f53097e9f856281e7d8d89dc42716fb77b26e36e (diff) | |
download | otp-3d7b35dcc7852ec735f39a66566f80f8dad65701.tar.gz otp-3d7b35dcc7852ec735f39a66566f80f8dad65701.tar.bz2 otp-3d7b35dcc7852ec735f39a66566f80f8dad65701.zip |
Teach ei_print_term() to print maps
Diffstat (limited to 'lib/erl_interface/src')
-rw-r--r-- | lib/erl_interface/src/misc/ei_printterm.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/erl_interface/src/misc/ei_printterm.c b/lib/erl_interface/src/misc/ei_printterm.c index 5c40fb7747..52ab8cd504 100644 --- a/lib/erl_interface/src/misc/ei_printterm.c +++ b/lib/erl_interface/src/misc/ei_printterm.c @@ -306,12 +306,29 @@ static int print_term(FILE* fp, ei_x_buff* x, } break; - case ERL_FLOAT_EXT: case NEW_FLOAT_EXT: if (ei_decode_double(buf, index, &d) < 0) goto err; ch_written += xprintf(fp, x, "%f", d); break; + case ERL_MAP_EXT: + if (ei_decode_map_header(buf, &tindex, &n) < 0) goto err; + ch_written += xprintf(fp, x, "#{"); + for (i = 0; i < n; ++i) { + r = print_term(fp, x, buf, &tindex); + if (r < 0) goto err; + ch_written += r; + ch_written += xprintf(fp, x, " => "); + r = print_term(fp, x, buf, &tindex); + if (r < 0) goto err; + ch_written += r; + if (i < n-1) { + xputs(", ", fp, x); ch_written += 2; + } + } + *index = tindex; + xputc('}', fp, x); ch_written++; + break; default: goto err; } |