diff options
author | Sverker Eriksson <sverker@erlang.org> | 2023-03-27 20:37:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 20:37:04 +0200 |
commit | 1b3c6214d4bf359f7e5c143bef5c5ad9c90c5536 (patch) | |
tree | 975dee673b2a363fbc494d8c167154ae549be7d3 /lib/stdlib | |
parent | f9cdb96f3ab07b378a66ebfb1473184374f4e16f (diff) | |
parent | 2628698afd7eddbde4204158062edf9111204bad (diff) | |
download | erlang-1b3c6214d4bf359f7e5c143bef5c5ad9c90c5536.tar.gz |
Merge PR-7050 from sabiwara/fix-iolib-build_text-maps_order
Make maps_order optional in io_lib:build_text/1
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/io_lib_format.erl | 5 | ||||
-rw-r--r-- | lib/stdlib/test/io_SUITE.erl | 18 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/stdlib/src/io_lib_format.erl b/lib/stdlib/src/io_lib_format.erl index 9624ee450f..b338afb982 100644 --- a/lib/stdlib/src/io_lib_format.erl +++ b/lib/stdlib/src/io_lib_format.erl @@ -289,8 +289,9 @@ build_small([]) -> []. build_limited([#{control_char := C, args := As, width := F, adjust := Ad, precision := P, pad_char := Pad, encoding := Enc, - strings := Str, maps_order := Ord} | Cs], + strings := Str} = Map | Cs], NumOfPs0, Count0, MaxLen0, I) -> + Ord = maps:get(maps_order, Map, undefined), MaxChars = if MaxLen0 < 0 -> MaxLen0; true -> MaxLen0 div Count0 @@ -314,7 +315,7 @@ build_limited([$\n|Cs], NumOfPs, Count, MaxLen, _I) -> [$\n|build_limited(Cs, NumOfPs, Count, MaxLen, 0)]; build_limited([$\t|Cs], NumOfPs, Count, MaxLen, I) -> [$\t|build_limited(Cs, NumOfPs, Count, MaxLen, ((I + 8) div 8) * 8)]; -build_limited([C|Cs], NumOfPs, Count, MaxLen, I) -> +build_limited([C|Cs], NumOfPs, Count, MaxLen, I) when is_integer(C) -> [C|build_limited(Cs, NumOfPs, Count, MaxLen, I+1)]; build_limited([], _, _, _, _) -> []. diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index 1ec23b8e90..f26d98cc18 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -34,7 +34,7 @@ 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, github_4801/1, chars_limit/1, error_info/1, otp_17525/1, - unscan_format_without_maps_order/1]). + unscan_format_without_maps_order/1, build_text_without_maps_order/1]). -export([pretty/2, trf/3]). @@ -68,7 +68,8 @@ all() -> 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, github_4801, chars_limit, - error_info, otp_17525, unscan_format_without_maps_order]. + error_info, otp_17525, unscan_format_without_maps_order, + build_text_without_maps_order]. %% Error cases for output. error_1(Config) when is_list(Config) -> @@ -3196,3 +3197,16 @@ unscan_format_without_maps_order(_Config) -> width => none }, {"~ts",[[<<"1">>]]} = io_lib:unscan_format([FormatSpec]). + +build_text_without_maps_order(_Config) -> + FormatSpec = #{ + adjust => right, + args => [[<<"1">>]], + control_char => 115, + encoding => unicode, + pad_char => 32, + precision => none, + strings => true, + width => none + }, + [["1"]] = io_lib:build_text([FormatSpec]). |