diff options
author | Richard Carlsson <[email protected]> | 2018-03-02 14:19:34 +0100 |
---|---|---|
committer | Richard Carlsson <[email protected]> | 2018-03-02 14:19:34 +0100 |
commit | 6ff26316ffb80fbd2d7daa79986671f0e8c2db70 (patch) | |
tree | e90ff81f3d30ede2ec98a9d7256ee5c1160261f3 /lib | |
parent | bd5ebce131cc8a02e559b8eec2a68b089ca235a6 (diff) | |
download | otp-6ff26316ffb80fbd2d7daa79986671f0e8c2db70.tar.gz otp-6ff26316ffb80fbd2d7daa79986671f0e8c2db70.tar.bz2 otp-6ff26316ffb80fbd2d7daa79986671f0e8c2db70.zip |
Make io_lib:unscan_format/1 work with pad char and default precision
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/io_lib_format.erl | 7 | ||||
-rw-r--r-- | lib/stdlib/test/io_SUITE.erl | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/stdlib/src/io_lib_format.erl b/lib/stdlib/src/io_lib_format.erl index e345810ca0..2ef4e517d8 100644 --- a/lib/stdlib/src/io_lib_format.erl +++ b/lib/stdlib/src/io_lib_format.erl @@ -95,7 +95,7 @@ print([]) -> []. print(C, F, Ad, P, Pad, Encoding, Strings) -> - [$~] ++ print_field_width(F, Ad) ++ print_precision(P) ++ + [$~] ++ print_field_width(F, Ad) ++ print_precision(P, Pad) ++ print_pad_char(Pad) ++ print_encoding(Encoding) ++ print_strings(Strings) ++ [C]. @@ -103,8 +103,9 @@ print_field_width(none, _Ad) -> ""; print_field_width(F, left) -> integer_to_list(-F); print_field_width(F, right) -> integer_to_list(F). -print_precision(none) -> ""; -print_precision(P) -> [$. | integer_to_list(P)]. +print_precision(none, $\s) -> ""; +print_precision(none, _Pad) -> "."; % pad must be second dot +print_precision(P, _Pad) -> [$. | integer_to_list(P)]. print_pad_char($\s) -> ""; % default, no need to make explicit print_pad_char(Pad) -> [$., Pad]. diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index 45363c0592..4977f5375f 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -2005,6 +2005,7 @@ writes(N, F1) -> format_string(_Config) -> %% All but padding is tested by fmt/2. + "xxxxxxxsss" = fmt("~10..xs", ["sss"]), "xxxxxxsssx" = fmt("~10.4.xs", ["sss"]), "xxxxxxsssx" = fmt("~10.4.*s", [$x, "sss"]), ok. |