File 1353-stdlib-Fix-a-concerning-io_lib-option-chars_limit.patch of Package erlang

From a3323d9cd1630c5e9cb3357dde16e697aedf65ae Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Thu, 15 Jul 2021 10:33:49 +0200
Subject: [PATCH] stdlib: Fix a concerning io_lib option 'chars_limit'

See also https://github.com/erlang/otp/issues/5053.
---
 lib/stdlib/src/io_lib_pretty.erl |  6 +++++-
 lib/stdlib/test/io_SUITE.erl     | 28 ++++++++++++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl
index 77f02eafe0..fbc2919a95 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,
@@ -973,7 +975,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 4eb5b1772c..bc96529a00 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_15847/1, otp_15875/1,
-         chars_limit/1]).
+         chars_limit/1, otp_17525/1]).
 
 -export([pretty/2, trf/3]).
 
@@ -66,7 +66,8 @@ 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_15847, otp_15875, chars_limit].
+     otp_15639, otp_15847, otp_15875, chars_limit,
+     otp_17525].
 
 %% Error cases for output.
 error_1(Config) when is_list(Config) ->
@@ -2786,3 +2787,26 @@ otp_15847(_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.
-- 
2.26.2

openSUSE Build Service is sponsored by