diff options
author | Erlang/OTP <otp@erlang.org> | 2021-07-21 16:39:54 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2021-07-21 16:39:54 +0200 |
commit | c60384e71f0c87c16cfc5139cc4d1acb2df85ad5 (patch) | |
tree | 05608a9337f9c872e15aaff21bb5ecdc8c8a3857 /lib/stdlib | |
parent | 4e7284bc07e3600ecac55722b1d8375df518b316 (diff) | |
parent | a3323d9cd1630c5e9cb3357dde16e697aedf65ae (diff) | |
download | erlang-c60384e71f0c87c16cfc5139cc4d1acb2df85ad5.tar.gz |
Merge branch 'hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525' into maint-24
* 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
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/io_lib_pretty.erl | 6 | ||||
-rw-r--r-- | lib/stdlib/test/io_SUITE.erl | 27 |
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 e4f01eed3f..ced025be14 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, @@ -990,7 +992,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 ea4667ba32..c31e479ee3 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) -> @@ -2982,3 +2982,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. |