File 0492-Fix-io_lib_pretty-printable_latin1_list-2.patch of Package erlang
From e38219c286e8a23041b7d28f80bae55c57892cd6 Mon Sep 17 00:00:00 2001
From: k32 <10274441+k32@users.noreply.github.com>
Date: Wed, 5 May 2021 16:49:35 +0200
Subject: [PATCH] Fix io_lib_pretty:printable_latin1_list/2
Fixes #4801
---
lib/stdlib/src/io_lib_pretty.erl | 4 ++--
lib/stdlib/test/io_SUITE.erl | 8 ++++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl
index 838d412d0c..51859b6f3d 100644
--- a/lib/stdlib/src/io_lib_pretty.erl
+++ b/lib/stdlib/src/io_lib_pretty.erl
@@ -835,9 +835,9 @@ printable_bin1(Bin, Start, Len) ->
%% -> all | integer() >=0. Adopted from io_lib.erl.
printable_latin1_list([_ | _], 0) -> 0;
-printable_latin1_list([C | Cs], N) when C >= $\s, C =< $~ ->
+printable_latin1_list([C | Cs], N) when is_integer(C), C >= $\s, C =< $~ ->
printable_latin1_list(Cs, N - 1);
-printable_latin1_list([C | Cs], N) when C >= $\240, C =< $\377 ->
+printable_latin1_list([C | Cs], N) when is_integer(C), C >= $\240, C =< $\377 ->
printable_latin1_list(Cs, N - 1);
printable_latin1_list([$\n | Cs], N) -> printable_latin1_list(Cs, N - 1);
printable_latin1_list([$\r | Cs], N) -> printable_latin1_list(Cs, N - 1);
diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl
index 4eb5b1772c..63395be98a 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, otp_17525/1]).
+ github_4801/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_17525].
+ otp_15639, otp_15705, otp_15847, otp_15875, github_4801, chars_limit, otp_17525].
%% Error cases for output.
error_1(Config) when is_list(Config) ->
@@ -2782,6 +2782,10 @@ otp_15847(_Config) ->
S = io_lib:format("~tp", [[{0, [<<"00">>]}]], [{chars_limit, 18}]),
"[{0,[<<\"00\">>]}]" = lists:flatten(S).
+
+github_4801(_Config) ->
+ <<"{[81.6]}">> = iolist_to_binary(io_lib:format("~p", [{[81.6]}], [{chars_limit,40}])).
+
%% GH-4824, GH-4842, OTP-17459.
chars_limit(_Config) ->
List = fun R(I) ->
--
2.26.2