Skip to content

Commit bf94fd8

Browse files
committed
Merge pull request #1473 from UncleGrumpy/port_format
Fix the formatting of local ports Corrects the format of ports to match the OTP spec (and size that was already defined correctly). These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 787f8e5 + ea39703 commit bf94fd8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libAtomVM/term.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int term_funprint(PrinterFun *fun, term t, const GlobalContext *global)
205205
} else if (term_is_local_port(t)) {
206206
// Update also PORT_AS_CSTRING_LEN when changing this format string
207207
int32_t process_id = term_to_local_process_id(t);
208-
return fun->print(fun, "#Port<0.%" PRIu32 ".0>", process_id);
208+
return fun->print(fun, "#Port<0.%" PRIu32 ">", process_id);
209209

210210
} else if (term_is_external_port(t)) {
211211
// Update also PORT_AS_CSTRING_LEN when changing this format string

tests/erlang_tests/test_binary_to_term.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,11 @@ test_encode_port() ->
628628
ExpectedSize = byte_size(Bin),
629629
case SupportsV4PortEncoding of
630630
true ->
631-
true = is_port(
632-
binary_to_term(
633-
<<131, 120, 119, 13, "nonode@nohost", 1:64, 0:32>>
634-
)
631+
LocalPort1 = binary_to_term(
632+
<<131, 120, 119, 13, "nonode@nohost", 1:64, 0:32>>
635633
),
634+
true = is_port(LocalPort1),
635+
"#Port<0.1>" = port_to_list(LocalPort1),
636636
Port1 = binary_to_term(<<131, 120, 119, 4, "true", 43:64, 0:32>>),
637637
Port2 = binary_to_term(<<131, 120, 119, 4, "true", 43:64, 1:32>>),
638638
false = Port1 =:= Port2,

0 commit comments

Comments
 (0)