aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/src/misc/ei_printterm.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2019-04-17 19:09:57 +0200
committerSverker Eriksson <[email protected]>2019-04-17 19:09:57 +0200
commit236cb4b5eb3b89c837324a5ae7a11117d671d717 (patch)
tree41a090786155ab22d5c7a883c275c59d059a4ea0 /lib/erl_interface/src/misc/ei_printterm.c
parentdbe9bbfb801bcd92cc54c73ce96203b3a04c5517 (diff)
parent6a0deeae54ee18aa2028e994c33d633bb41021ed (diff)
downloadotp-236cb4b5eb3b89c837324a5ae7a11117d671d717.tar.gz
otp-236cb4b5eb3b89c837324a5ae7a11117d671d717.tar.bz2
otp-236cb4b5eb3b89c837324a5ae7a11117d671d717.zip
Merge branch 'sverker/bit-binary-ext/OTP-15712'
* sverker/bit-binary-ext/OTP-15712: jinterface: Add dist flag for export funs erl_interface: Add bitstring and export fun support erl_interface: Remove old r9 pid and port compatibility erl_interface: Refactor ei_decode_SUITE erl_interface: Fix maps arity from ei_get_type() erl_interface: Remove ei_get_type_internal() erl_interface: Deprecate ei_encode_term and ei_decode_term
Diffstat (limited to 'lib/erl_interface/src/misc/ei_printterm.c')
-rw-r--r--lib/erl_interface/src/misc/ei_printterm.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/erl_interface/src/misc/ei_printterm.c b/lib/erl_interface/src/misc/ei_printterm.c
index 058de00de5..a89b990ac1 100644
--- a/lib/erl_interface/src/misc/ei_printterm.c
+++ b/lib/erl_interface/src/misc/ei_printterm.c
@@ -131,7 +131,7 @@ static int print_term(FILE* fp, ei_x_buff* x,
if (fp == NULL && x == NULL) return -1;
doquote = 0;
- ei_get_type_internal(buf, index, &ty, &n);
+ ei_get_type(buf, index, &ty, &n);
switch (ty) {
case ERL_ATOM_EXT:
case ERL_ATOM_UTF8_EXT:
@@ -189,7 +189,7 @@ static int print_term(FILE* fp, ei_x_buff* x,
xputs(", ", fp, x); ch_written += 2;
}
}
- if (ei_get_type_internal(buf, &tindex, &ty, &n) < 0) goto err;
+ if (ei_get_type(buf, &tindex, &ty, &n) < 0) goto err;
if (ty != ERL_NIL_EXT) {
xputs(" | ", fp, x); ch_written += 3;
r = print_term(fp, x, buf, &tindex);
@@ -249,6 +249,34 @@ static int print_term(FILE* fp, ei_x_buff* x,
xputc('>', fp, x); ++ch_written;
ei_free(p);
break;
+ case ERL_BIT_BINARY_EXT: {
+ size_t bits;
+ int trunc = 0;
+ p = ei_malloc(n);
+ if (p == NULL) goto err;
+ if (ei_decode_bitstring(buf, index, p, n, &bits) < 0) {
+ ei_free(p);
+ goto err;
+ }
+ ch_written += xprintf(fp, x, "#Bits<");
+ m = (bits+7) / 8;
+ if (m > BINPRINTSIZE) {
+ m = BINPRINTSIZE;
+ trunc = 1;
+ }
+ --m;
+ for (i = 0; i < m; ++i) {
+ ch_written += xprintf(fp, x, "%d,", p[i]);
+ }
+ ch_written += xprintf(fp, x, "%d", p[i]);
+ if (trunc)
+ ch_written += xprintf(fp, x, ",...");
+ else if (bits % 8 != 0)
+ ch_written += xprintf(fp, x, ":%u", (unsigned)(bits % 8));
+ xputc('>', fp, x); ++ch_written;
+ ei_free(p);
+ break;
+ }
case ERL_SMALL_INTEGER_EXT:
case ERL_INTEGER_EXT:
if (ei_decode_long(buf, index, &l) < 0) goto err;