aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/io_lib.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2018-04-20 12:19:12 +0200
committerHans Bolinder <[email protected]>2018-04-25 16:25:22 +0200
commit872548b0c798e1e1fe9350d04c9460f3a6db5d41 (patch)
tree8eb26eba47a1cad7b37e7c75ea43c2f71bfc7bbd /lib/stdlib/src/io_lib.erl
parent29a347ffd408c68861a914db4efc75d8ea20a762 (diff)
downloadotp-872548b0c798e1e1fe9350d04c9460f3a6db5d41.tar.gz
otp-872548b0c798e1e1fe9350d04c9460f3a6db5d41.tar.bz2
otp-872548b0c798e1e1fe9350d04c9460f3a6db5d41.zip
stdlib: Modify the printing of map associations with wWpP
Use the same depth for all (printed) elements of a map. Since the order of keys can vary when printing a map--maps:iterator/1 and maps:next/1 are used--it is more consistent to print all associations with the same depth. If the associations printed are limited by the depth, the selection of associations is arbitrary, as before.
Diffstat (limited to 'lib/stdlib/src/io_lib.erl')
-rw-r--r--lib/stdlib/src/io_lib.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/stdlib/src/io_lib.erl b/lib/stdlib/src/io_lib.erl
index 2624d420cc..3a5aba60b4 100644
--- a/lib/stdlib/src/io_lib.erl
+++ b/lib/stdlib/src/io_lib.erl
@@ -388,16 +388,16 @@ write_ref(Ref) ->
erlang:ref_to_list(Ref).
write_map(Map, D, E) when is_integer(D) ->
- [$#,${,write_map_body(maps:to_list(Map), D, E),$}].
+ [$#,${,write_map_body(maps:to_list(Map), D, D - 1, E),$}].
-write_map_body(_, 1, _E) -> "...";
-write_map_body([], _, _E) -> [];
-write_map_body([{K,V}], D, E) -> write_map_assoc(K, V, D, E);
-write_map_body([{K,V}|KVs], D, E) ->
- [write_map_assoc(K, V, D, E),$, | write_map_body(KVs, D-1, E)].
+write_map_body(_, 1, _D0, _E) -> "...";
+write_map_body([], _, _D0, _E) -> [];
+write_map_body([{K,V}], _D, D0, E) -> write_map_assoc(K, V, D0, E);
+write_map_body([{K,V}|KVs], D, D0, E) ->
+ [write_map_assoc(K, V, D0, E),$, | write_map_body(KVs, D - 1, D0, E)].
write_map_assoc(K, V, D, E) ->
- [write1(K, D - 1, E)," => ",write1(V, D-1, E)].
+ [write1(K, D, E)," => ",write1(V, D, E)].
write_binary(B, D) when is_integer(D) ->
{S, _} = write_binary(B, D, -1),