aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/io_lib.erl14
-rw-r--r--lib/stdlib/src/io_lib_pretty.erl16
-rw-r--r--lib/stdlib/test/io_SUITE.erl4
3 files changed, 18 insertions, 16 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),
diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl
index 2204231943..3d5a979b3e 100644
--- a/lib/stdlib/src/io_lib_pretty.erl
+++ b/lib/stdlib/src/io_lib_pretty.erl
@@ -596,21 +596,23 @@ print_length_map(Map, 1, _T, RF, Enc, Str) ->
{"#{...}", 6, 3, More};
print_length_map(Map, D, T, RF, Enc, Str) when is_map(Map) ->
Next = maps:next(maps:iterator(Map)),
- PairsS = print_length_map_pairs(Next, D, tsub(T, 3), RF, Enc, Str),
+ PairsS = print_length_map_pairs(Next, D, D - 1, tsub(T, 3), RF, Enc, Str),
{Len, Dots} = list_length(PairsS, 3, 0),
{{map, PairsS}, Len, Dots, no_more}.
-print_length_map_pairs(none, _D, _T, _RF, _Enc, _Str) ->
+print_length_map_pairs(none, _D, _D0, _T, _RF, _Enc, _Str) ->
[];
-print_length_map_pairs(Term, D, T, RF, Enc, Str) when D =:= 1; T =:= 0->
- More = fun(T1, Dd) -> ?FUNCTION_NAME(Term, D+Dd, T1, RF, Enc, Str) end,
+print_length_map_pairs(Term, D, D0, T, RF, Enc, Str) when D =:= 1; T =:= 0->
+ More = fun(T1, Dd) ->
+ ?FUNCTION_NAME(Term, D+Dd, D0, T1, RF, Enc, Str)
+ end,
{dots, 3, 3, More};
-print_length_map_pairs({K, V, Iter}, D, T, RF, Enc, Str) ->
- Pair1 = print_length_map_pair(K, V, D - 1, tsub(T, 1), RF, Enc, Str),
+print_length_map_pairs({K, V, Iter}, D, D0, T, RF, Enc, Str) ->
+ Pair1 = print_length_map_pair(K, V, D0, tsub(T, 1), RF, Enc, Str),
{_, Len1, _, _} = Pair1,
Next = maps:next(Iter),
[Pair1 |
- print_length_map_pairs(Next, D - 1, tsub(T, Len1+1), RF, Enc, Str)].
+ print_length_map_pairs(Next, D - 1, D0, tsub(T, Len1+1), RF, Enc, Str)].
print_length_map_pair(K, V, D, T, RF, Enc, Str) ->
{_, KL, KD, _} = P1 = print_length(K, D, T, RF, Enc, Str),
diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl
index 609d0ad876..9f48fbf5e3 100644
--- a/lib/stdlib/test/io_SUITE.erl
+++ b/lib/stdlib/test/io_SUITE.erl
@@ -2441,7 +2441,7 @@ limit_term(_Config) ->
{_, 1} = limt(T, 0),
{_, 2} = limt(T, 1),
{_, 2} = limt(T, 2),
- {_, 1} = limt(T, 3),
+ {_, 2} = limt(T, 3),
{_, 1} = limt(T, 4),
T2 = #{[] => {},{} => []},
{_, 2} = limt(T2, 1),
@@ -2542,7 +2542,7 @@ trunc_depth(D, Fun) ->
"#{{[...],...} => {[...],...},...}" = Fun(M, D, 22),
"#{{[...],...} => {[...],...},[...] => [...]}" = Fun(M, D, 31),
"#{{[...],...} => {[...],...},[...] => [...]}" = Fun(M, D, 33),
- "#{{[1|...],[...]} => {[1|...],[...]},[1|...] => [...]}" =
+ "#{{[1|...],[...]} => {[1|...],[...]},[1,2|...] => [...]}" =
Fun(M, D, 50),
"..." = Fun({c, 1, 2}, D, 0),