summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2021-09-02 12:15:41 +0200
committerErlang/OTP <otp@erlang.org>2021-09-02 12:15:41 +0200
commit8ac4cdee7c01d66eb24cabcc00b7feecece57bc3 (patch)
tree4598129d29f5ec8a40ca8114187bf83dbcd7c129
parent0054a4beee1d977bb2adbb8b10af4edcec37b225 (diff)
parenta3323d9cd1630c5e9cb3357dde16e697aedf65ae (diff)
downloaderlang-8ac4cdee7c01d66eb24cabcc00b7feecece57bc3.tar.gz
Merge branch 'hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525' into maint-22
* hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525: stdlib: Fix a concerning io_lib option 'chars_limit' # Conflicts: # lib/stdlib/test/io_SUITE.erl
-rw-r--r--lib/stdlib/src/io_lib_pretty.erl6
-rw-r--r--lib/stdlib/test/io_SUITE.erl27
2 files changed, 30 insertions, 3 deletions
diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl
index 32c5415067..63fa2b13e2 100644
--- a/lib/stdlib/src/io_lib_pretty.erl
+++ b/lib/stdlib/src/io_lib_pretty.erl
@@ -185,6 +185,8 @@ pp({S,_Len,_,_}, _Col, _Ll, _M, _TInd, _Ind, _LD, _W) ->
%% Print a tagged tuple by indenting the rest of the elements
%% differently to the tag. Tuple has size >= 2.
+pp_tag_tuple({dots, _, _, _}, _Col, _Ll, _M, _TInd, _Ind, _LD, _W) ->
+ "...";
pp_tag_tuple([{Tag,Tlen,_,_} | L], Col, Ll, M, TInd, Ind, LD, W) ->
%% this uses TInd
TagInd = Tlen + 2,
@@ -993,7 +995,9 @@ cind_tag_tuple([{_Tag,Tlen,_,_} | L], Col, Ll, M, Ind, LD, W) ->
cind_list(L, Tcol, Ll, M, Ind, LD, W + Tlen + 1);
true ->
throw(no_good)
- end.
+ end;
+cind_tag_tuple(_, _Col, _Ll, _M, Ind, _LD, _W) ->
+ Ind.
cind_map([P | Ps], Col, Ll, M, Ind, LD, W) ->
PW = cind_pair(P, Col, Ll, M, Ind, last_depth(Ps, LD), W),
diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl
index 025fcbc408..3d0a57eb28 100644
--- a/lib/stdlib/test/io_SUITE.erl
+++ b/lib/stdlib/test/io_SUITE.erl
@@ -33,7 +33,7 @@
maps/1, coverage/1, otp_14178_unicode_atoms/1, otp_14175/1,
otp_14285/1, limit_term/1, otp_14983/1, otp_15103/1, otp_15076/1,
otp_15159/1, otp_15639/1, otp_15705/1, otp_15847/1, otp_15875/1,
- chars_limit/1]).
+ chars_limit/1, otp_17525/1]).
-export([pretty/2, trf/3]).
@@ -66,7 +66,7 @@ all() ->
io_lib_width_too_small, io_with_huge_message_queue,
format_string, maps, coverage, otp_14178_unicode_atoms, otp_14175,
otp_14285, limit_term, otp_14983, otp_15103, otp_15076, otp_15159,
- otp_15639, otp_15705, otp_15847, otp_15875, chars_limit].
+ otp_15639, otp_15705, otp_15847, otp_15875, chars_limit, otp_17525].
%% Error cases for output.
error_1(Config) when is_list(Config) ->
@@ -2753,3 +2753,26 @@ chars_limit(_Config) ->
What <- [List, Tuple, Map, Record]
],
ok.
+
+%% GH-5053. 'chars_limit' bug.
+otp_17525(_Config) ->
+ L = [{xxxxxxxxx,aaaa},
+ {yyyyyyyyyyyy,1},
+ {eeeeeeeeeeeee,bbbb},
+ {ddddddddd,1111111111},
+ {gggggggggggggggggggg,cccc},
+ {uuuuuuuuuuuu,11}],
+ S = io_lib:format("aaaaaaaaaaaaaaaaaa ~p bbbbbbbbbbb ~p",
+ ["cccccccccccccccccccccccccccccccccccccc", L],
+ [{chars_limit, 155}]),
+ "aaaaaaaaaaaaaaaaaa \"cccccccccccccccccccccccccccccccccccccc\" bbbbbbbbbbb [{xxxxxxxxx,\n"
+ " aaaa},\n"
+ " {yyyyyyyyyyyy,\n"
+ " 1},\n"
+ " {eeeeeeeeeeeee,\n"
+ " bbbb},\n"
+ " {ddddddddd,\n"
+ " 1111111111},\n"
+ " {...}|...]" =
+ lists:flatten(S),
+ ok.